lpcware

NXP driver library GPIO port and pin naming conventions

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by wlamers on Mon Apr 08 06:49:09 MST 2013

While wrinting the firmware for a LPC4357, without having the board yet, I face a naming convention issue.


The NXP driver library (latest from GIT), uses the function scu_pinmux (in LPC43xx_scu.c) to the the pin's function and mode. Let's, for example, say I want to set pin PD.9 to a GPIO output (LED):


#define LED1_PORT           0xd
#define LED1_BIT            9


scu_pinmux(LED1_PORT, ((uint32_t)1<<LED1_BIT), GPIO_PDN, FUNC4);


This should works. I have checked the according registers in the UM.


But when I want to use some of the GPIO functions (in lpc43xx_gpio.c) I have to switch to the GPIOn[m] naming conventions instead of the normal pin names (is seems at least). PD.9 = GPIO6[23]


GPIO_SetDir(LED1_PORT, ((uint32_t)1<<LED1_BIT), PIN_OUTPUT);  -> WRONG because it should be: GPIO_SetDir(6, ((uint32_t)1<<23), PIN_OUTPUT); now


Same for:


GPIO_SetValue(LED1_PORT, BITVAL(LED1_BIT));


etc.


While not being a really large problem.... This is quite confusing in my opninion. The root cause is the register layout in the uC itself. The SCU is using the pinnames while the GPIO 'controller' uses the GPIO names...


Can someone confirm the above?

Outcomes