Hey everyone!
With the iMX8MM EVK, you also get an IR receiver LED interfaced with one of the GPIOs. Through this article today, I will demonstrate how to enable Infrared Receiver on the iMX8MM EVK so that data sent from the IR transmitter LEDs can be received and decoded on the iMX8MM EVK.
Hardware used :
Arduino interfaced with IR TX will send IR messages to iMX8MM interfaced with IR RX LED
Hardware connections:
IR TX Module <----> Arduino Uno
GND - GND
3.3V - 3.3V
DAT - D3IR transmitter LED connected to Arduino Uno
-- Kernel configurations needed:Linux Kernel Configurations
Copy the kernel 'Image' built with the above changes and the IR decoder modules for the protocol you want to decode. All the ko modules are present i.e ir-rc5-decoder.ko for rc5 IR decoding in this folder after building:LIRC drivers
Boot linux with the default dtb[imx8mm-evk.dtb] and the newly copied kernel 'Image' that you uploaded on the board.
At boot-up rc_register_device is called from drivers/media/rc/rc-main.c.
A /dev/lirc0 node will also be created as a result of in-built driver loading.
You can verify this by executing:lirc device node
On iM8MM, The IR receiver is connected to GPIO1_13. drivers/media/rc/gpio-ir-recv.c is responsible to configure this GPIO using the dts entry present in arch/arm64/boot/dts/freescale/imx8mm-evk.dtsi
Device tree changes
gpio_ir_recv_probe will be called from drivers/media/rc/gpio-ir-recv.c.
At linux prompt, you can verify the gpio configuration using sysfs:
IR GPIO
Now insert the NEC and RC5 decoder modules. This gives the kernel ability to be able to decode the NEC and RC5 IR protocols.
LIRC Decoder
Next, we need a program that utilizes the decoder driver to start decoding the IR signals coming onto the IR Receiver of iMX8MM EVK.
Some example invocations of the user-space binary we have built for the above purpose:
RC5 Decoder
RC6 Decoder
NEC Decoder
ir_recv accepts 2 arguments:-
1st argument - protocol to enable
2nd argument - the remote-control device created in the /sys/class/rc
example - /sys/class/rc/rc0
Note - Not to be confused with the protocols rc5 or rc6. The 2nd argument is not the name of the protocol
ir_recv utility that we have built will open the /dev/lirc0 device and make an ioctl call LIRC_SET_REC_MODE to set the LIRC driver in Recording mode.
These ioctls are handled in drivers/media/rc/lirc_dev.c in the kernel source code.
So that whenever you run the ir_recv binary, it polls for the IR protocol scan code and prints it if successfully decoded.
Attaching the ir_recv executable and the source code with this article for you to test and tweak. Please let me know if you have any follow-up questions. I would be happy to indulge. That's all I have for today. Thank you for your time!