summaryrefslogtreecommitdiff
path: root/nuttx/arch/arm/src/lpc17xx/lpc17_gpio.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-04-01 13:10:14 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-04-01 13:10:14 +0000
commit8e9c9c4fd33836b5504ede9cacdb111d6877ef1b (patch)
tree04e811356c79b945a2b5704f3f011eb18433928e /nuttx/arch/arm/src/lpc17xx/lpc17_gpio.c
parent53115c611716b692fbb3622e150c96c0431d147c (diff)
downloadpx4-nuttx-8e9c9c4fd33836b5504ede9cacdb111d6877ef1b.tar.gz
px4-nuttx-8e9c9c4fd33836b5504ede9cacdb111d6877ef1b.tar.bz2
px4-nuttx-8e9c9c4fd33836b5504ede9cacdb111d6877ef1b.zip
LPC1788 LCD fixes from Rommel Marcelo
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5806 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch/arm/src/lpc17xx/lpc17_gpio.c')
-rw-r--r--nuttx/arch/arm/src/lpc17xx/lpc17_gpio.c52
1 files changed, 42 insertions, 10 deletions
diff --git a/nuttx/arch/arm/src/lpc17xx/lpc17_gpio.c b/nuttx/arch/arm/src/lpc17xx/lpc17_gpio.c
index 97a5c19d6..05c3caa20 100644
--- a/nuttx/arch/arm/src/lpc17xx/lpc17_gpio.c
+++ b/nuttx/arch/arm/src/lpc17xx/lpc17_gpio.c
@@ -540,18 +540,31 @@ static inline int lpc17_configinput(lpc17_pinset_t cfgset, unsigned int port, un
lpc17_clropendrain(port, pin);
#elif defined(LPC178x)
-
- /* Configure as GPIO */
+ /* Configure the pin as a GPIO. Clear opendrain, input inversion,
+ * hysteris, slew. Set analog pins as digital.
+ */
regval = IOCON_FUNC_GPIO;
- /* Set pull-up mode */
+ /* Set pull-up mode. Isolate the field from the cfgset and move it
+ * into the correct position in the register value.
+ */
- regval |= ((cfgset & GPIO_PUMODE_MASK) >> GPIO_PINMODE_SHIFT);
+ regval |= (((cfgset & GPIO_PUMODE_MASK) >> GPIO_PINMODE_SHIFT) << IOCON_MODE_SHIFT);
- /* Clear opendrain, input hysteresis, invertion, slew */
+ /* Select input polarity */
- regval &= ~(IOCON_HYS_MASK | IOCON_INV_MASK | IOCON_SLEW_MASK | IOCON_OD_MASK);
+ if ((cfgset & GPIO_INVERT) != 0)
+ {
+ regval |= IOCON_INV_MASK;
+ }
+
+ /* Select hysteresis enable */
+
+ if ((cfgset & GPIO_HYSTERESIS) != 0)
+ {
+ regval |= IOCON_HYS_MASK;
+ }
/* Set IOCON register */
@@ -631,7 +644,11 @@ static inline int lpc17_configoutput(lpc17_pinset_t cfgset, unsigned int port,
}
#elif defined(LPC178x)
- regval = 0;
+ /* Configure the pin as a GPIO. Clear opendrain, input inversion,
+ * hysteris, slew. Set analog pins as digital.
+ */
+
+ regval = IOCON_FUNC_GPIO;
/* Select open drain output */
@@ -647,9 +664,11 @@ static inline int lpc17_configoutput(lpc17_pinset_t cfgset, unsigned int port,
regval |= IOCON_SLEW_MASK;
}
- /* Set pull-up mode */
+ /* Set pull-up mode. Isolate the field from the cfgset and move it
+ * into the correct position in the register value.
+ */
- regval |= ((cfgset & GPIO_PUMODE_MASK) >> GPIO_PINMODE_SHIFT);
+ regval |= (((cfgset & GPIO_PUMODE_MASK) >> GPIO_PINMODE_SHIFT) << IOCON_MODE_SHIFT);
/* Set IOCON register */
@@ -702,10 +721,23 @@ static int lpc17_configalternate(lpc17_pinset_t cfgset, unsigned int port,
#elif defined(LPC178x)
uint32_t regval = 0;
- /* Set the alternate pin */
+ /* Select the alternate pin */
regval |= (alt & IOCON_FUNC_MASK);
+ /* Select analog mode */
+
+ if ((cfgset & GPIO_ADMODE) != 0)
+ {
+ regval |= IOCON_ADMODE_MASK;
+ }
+
+ /* Set pull-up mode. Isolate the field from the cfgset and move it
+ * into the correct position in the register value.
+ */
+
+ regval |= (((cfgset & GPIO_PUMODE_MASK) >> GPIO_PINMODE_SHIFT) << IOCON_MODE_SHIFT);
+
/* Select open drain output */
if ((cfgset & GPIO_OPEN_DRAIN) != 0)