Enabling Infrared Receiver on iMX8MM EVK

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Enabling Infrared Receiver on iMX8MM EVK

Enabling Infrared Receiver on iMX8MM EVK

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 :

  1. iMX8MM EVK - i.MX 8M Mini Evaluation Kit | NXP Semiconductors
  2. Arduino Uno board
  3. IR TX module

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                           -                     D3

IR transmitter LED connected to Arduino UnoIR transmitter LED connected to Arduino Uno
















-- Kernel configurations needed:
Linux Kernel ConfigurationsLinux 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 driversLIRC 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 nodelirc 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 changesDevice 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 GPIOIR 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 DecoderLIRC 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 DecoderRC5 DecoderRC6 DecoderRC6 DecoderNEC DecoderNEC 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!

 

附件
无评分
版本历史
最后更新:
‎10-29-2025 10:34 PM
更新人: