Hardware Reference
In-Depth Information
200 t0 = t1; /
Save for next call
/
201 return n; /
Return value
/
202 }
203
204 /
205
Signal handler to quit the program :
206
/
207 static void
208 sigint_handler(int signo) {
209 is_signaled = 1; /
Signal to exit program
/
210 }
211
212 /
213
Wait until the line changes :
214
/
215 static inline int
216 wait_change(double
ms) {
217 /
Invert the logic of the input pin
/
218 return gpio_poll(gpio_fd,ms) ? 0 : 1;
219 }
220
221 /
222
Wait until line changes to "level" :
223
/
224 static int
225 wait_level(int level) {
226 int v;
227 double ms;
228
229 while ( (v = wait_change(&ms)) != level )
230 ;
231 return v;
232 }
233
234 /
235
Get a 32 bit code from remote control :
236
/
237 static unsigned long
238 getword(void) {
239 static struct timeval t0 = { 0, 0 };
240 static unsigned long last = 0;
241 struct timeval t1;
242 double ms;
243 int v, b, count;
244 unsigned long word = 0;
245
Search WWH ::




Custom Search