diff options
author | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2012-07-10 18:33:14 +0000 |
---|---|---|
committer | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2012-07-10 18:33:14 +0000 |
commit | f3c14a746146edbbe9966c2068193722f937cc33 (patch) | |
tree | 4085943a5e641b60d2e626a68d70b4072112be4f /nuttx/arch | |
parent | ee57207deb7dcf86f9747ad70ddf8cdd64c2bd53 (diff) | |
download | px4-firmware-f3c14a746146edbbe9966c2068193722f937cc33.tar.gz px4-firmware-f3c14a746146edbbe9966c2068193722f937cc33.tar.bz2 px4-firmware-f3c14a746146edbbe9966c2068193722f937cc33.zip |
Several fixes to LPC43 pin and GPIO configuration
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4925 7fd9a85b-ad96-42d3-883c-3090e2eb8679
Diffstat (limited to 'nuttx/arch')
-rw-r--r-- | nuttx/arch/arm/src/lpc43xx/lpc43_gpio.c | 8 | ||||
-rw-r--r-- | nuttx/arch/arm/src/lpc43xx/lpc43_gpio.h | 6 | ||||
-rw-r--r-- | nuttx/arch/arm/src/lpc43xx/lpc43_pinconfig.c | 12 |
3 files changed, 15 insertions, 11 deletions
diff --git a/nuttx/arch/arm/src/lpc43xx/lpc43_gpio.c b/nuttx/arch/arm/src/lpc43xx/lpc43_gpio.c index edb5bf3e0..2b2c88f31 100644 --- a/nuttx/arch/arm/src/lpc43xx/lpc43_gpio.c +++ b/nuttx/arch/arm/src/lpc43xx/lpc43_gpio.c @@ -158,7 +158,7 @@ static inline void lpc43_configoutput(uint16_t gpiocfg, int lpc43_gpio_config(uint16_t gpiocfg) { unsigned int port = ((gpiocfg & GPIO_PORT_MASK) >> GPIO_PORT_SHIFT); - unsigned int pin = ((gpiocfg & GPIO_PORT_MASK) >> GPIO_PORT_SHIFT); + unsigned int pin = ((gpiocfg & GPIO_PIN_MASK) >> GPIO_PIN_SHIFT); irqstate_t flags; int ret = OK; @@ -167,7 +167,7 @@ int lpc43_gpio_config(uint16_t gpiocfg) /* Handle the GPIO configuration by the basic mode of the pin */ flags = irqsave(); - switch (gpiocfg & GPIO_PORT_MASK) + switch (gpiocfg & GPIO_MODE_MASK) { case GPIO_MODE_INPUT: /* GPIO input pin */ lpc43_configinput(gpiocfg, port, pin); @@ -215,7 +215,7 @@ int lpc43_gpio_config(uint16_t gpiocfg) void lpc43_gpio_write(uint16_t gpiocfg, bool value) { unsigned int port = ((gpiocfg & GPIO_PORT_MASK) >> GPIO_PORT_SHIFT); - unsigned int pin = ((gpiocfg & GPIO_PORT_MASK) >> GPIO_PORT_SHIFT); + unsigned int pin = ((gpiocfg & GPIO_PIN_MASK) >> GPIO_PIN_SHIFT); DEBUGASSERT(port < NUM_GPIO_PORTS && pin < NUM_GPIO_PINS); @@ -238,7 +238,7 @@ void lpc43_gpio_write(uint16_t gpiocfg, bool value) bool lpc43_gpio_read(uint16_t gpiocfg) { unsigned int port = ((gpiocfg & GPIO_PORT_MASK) >> GPIO_PORT_SHIFT); - unsigned int pin = ((gpiocfg & GPIO_PORT_MASK) >> GPIO_PORT_SHIFT); + unsigned int pin = ((gpiocfg & GPIO_PIN_MASK) >> GPIO_PIN_SHIFT); DEBUGASSERT(port < NUM_GPIO_PORTS && pin < NUM_GPIO_PINS); diff --git a/nuttx/arch/arm/src/lpc43xx/lpc43_gpio.h b/nuttx/arch/arm/src/lpc43xx/lpc43_gpio.h index f494be6b5..8f8460966 100644 --- a/nuttx/arch/arm/src/lpc43xx/lpc43_gpio.h +++ b/nuttx/arch/arm/src/lpc43xx/lpc43_gpio.h @@ -68,7 +68,7 @@ * ---- ---- ---- ---- * Normal GPIO: MMV. .... PPPB BBBB * Normal Interrupt: MMCC CIII PPPB BBBB - * Group Interrupt: MM.N P.. PPPB BBBB + * Group Interrupt: MM.N P... PPPB BBBB */ /* GPIO mode: @@ -184,10 +184,10 @@ * 1111 1100 0000 0000 * 5432 1098 7654 3210 * ---- ---- ---- ---- - * .... GPII .... .... + * .... .... PPP. .... */ -#define GPIO_PORT_SHIFT (4) /* Bits 4-6: Port number */ +#define GPIO_PORT_SHIFT (5) /* Bits 5-7: Port number */ #define GPIO_PORT_MASK (7 << GPIO_PORT_SHIFT) # define GPIO_PORT0 (0 << GPIO_PORT_SHIFT) # define GPIO_PORT1 (1 << GPIO_PORT_SHIFT) diff --git a/nuttx/arch/arm/src/lpc43xx/lpc43_pinconfig.c b/nuttx/arch/arm/src/lpc43xx/lpc43_pinconfig.c index 2f748a9b1..fb5173339 100644 --- a/nuttx/arch/arm/src/lpc43xx/lpc43_pinconfig.c +++ b/nuttx/arch/arm/src/lpc43xx/lpc43_pinconfig.c @@ -43,6 +43,7 @@ #include <nuttx/arch.h> #include <errno.h> +#include "up_arch.h" #include "lpc43_pinconfig.h" /**************************************************************************** @@ -83,10 +84,6 @@ int lpc43_pin_config(uint32_t pinconf) uintptr_t regaddr; uint32_t regval; - /* Get the address of the pin configuration register */ - - regaddr = LPC43_SCU_SFSP(pinset, pin); - /* Set up common pin configurations */ regval = (func << SCU_PIN_MODE_SHIFT); @@ -146,5 +143,12 @@ int lpc43_pin_config(uint32_t pinconf) break; } + /* Get the address of the pin configuration register and save the new + * pin configuration. + */ + + regaddr = LPC43_SCU_SFSP(pinset, pin); + putreg32(regval, regaddr); + return OK; } |