Implementing an IR receiver
I've built my IR receiver out of Radio Shack parts. It's all soldered together and it is working.
Currently it is hooked up to GPIO_WKUP_7. This is a normal GPIO pin that is capable of generating interrupts. Unfortunately the Linux kernel doesn't have support for interrupting GPIOs on PowerPC. So I've spent the last two days writing it.
The problem with interrupting GPIOs is that there is one interrupt per GPIO group and a GPIO group may have between 8 and 32 GPIOs. When the one shared interrupt activates you need to provide a chained interrupt handler for it. This chained handler figures out which of the 8-32 GPIOs caused the interrupt and then chains again into the specific interrupt handler for that GPIO pin. Support for all of these chained handlers is running about 800 lines of C code.
If you look at how IR protocols work you need to be able to measure the times between the leading and trailing edges of the pulses. I have GPIO_WKUP_7 configured to interrupt on both the rising and falling edge of the output from the IR receiver. So the next thing I need to do is have a timer running to time the pulses.
Now I'm reading about the timers available in the mpc5200. In the middle of chapter 7.4 there is a note: Be aware, the intermediate values of the counters are not software readable. I needed to read the values of a free running timer on each interrupt.
This means I can't hook IR up to GPIO_WKUP_7. Instead I have to move it over to TIMER_7. The timer 7 pin is capable of snapshotting the counter value on either edge on the input signal and generating an interrupt on each edge.
So I never needed all of that interrupt demultiplexing code for GPIO_WKUP_7, the timers have their own non-multiplexed interrupts. Maybe someone on LKML will take it from me and run with it.
Now I have to warm up my soldering iron and move the IR input over to pin 15A in the Phytex patchfield. Then I have to write a whole new device driver for the timer. Hopefully the timer pin will have the features needed to decode IR signals.
BTW, it is many times easier to decode IR signal using a serial port. You set the serial port to a high baud rate and use it as a 1 bit digitizer to record the IR signal. The is the most common method used by LIRC. Too bad all of our serial ports are tied up with other things.
- jonsmirl's blog
- Login or register to post comments