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
This commit is contained in:
parent
96d83b7d3f
commit
98cdc4e0fe
|
@ -158,7 +158,7 @@ static inline void lpc43_configoutput(uint16_t gpiocfg,
|
||||||
int lpc43_gpio_config(uint16_t gpiocfg)
|
int lpc43_gpio_config(uint16_t gpiocfg)
|
||||||
{
|
{
|
||||||
unsigned int port = ((gpiocfg & GPIO_PORT_MASK) >> GPIO_PORT_SHIFT);
|
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;
|
irqstate_t flags;
|
||||||
int ret = OK;
|
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 */
|
/* Handle the GPIO configuration by the basic mode of the pin */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = irqsave();
|
||||||
switch (gpiocfg & GPIO_PORT_MASK)
|
switch (gpiocfg & GPIO_MODE_MASK)
|
||||||
{
|
{
|
||||||
case GPIO_MODE_INPUT: /* GPIO input pin */
|
case GPIO_MODE_INPUT: /* GPIO input pin */
|
||||||
lpc43_configinput(gpiocfg, port, 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)
|
void lpc43_gpio_write(uint16_t gpiocfg, bool value)
|
||||||
{
|
{
|
||||||
unsigned int port = ((gpiocfg & GPIO_PORT_MASK) >> GPIO_PORT_SHIFT);
|
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);
|
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)
|
bool lpc43_gpio_read(uint16_t gpiocfg)
|
||||||
{
|
{
|
||||||
unsigned int port = ((gpiocfg & GPIO_PORT_MASK) >> GPIO_PORT_SHIFT);
|
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);
|
DEBUGASSERT(port < NUM_GPIO_PORTS && pin < NUM_GPIO_PINS);
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@
|
||||||
* ---- ---- ---- ----
|
* ---- ---- ---- ----
|
||||||
* Normal GPIO: MMV. .... PPPB BBBB
|
* Normal GPIO: MMV. .... PPPB BBBB
|
||||||
* Normal Interrupt: MMCC CIII PPPB BBBB
|
* Normal Interrupt: MMCC CIII PPPB BBBB
|
||||||
* Group Interrupt: MM.N P.. PPPB BBBB
|
* Group Interrupt: MM.N P... PPPB BBBB
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* GPIO mode:
|
/* GPIO mode:
|
||||||
|
@ -184,10 +184,10 @@
|
||||||
* 1111 1100 0000 0000
|
* 1111 1100 0000 0000
|
||||||
* 5432 1098 7654 3210
|
* 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_PORT_MASK (7 << GPIO_PORT_SHIFT)
|
||||||
# define GPIO_PORT0 (0 << GPIO_PORT_SHIFT)
|
# define GPIO_PORT0 (0 << GPIO_PORT_SHIFT)
|
||||||
# define GPIO_PORT1 (1 << GPIO_PORT_SHIFT)
|
# define GPIO_PORT1 (1 << GPIO_PORT_SHIFT)
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include "up_arch.h"
|
||||||
#include "lpc43_pinconfig.h"
|
#include "lpc43_pinconfig.h"
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -83,10 +84,6 @@ int lpc43_pin_config(uint32_t pinconf)
|
||||||
uintptr_t regaddr;
|
uintptr_t regaddr;
|
||||||
uint32_t regval;
|
uint32_t regval;
|
||||||
|
|
||||||
/* Get the address of the pin configuration register */
|
|
||||||
|
|
||||||
regaddr = LPC43_SCU_SFSP(pinset, pin);
|
|
||||||
|
|
||||||
/* Set up common pin configurations */
|
/* Set up common pin configurations */
|
||||||
|
|
||||||
regval = (func << SCU_PIN_MODE_SHIFT);
|
regval = (func << SCU_PIN_MODE_SHIFT);
|
||||||
|
@ -146,5 +143,12 @@ int lpc43_pin_config(uint32_t pinconf)
|
||||||
break;
|
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;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue