CHDK_DE Vorschauversion  Trunk Rev. 5779
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
usb_sync.c-Dateireferenz
#include "camera.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 90 der Datei usb_sync.c.

#define GPIO_VSYNC_UPDATE   0xC0F06000

Definiert in Zeile 89 der Datei usb_sync.c.

Dokumentation der Funktionen

void _wait_until_remote_button_is_released ( void  )

Definiert in Zeile 93 der Datei usb_sync.c.

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

Definiert in Zeile 36 der Datei usb_sync.c.

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

Definiert in Zeile 54 der Datei usb_sync.c.

55 {
56 #ifdef CAM_REMOTE_MULTICHANNEL
58  {
59  case REMOTE_INPUT_USB:
60  return get_usb_bit();
61 #ifdef CAM_REMOTE_HDMI_HPD
63  return get_hdmi_hpd_bit();
64 #endif
65 #ifdef CAM_REMOTE_ANALOG_AV
67  return get_analog_av_bit();
68 #endif
69 #ifdef CAM_REMOTE_AtoD_CHANNEL
72 #endif
73  }
74  return 0;
75 #else // not CAM_REMOTE_MULTICHANNEL
76  return( get_usb_bit() );
77 #endif
78 }

Variablen-Dokumentation

int forced_usb_port = 0

Definiert in Zeile 34 der Datei usb_sync.c.

int usb_remote_active

Definiert in Zeile 32 der Datei usb_remote.c.

int usb_sync_wait_flag

Definiert in Zeile 31 der Datei usb_remote.c.