CHDK_DE Vorschauversion  Trunk Rev. 5163
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
usb_sync.c-Dateireferenz
#include "camera.h"
#include "stdlib.h"
#include "clock.h"
#include "modes.h"
#include "conf.h"
#include "usb_remote.h"
#include "script_api.h"
#include "shooting.h"
+ Include-Abhängigkeitsdiagramm für usb_sync.c:

gehe zum Quellcode dieser Datei

Makrodefinitionen

#define GPIO_VSYNC_UPDATE   0xC0F06000
 
#define GPIO_VSYNC_MAX   0xC0F06014
 

Funktionen

int force_usb_state (int state)
 
int get_remote_state ()
 
void _wait_until_remote_button_is_released (void)
 

Variablen

int usb_sync_wait_flag
 
int usb_remote_active
 
int forced_usb_port = 0
 

Makro-Dokumentation

#define GPIO_VSYNC_MAX   0xC0F06014

Definiert in Zeile 91 der Datei usb_sync.c.

#define GPIO_VSYNC_UPDATE   0xC0F06000

Definiert in Zeile 90 der Datei usb_sync.c.

Dokumentation der Funktionen

void _wait_until_remote_button_is_released ( void  )

Definiert in Zeile 94 der Datei usb_sync.c.

95 {
96  int tick;
97 
98  // hook for script to block processing just prior to exposure start
100 
101  if ( usb_sync_wait_flag ) // flag set when something wants the current shot to be sync'd
102  {
103  usb_remote_status_led(1); // indicate to user we are waiting for remote button to release - this happens every time the camera takes a picture
104  tick = get_tick_count(); // timestamp so we don't hang here forever if something goes wrong
105 
106  #ifdef CAM_REMOTE_USES_PRECISION_SYNC
107 
108  int std_period = EngDrvRead(GPIO_VSYNC_MAX);
109 
110  do { } while( get_remote_state() && ((int)get_tick_count()-tick < DELAY_TIMEOUT));
111 
112  int cur_cnt = *(volatile int*)(GPIO_VSYNC_CURRENT) & 0xffff; // get the counter state at the time of sync
113 
114  int sync_period = std_period * 2 + cur_cnt; // schedule the end of extended period at t = t(synch pulse) + sync_time
115 
116  if (std_period - cur_cnt < 10) // if too close to overflow, wait for the next period
117  {
118  sync_period -= (std_period - cur_cnt);
119  while ((*(volatile int*)(GPIO_VSYNC_CURRENT) & 0xffff) >= cur_cnt) {};
120  }
121 
122  *(volatile int*)(GPIO_VSYNC_MAX) = sync_period; // write the length of the extended period to the register
123  *(volatile int*)(GPIO_VSYNC_UPDATE) = 1;
124 
125  while (*(volatile int*)(GPIO_VSYNC_UPDATE)) {}; // wait until the new value is applied
126 
127  //now we are at the beginning of extended period
128 
129  *(volatile int*)(GPIO_VSYNC_MAX) = std_period; // back to standard timing on next period
130  *(volatile int*)(GPIO_VSYNC_UPDATE) = 1;
131 
132  /* on s95 the std_period is 0x110
133  1. if the shooting starts with GPIO_VSYNC_CURRENT value between 0 and 0xe1, it starts immediately
134  2. if the shooting starts with value between 0xe1 and 0x110 (end of period), it waits for the next period
135 
136  now we want to go for the case 2
137  msleep(40) should get us there, the timing is not critical and with sleep we give the camera a chance
138  to run the delayed low prio tasks now
139  */
140 
141  msleep(40);
142 
143  // now we are in the second half of the extended period, shooting can start, it will wait for the end of the period
144 
145  #else // CAM_REMOTE_USES_PRECISION_SYNC
146  // delay until USB state goes to "Off" or timeout
147 
148  do { } while( get_remote_state() && ((int)get_tick_count()-tick < DELAY_TIMEOUT));
149 
150  // add a sync calibration delay if requested
151 
153 
154  #endif
155  #ifdef USB_REMOTE_DEBUGGING
156  sync_counter++ ;
157  #endif
158  usb_sync_wait_flag = 0 ;
159  usb_remote_status_led(0); // alert the user that we are all done
160  }
161 
162 }
int force_usb_state ( int  state)

Definiert in Zeile 37 der Datei usb_sync.c.

38 {
39  forced_usb_port = state ;
40 #ifdef CAM_ALLOWS_USB_PORT_FORCING
41  return 1 ;
42 #else
43  return 0 ;
44 #endif
45 }
int get_remote_state ( )

Definiert in Zeile 55 der Datei usb_sync.c.

56 {
57 #ifdef CAM_REMOTE_MULTICHANNEL
59  {
60  case REMOTE_INPUT_USB:
61  return get_usb_bit();
62 #ifdef CAM_REMOTE_HDMI_HPD
64  return get_hdmi_hpd_bit();
65 #endif
66 #ifdef CAM_REMOTE_ANALOG_AV
68  return get_analog_av_bit();
69 #endif
70 #ifdef CAM_REMOTE_AtoD_CHANNEL
73 #endif
74  }
75  return 0;
76 #else // not CAM_REMOTE_MULTICHANNEL
77  return( get_usb_bit() );
78 #endif
79 }

Variablen-Dokumentation

int forced_usb_port = 0

Definiert in Zeile 35 der Datei usb_sync.c.

int usb_remote_active

Definiert in Zeile 33 der Datei usb_remote.c.

int usb_sync_wait_flag

Definiert in Zeile 32 der Datei usb_remote.c.