LPCOpen Platform for LPC18XX/43XX microcontrollers  18XX43XX
LPCOpen Platform for the NXP LPC18XX/43XX family of Microcontrollers
Data Structures | Functions
CHIP: LPC18xx/43xx GPIO driver

Detailed Description

Data Structures

struct  LPC_GPIO_T
 GPIO port register block structure. More...
 

Functions

void Chip_GPIO_Init (LPC_GPIO_T *pGPIO)
 Initialize GPIO block. More...
 
void Chip_GPIO_DeInit (LPC_GPIO_T *pGPIO)
 De-Initialize GPIO block. More...
 
STATIC INLINE void Chip_GPIO_WritePortBit (LPC_GPIO_T *pGPIO, uint32_t port, uint8_t pin, bool setting)
 Set a GPIO port/bit state. More...
 
STATIC INLINE void Chip_GPIO_SetPinState (LPC_GPIO_T *pGPIO, uint8_t port, uint8_t pin, bool setting)
 Set a GPIO pin state via the GPIO byte register. More...
 
STATIC INLINE bool Chip_GPIO_ReadPortBit (LPC_GPIO_T *pGPIO, uint32_t port, uint8_t pin)
 Read a GPIO state. More...
 
STATIC INLINE bool Chip_GPIO_GetPinState (LPC_GPIO_T *pGPIO, uint8_t port, uint8_t pin)
 Get a GPIO pin state via the GPIO byte register. More...
 
void Chip_GPIO_WriteDirBit (LPC_GPIO_T *pGPIO, uint32_t port, uint8_t bit, bool setting)
 Set a GPIO direction. More...
 
STATIC INLINE void Chip_GPIO_SetPinDIROutput (LPC_GPIO_T *pGPIO, uint8_t port, uint8_t pin)
 Set GPIO direction for a single GPIO pin to an output. More...
 
STATIC INLINE void Chip_GPIO_SetPinDIRInput (LPC_GPIO_T *pGPIO, uint8_t port, uint8_t pin)
 Set GPIO direction for a single GPIO pin to an input. More...
 
void Chip_GPIO_SetPinDIR (LPC_GPIO_T *pGPIO, uint8_t port, uint8_t pin, bool output)
 Set GPIO direction for a single GPIO pin. More...
 
STATIC INLINE bool Chip_GPIO_ReadDirBit (LPC_GPIO_T *pGPIO, uint32_t port, uint8_t bit)
 Read a GPIO direction (out or in) More...
 
STATIC INLINE bool Chip_GPIO_GetPinDIR (LPC_GPIO_T *pGPIO, uint8_t port, uint8_t pin)
 Get GPIO direction for a single GPIO pin. More...
 
void Chip_GPIO_SetDir (LPC_GPIO_T *pGPIO, uint8_t portNum, uint32_t bitValue, uint8_t out)
 Set Direction for a GPIO port. More...
 
STATIC INLINE void Chip_GPIO_SetPortDIROutput (LPC_GPIO_T *pGPIO, uint8_t port, uint32_t pinMask)
 Set GPIO direction for a all selected GPIO pins to an output. More...
 
STATIC INLINE void Chip_GPIO_SetPortDIRInput (LPC_GPIO_T *pGPIO, uint8_t port, uint32_t pinMask)
 Set GPIO direction for a all selected GPIO pins to an input. More...
 
void Chip_GPIO_SetPortDIR (LPC_GPIO_T *pGPIO, uint8_t port, uint8_t pinMask, bool outSet)
 Set GPIO direction for a all selected GPIO pins to an input or output. More...
 
STATIC INLINE uint32_t Chip_GPIO_GetPortDIR (LPC_GPIO_T *pGPIO, uint8_t port)
 Get GPIO direction for a all GPIO pins. More...
 
STATIC INLINE void Chip_GPIO_SetPortMask (LPC_GPIO_T *pGPIO, uint8_t port, uint32_t mask)
 Set GPIO port mask value for GPIO masked read and write. More...
 
STATIC INLINE uint32_t Chip_GPIO_GetPortMask (LPC_GPIO_T *pGPIO, uint8_t port)
 Get GPIO port mask value used for GPIO masked read and write. More...
 
STATIC INLINE void Chip_GPIO_SetPortValue (LPC_GPIO_T *pGPIO, uint8_t port, uint32_t value)
 Set all GPIO raw pin states (regardless of masking) More...
 
STATIC INLINE uint32_t Chip_GPIO_GetPortValue (LPC_GPIO_T *pGPIO, uint8_t port)
 Get all GPIO raw pin states (regardless of masking) More...
 
STATIC INLINE void Chip_GPIO_SetMaskedPortValue (LPC_GPIO_T *pGPIO, uint8_t port, uint32_t value)
 Set all GPIO pin states, but mask via the MASKP0 register. More...
 
STATIC INLINE uint32_t Chip_GPIO_GetMaskedPortValue (LPC_GPIO_T *pGPIO, uint8_t port)
 Get all GPIO pin statesm but mask via the MASKP0 register. More...
 
STATIC INLINE void Chip_GPIO_SetValue (LPC_GPIO_T *pGPIO, uint8_t portNum, uint32_t bitValue)
 Set a GPIO port/bit to the high state. More...
 
STATIC INLINE void Chip_GPIO_SetPortOutHigh (LPC_GPIO_T *pGPIO, uint8_t port, uint32_t pins)
 Set selected GPIO output pins to the high state. More...
 
STATIC INLINE void Chip_GPIO_SetPinOutHigh (LPC_GPIO_T *pGPIO, uint8_t port, uint8_t pin)
 Set an individual GPIO output pin to the high state. More...
 
STATIC INLINE void Chip_GPIO_ClearValue (LPC_GPIO_T *pGPIO, uint8_t portNum, uint32_t bitValue)
 Set a GPIO port/bit to the low state. More...
 
STATIC INLINE void Chip_GPIO_SetPortOutLow (LPC_GPIO_T *pGPIO, uint8_t port, uint32_t pins)
 Set selected GPIO output pins to the low state. More...
 
STATIC INLINE void Chip_GPIO_SetPinOutLow (LPC_GPIO_T *pGPIO, uint8_t port, uint8_t pin)
 Set an individual GPIO output pin to the low state. More...
 
STATIC INLINE void Chip_GPIO_SetPortToggle (LPC_GPIO_T *pGPIO, uint8_t port, uint32_t pins)
 Toggle selected GPIO output pins to the opposite state. More...
 
STATIC INLINE void Chip_GPIO_SetPinToggle (LPC_GPIO_T *pGPIO, uint8_t port, uint8_t pin)
 Toggle an individual GPIO output pin to the opposite state. More...
 
STATIC INLINE uint32_t Chip_GPIO_ReadValue (LPC_GPIO_T *pGPIO, uint8_t portNum)
 Read current bit states for the selected port. More...
 

Function Documentation

STATIC INLINE void Chip_GPIO_ClearValue ( LPC_GPIO_T pGPIO,
uint8_t  portNum,
uint32_t  bitValue 
)

Set a GPIO port/bit to the low state.

Parameters
pGPIO: The base of GPIO peripheral on the chip
portNum: port number
bitValue: bit(s) in the port to set low
Returns
None
Note
Any bit set as a '0' will not have it's state changed. This only applies to ports configured as an output.

Definition at line 389 of file gpio_18xx_43xx.h.

void Chip_GPIO_DeInit ( LPC_GPIO_T pGPIO)

De-Initialize GPIO block.

Parameters
pGPIO: The base of GPIO peripheral on the chip
Returns
Nothing

Definition at line 56 of file gpio_18xx_43xx.c.

STATIC INLINE uint32_t Chip_GPIO_GetMaskedPortValue ( LPC_GPIO_T pGPIO,
uint8_t  port 
)

Get all GPIO pin statesm but mask via the MASKP0 register.

Parameters
pGPIO: The base of GPIO peripheral on the chip
port: GPIO Port number where pin is located
Returns
Current (masked) state of all GPIO pins

Definition at line 332 of file gpio_18xx_43xx.h.

STATIC INLINE bool Chip_GPIO_GetPinDIR ( LPC_GPIO_T pGPIO,
uint8_t  port,
uint8_t  pin 
)

Get GPIO direction for a single GPIO pin.

Parameters
pGPIO: The base of GPIO peripheral on the chip
port: GPIO Port number where pin is located
pin: GPIO pin to get direction for
Returns
true if the GPIO is an output, false if input

Definition at line 193 of file gpio_18xx_43xx.h.

STATIC INLINE bool Chip_GPIO_GetPinState ( LPC_GPIO_T pGPIO,
uint8_t  port,
uint8_t  pin 
)

Get a GPIO pin state via the GPIO byte register.

Parameters
pGPIO: The base of GPIO peripheral on the chip
port: GPIO Port number where pin is located
pin: GPIO pin to get state for
Returns
true if the GPIO is high, false if low
Note
This function replaces Chip_GPIO_ReadPortBit()

Definition at line 121 of file gpio_18xx_43xx.h.

STATIC INLINE uint32_t Chip_GPIO_GetPortDIR ( LPC_GPIO_T pGPIO,
uint8_t  port 
)

Get GPIO direction for a all GPIO pins.

Parameters
pGPIO: The base of GPIO peripheral on the chip
port: GPIO Port number where pin is located
Returns
a bitfield containing the input and output states for each pin
Note
For pins 0..n, a high state in a bit corresponds to an output state for the same pin, while a low state corresponds to an input state.

Definition at line 258 of file gpio_18xx_43xx.h.

STATIC INLINE uint32_t Chip_GPIO_GetPortMask ( LPC_GPIO_T pGPIO,
uint8_t  port 
)

Get GPIO port mask value used for GPIO masked read and write.

Parameters
pGPIO: The base of GPIO peripheral on the chip
port: port Number
Returns
Returns value set with the Chip_GPIO_SetPortMask() function.
Note
A high bit in the return value indicates that that GPIO pin for the port cannot be set using the masked write function.

Definition at line 286 of file gpio_18xx_43xx.h.

STATIC INLINE uint32_t Chip_GPIO_GetPortValue ( LPC_GPIO_T pGPIO,
uint8_t  port 
)

Get all GPIO raw pin states (regardless of masking)

Parameters
pGPIO: The base of GPIO peripheral on the chip
port: GPIO Port number where pin is located
Returns
Current (raw) state of all GPIO pins

Definition at line 309 of file gpio_18xx_43xx.h.

void Chip_GPIO_Init ( LPC_GPIO_T pGPIO)

Initialize GPIO block.

Parameters
pGPIO: The base of GPIO peripheral on the chip
Returns
Nothing

Definition at line 51 of file gpio_18xx_43xx.c.

STATIC INLINE bool Chip_GPIO_ReadDirBit ( LPC_GPIO_T pGPIO,
uint32_t  port,
uint8_t  bit 
)

Read a GPIO direction (out or in)

Parameters
pGPIO: The base of GPIO peripheral on the chip
port: GPIO port to read
bit: GPIO bit to read
Returns
true of the GPIO is an output, false if input
Note
It is recommended to use the Chip_GPIO_GetPinDIR() function instead.

Definition at line 181 of file gpio_18xx_43xx.h.

STATIC INLINE bool Chip_GPIO_ReadPortBit ( LPC_GPIO_T pGPIO,
uint32_t  port,
uint8_t  pin 
)

Read a GPIO state.

Parameters
pGPIO: The base of GPIO peripheral on the chip
port: GPIO port to read
pin: GPIO pin to read
Returns
true of the GPIO is high, false if low
Note
It is recommended to use the Chip_GPIO_GetPinState() function instead.

Definition at line 108 of file gpio_18xx_43xx.h.

STATIC INLINE uint32_t Chip_GPIO_ReadValue ( LPC_GPIO_T pGPIO,
uint8_t  portNum 
)

Read current bit states for the selected port.

Parameters
pGPIO: The base of GPIO peripheral on the chip
portNum: port number to read
Returns
Current value of GPIO port
Note
The current states of the bits for the port are read, regardless of whether the GPIO port bits are input or output.

Definition at line 458 of file gpio_18xx_43xx.h.

void Chip_GPIO_SetDir ( LPC_GPIO_T pGPIO,
uint8_t  portNum,
uint32_t  bitValue,
uint8_t  out 
)

Set Direction for a GPIO port.

Parameters
pGPIO: The base of GPIO peripheral on the chip
portNum: port Number
bitValue: GPIO bit to set
out: Direction value, 0 = input, !0 = output
Returns
None
Note
Bits set to '0' are not altered. It is recommended to use the Chip_GPIO_SetPortDIR() function instead.

Definition at line 72 of file gpio_18xx_43xx.c.

STATIC INLINE void Chip_GPIO_SetMaskedPortValue ( LPC_GPIO_T pGPIO,
uint8_t  port,
uint32_t  value 
)

Set all GPIO pin states, but mask via the MASKP0 register.

Parameters
pGPIO: The base of GPIO peripheral on the chip
port: GPIO Port number where pin is located
value: Value to set all GPIO pin states (0..n) to
Returns
Nothing

Definition at line 321 of file gpio_18xx_43xx.h.

void Chip_GPIO_SetPinDIR ( LPC_GPIO_T pGPIO,
uint8_t  port,
uint8_t  pin,
bool  output 
)

Set GPIO direction for a single GPIO pin.

Parameters
pGPIO: The base of GPIO peripheral on the chip
port: GPIO Port number where pin is located
pin: GPIO pin to set direction for
output: true for output, false for input
Returns
Nothing

Definition at line 83 of file gpio_18xx_43xx.c.

STATIC INLINE void Chip_GPIO_SetPinDIRInput ( LPC_GPIO_T pGPIO,
uint8_t  port,
uint8_t  pin 
)

Set GPIO direction for a single GPIO pin to an input.

Parameters
pGPIO: The base of GPIO peripheral on the chip
port: GPIO Port number where pin is located
pin: GPIO pin to set direction on as input
Returns
Nothing

Definition at line 158 of file gpio_18xx_43xx.h.

STATIC INLINE void Chip_GPIO_SetPinDIROutput ( LPC_GPIO_T pGPIO,
uint8_t  port,
uint8_t  pin 
)

Set GPIO direction for a single GPIO pin to an output.

Parameters
pGPIO: The base of GPIO peripheral on the chip
port: GPIO Port number where pin is located
pin: GPIO pin to set direction on as output
Returns
Nothing

Definition at line 146 of file gpio_18xx_43xx.h.

STATIC INLINE void Chip_GPIO_SetPinOutHigh ( LPC_GPIO_T pGPIO,
uint8_t  port,
uint8_t  pin 
)

Set an individual GPIO output pin to the high state.

Parameters
pGPIO: The base of GPIO peripheral on the chip'
port: GPIO Port number where pin is located
pin: pin number (0..n) to set high
Returns
None
Note
Any bit set as a '0' will not have it's state changed. This only applies to ports configured as an output.

Definition at line 375 of file gpio_18xx_43xx.h.

STATIC INLINE void Chip_GPIO_SetPinOutLow ( LPC_GPIO_T pGPIO,
uint8_t  port,
uint8_t  pin 
)

Set an individual GPIO output pin to the low state.

Parameters
pGPIO: The base of GPIO peripheral on the chip
port: GPIO Port number where pin is located
pin: pin number (0..n) to set low
Returns
None
Note
Any bit set as a '0' will not have it's state changed. This only applies to ports configured as an output.

Definition at line 417 of file gpio_18xx_43xx.h.

STATIC INLINE void Chip_GPIO_SetPinState ( LPC_GPIO_T pGPIO,
uint8_t  port,
uint8_t  pin,
bool  setting 
)

Set a GPIO pin state via the GPIO byte register.

Parameters
pGPIO: The base of GPIO peripheral on the chip
port: GPIO Port number where pin is located
pin: GPIO pin to set
setting: true for high, false for low
Returns
Nothing
Note
This function replaces Chip_GPIO_WritePortBit()

Definition at line 95 of file gpio_18xx_43xx.h.

STATIC INLINE void Chip_GPIO_SetPinToggle ( LPC_GPIO_T pGPIO,
uint8_t  port,
uint8_t  pin 
)

Toggle an individual GPIO output pin to the opposite state.

Parameters
pGPIO: The base of GPIO peripheral on the chip
port: GPIO Port number where pin is located
pin: pin number (0..n) to toggle
Returns
None
Note
Any bit set as a '0' will not have it's state changed. This only applies to ports configured as an output.

Definition at line 445 of file gpio_18xx_43xx.h.

void Chip_GPIO_SetPortDIR ( LPC_GPIO_T pGPIO,
uint8_t  port,
uint8_t  pinMask,
bool  outSet 
)

Set GPIO direction for a all selected GPIO pins to an input or output.

Parameters
pGPIO: The base of GPIO peripheral on the chip
port: GPIO Port number where pin is located
pinMask: GPIO pin mask to set direction on (bits 0..b for pins 0..n)
outSet: Direction value, false = set as inputs, true = set as outputs
Returns
Nothing
Note
Sets multiple GPIO pins to the input direction, each bit's position that is high sets the corresponding pin number for that bit to an input.

Definition at line 94 of file gpio_18xx_43xx.c.

STATIC INLINE void Chip_GPIO_SetPortDIRInput ( LPC_GPIO_T pGPIO,
uint8_t  port,
uint32_t  pinMask 
)

Set GPIO direction for a all selected GPIO pins to an input.

Parameters
pGPIO: The base of GPIO peripheral on the chip
port: GPIO Port number where pin is located
pinMask: GPIO pin mask to set direction on as input (bits 0..b for pins 0..n)
Returns
Nothing
Note
Sets multiple GPIO pins to the input direction, each bit's position that is high sets the corresponding pin number for that bit to an input.

Definition at line 233 of file gpio_18xx_43xx.h.

STATIC INLINE void Chip_GPIO_SetPortDIROutput ( LPC_GPIO_T pGPIO,
uint8_t  port,
uint32_t  pinMask 
)

Set GPIO direction for a all selected GPIO pins to an output.

Parameters
pGPIO: The base of GPIO peripheral on the chip
port: GPIO Port number where pin is located
pinMask: GPIO pin mask to set direction on as output (bits 0..b for pins 0..n)
Returns
Nothing
Note
Sets multiple GPIO pins to the output direction, each bit's position that is high sets the corresponding pin number for that bit to an output.

Definition at line 219 of file gpio_18xx_43xx.h.

STATIC INLINE void Chip_GPIO_SetPortMask ( LPC_GPIO_T pGPIO,
uint8_t  port,
uint32_t  mask 
)

Set GPIO port mask value for GPIO masked read and write.

Parameters
pGPIO: The base of GPIO peripheral on the chip
port: port Number
mask: Mask value for read and write (only low bits are enabled)
Returns
Nothing
Note
Controls which bits are set or unset when using the masked GPIO read and write functions. A low state indicates the pin is settable and readable via the masked write and read functions.

Definition at line 273 of file gpio_18xx_43xx.h.

STATIC INLINE void Chip_GPIO_SetPortOutHigh ( LPC_GPIO_T pGPIO,
uint8_t  port,
uint32_t  pins 
)

Set selected GPIO output pins to the high state.

Parameters
pGPIO: The base of GPIO peripheral on the chip
port: GPIO Port number where pin is located
pins: pins (0..n) to set high
Returns
None
Note
Any bit set as a '0' will not have it's state changed. This only applies to ports configured as an output.

Definition at line 361 of file gpio_18xx_43xx.h.

STATIC INLINE void Chip_GPIO_SetPortOutLow ( LPC_GPIO_T pGPIO,
uint8_t  port,
uint32_t  pins 
)

Set selected GPIO output pins to the low state.

Parameters
pGPIO: The base of GPIO peripheral on the chip
port: GPIO Port number where pin is located
pins: pins (0..n) to set low
Returns
None
Note
Any bit set as a '0' will not have it's state changed. This only applies to ports configured as an output.

Definition at line 403 of file gpio_18xx_43xx.h.

STATIC INLINE void Chip_GPIO_SetPortToggle ( LPC_GPIO_T pGPIO,
uint8_t  port,
uint32_t  pins 
)

Toggle selected GPIO output pins to the opposite state.

Parameters
pGPIO: The base of GPIO peripheral on the chip
port: GPIO Port number where pin is located
pins: pins (0..n) to toggle
Returns
None
Note
Any bit set as a '0' will not have it's state changed. This only applies to ports configured as an output.

Definition at line 431 of file gpio_18xx_43xx.h.

STATIC INLINE void Chip_GPIO_SetPortValue ( LPC_GPIO_T pGPIO,
uint8_t  port,
uint32_t  value 
)

Set all GPIO raw pin states (regardless of masking)

Parameters
pGPIO: The base of GPIO peripheral on the chip
port: GPIO Port number where pin is located
value: Value to set all GPIO pin states (0..n) to
Returns
Nothing

Definition at line 298 of file gpio_18xx_43xx.h.

STATIC INLINE void Chip_GPIO_SetValue ( LPC_GPIO_T pGPIO,
uint8_t  portNum,
uint32_t  bitValue 
)

Set a GPIO port/bit to the high state.

Parameters
pGPIO: The base of GPIO peripheral on the chip
portNum: port number
bitValue: bit(s) in the port to set high
Returns
None
Note
Any bit set as a '0' will not have it's state changed. This only applies to ports configured as an output. It is recommended to use the Chip_GPIO_SetPortOutHigh() function instead.

Definition at line 347 of file gpio_18xx_43xx.h.

void Chip_GPIO_WriteDirBit ( LPC_GPIO_T pGPIO,
uint32_t  port,
uint8_t  bit,
bool  setting 
)

Set a GPIO direction.

Parameters
pGPIO: The base of GPIO peripheral on the chip
port: GPIO port to set
bit: GPIO bit to set
setting: true for output, false for input
Returns
Nothing
Note
It is recommended to use the Chip_GPIO_SetPinDIROutput(), Chip_GPIO_SetPinDIRInput() or Chip_GPIO_SetPinDIR() functions instead of this function.

Definition at line 61 of file gpio_18xx_43xx.c.

STATIC INLINE void Chip_GPIO_WritePortBit ( LPC_GPIO_T pGPIO,
uint32_t  port,
uint8_t  pin,
bool  setting 
)

Set a GPIO port/bit state.

Parameters
pGPIO: The base of GPIO peripheral on the chip
port: GPIO port to set
pin: GPIO pin to set
setting: true for high, false for low
Returns
Nothing

Definition at line 81 of file gpio_18xx_43xx.h.