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
This commit is contained in:
parent
f65ee52752
commit
90dd12bc15
@ -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);
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user