|
@@ -248,16 +248,17 @@ int main(void)
|
248
|
248
|
gptStart(&GPTD4, &gpt4cfg);
|
249
|
249
|
|
250
|
250
|
while (true) {
|
|
251
|
+ /* Wait for a signal */
|
|
252
|
+ chEvtWaitAny(ALL_EVENTS);
|
|
253
|
+
|
251
|
254
|
/* If an NEC power signal was received */
|
252
|
255
|
if (nec_addr == 0x80 && nec_data == 0x18) {
|
253
|
256
|
/* Turn on the LED */
|
254
|
257
|
palClearPad(GPIOC, GPIOC_LED);
|
255
|
258
|
|
256
|
|
- /* Wait to see if another code arrives */
|
257
|
|
- if (chEvtWaitAnyTimeout(ALL_EVENTS, MS2ST(200))) {
|
258
|
|
- /* If one does, keep waiting so as not to interfere */
|
259
|
|
- continue;
|
260
|
|
- }
|
|
259
|
+ /* Wait until further codes stop arriving to avoid interfering */
|
|
260
|
+ while (chEvtWaitAnyTimeout(ALL_EVENTS, MS2ST(200)))
|
|
261
|
+ ;
|
261
|
262
|
|
262
|
263
|
/* Send the RC5 power signal */
|
263
|
264
|
for (int i = 0; i < 3; i++) {
|
|
@@ -268,7 +269,5 @@ int main(void)
|
268
|
269
|
/* Turn off the LED */
|
269
|
270
|
palSetPad(GPIOC, GPIOC_LED);
|
270
|
271
|
}
|
271
|
|
- /* Wait for a signal */
|
272
|
|
- chEvtWaitAny(ALL_EVENTS);
|
273
|
272
|
}
|
274
|
273
|
}
|