GPIO numbering on uclinux

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

GPIO numbering on uclinux

342 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bomellberg on Fri Apr 10 00:16:30 MST 2015
In uClinux, you can address GPIO in user space by enabling gpio like this:

echo 12 > /sys/class/gpio/export

which gives you a virtual directory named "gpio12" where you can set direction and high/low etc.

My question is: How do I find out the number to use in uClinux?

My LQFP144 version of LPC4337 has 6 GPIO Ports:

GPIO0[15:0]
GPIO1[15:0]
GPIO2[15:0]
GPIO3[15:0]
GPIO4[11]
GPIO5[16:0]
GPIO5[18]

I need to set pin P7_4 which is GPIO3[12]. What is the number to use in uClinux? (the number 12 in my example above).

Thanks!

/Bo
Labels (1)
0 Kudos
1 Reply

317 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bomellberg on Fri Apr 10 02:55:10 MST 2015
Found the answer in arch\arm\mach-lpc18xx\include\mach\gpio.h:

/*
 * Convert a {port, pin} pair to an single integer
 */
#define LPC18XX_GPIO_MKPIN(port,pin) \
((LPC18XX_GPIO_PORT_PINS) * (port) + (pin))


So to work with GPIO3[12] the number is 3*32+12 = 108, which works nicely.
0 Kudos