Johannes Stratmann
/
IRMP_Receiver
Sample code for IRMP library
Diff: main.cpp
- Revision:
- 1:57d9ea192a5e
- Parent:
- 0:4146c9dd6aa5
--- a/main.cpp Sat Jan 09 14:19:29 2016 +0000 +++ b/main.cpp Sat Jan 09 14:26:06 2016 +0000 @@ -4,9 +4,11 @@ #define LED_ON 0 #define LED_OFF 1 -DigitalOut led(P0_14, 1); -DigitalOut flash(P0_12, 1); +// LED as test output +DigitalOut led(P0_14, LED_OFF); +DigitalOut flash(P0_12, LED_OFF); +// cyclic interrupt for IRMP ISR worker Ticker t; // only for performance test @@ -16,11 +18,12 @@ int timeISRAvgSum = 0; int countISRCalls = 0; +// this ISR must be called cyclic void irmpISR(void) { - int t1 = timerPerfTest.read_us(); + int t1 = timerPerfTest.read_us(); // read performance timer - irmp_ISR(); // call irmp ISR + irmp_ISR(); // call irmp ISR int timeISR = timerPerfTest.read_us() - t1; // calc time spent in worker ISR if (timeISR > timeISRMax) // store maximum @@ -35,6 +38,7 @@ led = LED_OFF; timerPerfTest.start(); + // irmp_data holds result of received IR code IRMP_DATA irmp_data; irmp_init(); // initialize irmp @@ -43,8 +47,9 @@ // infinite loop, interrupts will blink PORTD pins and handle UART communications. while (1) { - flash = !flash; + flash = !flash; // test output. flashes at 15/2 kHz, you will not see it blinking + // check for received IR commands if (irmp_get_data (&irmp_data)) { // ir signal decoded, do something here...