summaryrefslogtreecommitdiff
path: root/nuttx/arch/arm/src
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-07-10 18:33:14 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-07-10 18:33:14 +0000
commit138db51f4c7c2ad07f7b9e7e8fc032997f0457f9 (patch)
tree4085943a5e641b60d2e626a68d70b4072112be4f /nuttx/arch/arm/src
parent0c0a801ee2dcda5e38bb6b86d4c7504673ea9574 (diff)
downloadpx4-nuttx-138db51f4c7c2ad07f7b9e7e8fc032997f0457f9.tar.gz
px4-nuttx-138db51f4c7c2ad07f7b9e7e8fc032997f0457f9.tar.bz2
px4-nuttx-138db51f4c7c2ad07f7b9e7e8fc032997f0457f9.zip
Several fixes to LPC43 pin and GPIO configuration
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4925 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch/arm/src')
-rw-r--r--nuttx/arch/arm/src/lpc43xx/lpc43_gpio.c8
-rw-r--r--nuttx/arch/arm/src/lpc43xx/lpc43_gpio.h6
-rw-r--r--nuttx/arch/arm/src/lpc43xx/lpc43_pinconfig.c12
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;
}