This source file includes following definitions.
- usb_one_press_switch
- usb_two_press_switch
- usb_ricoh_ca1_switch
- usb_null_driver
1
2
3
4
5
6
7
8
9
10
11
12
13
14 #include "camera_info.h"
15 #include "clock.h"
16 #include "conf.h"
17 #include "usb_remote.h"
18
19
20
21
22
23
24 #ifdef USB_REMOTE_DEBUGGING
25
26 extern int debug_errors[] ;
27 extern void debug_error(int ) ;
28
29 #else
30
31 extern void debug_error(int ) ;
32
33 #endif
34
35
36
37
38
39
40
41 void usb_one_press_switch(int usb_state)
42 {
43 static int time_stamp = 0 ;
44 int current_time ;
45
46 current_time = get_tick_count();
47
48 switch( driver_state )
49 {
50 case SW_RESET :
51 virtual_remote_state = REMOTE_RELEASE ;
52 driver_state = SW_IDLE ;
53 break ;
54 case SW_IDLE :
55 virtual_remote_state = REMOTE_RELEASE ;
56 if ( usb_state == USB_POWER_ON )
57 {
58 driver_state = SW_POWER_CONNECT ;
59 time_stamp = current_time ;
60 }
61 break ;
62 case SW_POWER_CONNECT :
63 if ( usb_state == USB_POWER_ON )
64 {
65 if ( current_time - time_stamp > DEBOUNCE_TIME )
66 {
67 driver_state = SW_POWER_ON ;
68 virtual_remote_state = REMOTE_HALF_PRESS ;
69 time_stamp = current_time ;
70 }
71 }
72 else
73 {
74 driver_state = SW_IDLE ;
75 }
76 break ;
77 case SW_POWER_ON :
78 if ( usb_state != USB_POWER_ON )
79 {
80 if ( current_time - time_stamp > DEBOUNCE_TIME )
81 {
82 driver_state = SW_POWER_DISCONNECT ;
83 virtual_remote_state = REMOTE_FULL_PRESS ;
84 time_stamp = current_time ;
85 }
86 }
87 break ;
88 case SW_POWER_DISCONNECT :
89 if ( current_time - time_stamp > FULL_PRESS_PULSE_TIME )
90 {
91 driver_state = SW_IDLE ;
92 virtual_remote_state = REMOTE_RELEASE ;
93 }
94 break ;
95 default :
96 debug_error(INVALID_STATE) ;
97 break ;
98 }
99
100 };
101
102
103
104
105
106
107
108 void usb_two_press_switch(int usb_state)
109 {
110 static int time_stamp = 0 ;
111 int current_time ;
112
113 current_time = get_tick_count() ;
114
115 switch( driver_state )
116 {
117 case SW_RESET :
118 virtual_remote_state = REMOTE_RELEASE ;
119 driver_state = SW_IDLE ;
120 break ;
121 case SW_IDLE :
122 if ( usb_state == USB_POWER_ON )
123 {
124 driver_state = SW_POWER_CONNECT ;
125 time_stamp = current_time ;
126 }
127 break ;
128 case SW_POWER_CONNECT :
129 if ( usb_state == USB_POWER_ON )
130 {
131 if ( current_time - time_stamp > DEBOUNCE_TIME )
132 {
133 driver_state = SW_POWER_ON ;
134 virtual_remote_state = REMOTE_HALF_PRESS ;
135 time_stamp = current_time ;
136 }
137 }
138 else
139 {
140 driver_state = SW_IDLE ;
141 }
142 break ;
143 case SW_POWER_ON :
144 if ( usb_state == USB_POWER_OFF )
145 {
146 if ( current_time - time_stamp > DEBOUNCE_TIME )
147 {
148 driver_state = SW_POWER_DISCONNECT ;
149 time_stamp = current_time ;
150 }
151 }
152 break ;
153 case SW_POWER_DISCONNECT :
154 if ( usb_state == USB_POWER_ON )
155 {
156 if ( current_time - time_stamp > DEBOUNCE_TIME )
157 {
158 driver_state = SW_FULL_PRESS_ACTIVE;
159 virtual_remote_state = REMOTE_FULL_PRESS ;
160 time_stamp = current_time ;
161 }
162 }
163 else
164 {
165 if ( current_time - time_stamp > MAX_FULL_PRESS_DELAY )
166 {
167 virtual_remote_state = REMOTE_RELEASE ;
168 driver_state = SW_IDLE ;
169 }
170 }
171 break ;
172 case SW_FULL_PRESS_ACTIVE :
173 if ( usb_state == USB_POWER_OFF )
174 {
175 virtual_remote_state = REMOTE_RELEASE ;
176 driver_state = SW_IDLE ;
177 }
178 break ;
179 default :
180 debug_error(INVALID_STATE) ;
181 break ;
182 }
183 } ;
184
185
186
187
188
189
190
191 #define CA1_MAX_SHORT_PULSE_TIME 30
192 #define CA1_MAX_GAP_TIME 50
193
194
195
196
197
198
199
200
201
202
203
204
205 void usb_ricoh_ca1_switch(int usb_state)
206 {
207 static int time_stamp = 0 ;
208 int current_time ;
209
210 current_time = get_tick_count() ;
211
212 switch( driver_state )
213 {
214 case SW_RESET :
215 virtual_remote_state = REMOTE_RELEASE ;
216 driver_state = SW_IDLE ;
217 break ;
218 case SW_IDLE :
219 if ( usb_state == USB_POWER_ON )
220 {
221 driver_state = SW_CA1_1XX ;
222 time_stamp = current_time ;
223 }
224 break ;
225 case SW_CA1_1XX :
226 if ( usb_state == USB_POWER_OFF )
227 {
228 driver_state = SW_CA1_10X ;
229 time_stamp = current_time ;
230 }
231 else if ( current_time - time_stamp > CA1_MAX_SHORT_PULSE_TIME )
232 {
233 driver_state = SW_CA1_11 ;
234 virtual_remote_state = REMOTE_FULL_PRESS ;
235 }
236 break ;
237 case SW_CA1_10X :
238 if ( usb_state == USB_POWER_ON)
239 {
240 driver_state = SW_CA1_101 ;
241 }
242 else if ( current_time - time_stamp > CA1_MAX_GAP_TIME)
243 {
244 driver_state = SW_CA1_100 ;
245 }
246 break ;
247 case SW_CA1_101 :
248 if ( usb_state == USB_POWER_OFF )
249 {
250 driver_state = SW_IDLE ;
251 virtual_remote_state = REMOTE_RELEASE ;
252 }
253 break ;
254 case SW_CA1_100 :
255 driver_state = SW_IDLE ;
256 virtual_remote_state = REMOTE_HALF_PRESS ;
257 break ;
258 case SW_CA1_11 :
259 if ( usb_state == USB_POWER_OFF )
260 {
261 driver_state = SW_IDLE ;
262 virtual_remote_state = REMOTE_RELEASE ;
263 }
264 break ;
265 default :
266 debug_error(INVALID_STATE) ;
267 break ;
268 }
269 } ;
270
271
272
273
274
275
276
277
278
279 void usb_null_driver(__attribute__ ((unused))int i) { return ; } ;
280
281 void (*usb_driver[NUM_USB_INPUT_DRV])(int) =
282 {
283 usb_null_driver ,
284 usb_one_press_switch ,
285 usb_two_press_switch ,
286 usb_ricoh_ca1_switch ,
287 usb_null_driver
288 };