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?
Hello wlamers,
yes, it is a little bit confusing. You not alone with this. It is, because you have so many options. Another thing is, that
GPIO is sometimes FUNC0 or another FUNCx. Thats stupid, because i have to look into the datasheet for every pin.
Why the don't use FUNC0 for GPIO only?