cfpgaxilinxbare-metalinfrared

NEC Infrared Transmission Protocol in C lanc on Xilinx


I need to capture and decode an infrared signal (with NEC infrared protocol) using a GPIO pin on a Xilinx FPGA and show the content of the signal on the console. I receive the signal on the address

XPAR_GPIO_IR_BASEADDR // 0x40040000

How can I take the contents of that register and put it into another varable that will then be used to decode the signal? u32 packet

The goal of this part is to take the value received from the IR and then insert it into the packet variable as shown above. The variable will then be used for other operations.


Solution

  • That macro definition is the absolute address of the peripheral. So if you don't have a driver already generated for the system and no functions are available - then for C language you'd just cast that address to a volatile pointer to the type matching the register size, and then dereference it.

    Basically you do u32 value = *(volatile u32 *)XPAR_GPIO_IR_BASEADDR;

    The BSP generated by Vitis includes the convenience functions Xil_In32() and Xil_Out32(), as well as functions for other data sizes, basically doing the same.

    Note that if you do not have the driver, then you also should be aware of the peripherals registers offsets relative to the whole peripheral base address. In general case the base address is not necessarily the address to be touched. For the Xilinx LogiCORE IP AXI GPIO the channel 1 data register coincide with the base address, while channel 2 data register is at the offset of 0x08.