how to use different GPIOs for gpio_test_c example

The gpio_test example is using BUTTON2 and LED2 on (Wi-)i.MX53.
In order to use different pins, you need to modify the example application gpio_test.c:
} plat_list[PLAT_NONE + 1] = {
..
MK(CCMX53JS, "ccmx53js", "BUTTON2", "LED2", MX5X_GPIO(4,1), MX5X_GPIO(7,12), 1, GPIO_UNDEFINED, ""),
MK(CCWMX53JS, "ccwmx53js", "BUTTON1", "LED1", MX5X_GPIO(4,0), MX5X_GPIO(5,20), 1, GPIO_UNDEFINED, ""),
..
};


The GPIOx_y numbers can be found in the hardware reference manual 90001270. Download latest version of HRM on: Wi-i.MX53 Software and Documentation page or browse for 90001270 on FTP with latest revision character.

You also need to make sure appropriate device nodes are created during runtime for the GPIOs used:
#define MX5X_GPIO(port,pin) ((port -1) * 32 +pin)
MX5X_GPIO(4, 0)
matches /dev/gpio/96
MX5X_GPIO(5, 20) matches /dev/gpio/148

Just add the missing device nodes to /etc/makedevs.d/ccwmx53js:
# Device nodes for ccwmx51js
# button1 and led1
/dev/gpio d 755 0 0
/dev/gpio/96 c 644 0 0 240 96
/dev/gpio/148 c 644 0 0 240 148


see also ESP documentation section 9.14.5 Managing GPIO from user space.
Last updated: Jan 01, 2024

Filed Under

Embedded

Recently Viewed

No recently viewed articles

Did you find this article helpful?