The MCUXpresso SDK provides a peripheral driver for the General-Purpose Input/Output (GPIO) module of MCUXpresso SDK devices.
Typical use case
Output Operation
Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/gpio
Input Operation
Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/gpio
|
void | GPIO_PinWrite (GPIO_Type *base, uint32_t pin, uint8_t output) |
| Sets the output level of single GPIO pin to the logic 1 or 0. More...
|
|
__STATIC_INLINE void | GPIO_PortSet (GPIO_Type *base, uint32_t port, uint32_t mask) |
| Sets the output level of the multiple GPIO pins to the logic 1. More...
|
|
__STATIC_INLINE void | GPIO_PortClear (GPIO_Type *base, uint32_t port, uint32_t mask) |
| Sets the output level of the multiple GPIO pins to the logic 0. More...
|
|
void | GPIO_PortToggle (GPIO_Type *base, uint32_t port, uint32_t mask) |
| Reverses the current output logic of the multiple GPIO pins. More...
|
|
|
__STATIC_INLINE uint32_t | GPIO_PinRead (GPIO_Type *base, uint32_t pin) |
| Reads the current input value of the GPIO port. More...
|
|
void GPIO_PinInit |
( |
GPIO_Type * |
base, |
|
|
uint32_t |
pin, |
|
|
const gpio_pin_config_t * |
config |
|
) |
| |
To initialize the GPIO, define a pin configuration, as either input or output, in the user file. Then, call the GPIO_PinInit() function.
This is an example to define an input pin or an output pin configuration.
* Define a digital input pin configuration,
* {
* 0,
* }
* Define a digital output pin configuration,
* {
* 0,
* }
*
- Parameters
-
base | GPIO peripheral base pointer |
pin | GPIO pin number |
config | GPIO pin configuration pointer |
void GPIO_PinWrite |
( |
GPIO_Type * |
base, |
|
|
uint32_t |
pin, |
|
|
uint8_t |
output |
|
) |
| |
- Parameters
-
base | GPIO peripheral base pointer |
pin | GPIO pin number |
output | GPIO pin output logic level.
- 0: corresponding pin output low-logic level.
- 1: corresponding pin output high-logic level.
|
__STATIC_INLINE void GPIO_PortSet |
( |
GPIO_Type * |
base, |
|
|
uint32_t |
port, |
|
|
uint32_t |
mask |
|
) |
| |
- Parameters
-
base | GPIO peripheral base pointer (GPIOA, GPIOB, GPIOC, and so on.) |
port | GPIO port number. Each port contains 32 GPIOs. |
mask | GPIO pin bit mask. Bit position stands for the pin number in the port. |
__STATIC_INLINE void GPIO_PortClear |
( |
GPIO_Type * |
base, |
|
|
uint32_t |
port, |
|
|
uint32_t |
mask |
|
) |
| |
- Parameters
-
base | GPIO peripheral base pointer |
port | GPIO port number. Each port contains 32 GPIOs. |
mask | GPIO pin bit mask. Bit position stands for the pin number in the port. |
void GPIO_PortToggle |
( |
GPIO_Type * |
base, |
|
|
uint32_t |
port, |
|
|
uint32_t |
mask |
|
) |
| |
- Parameters
-
base | GPIO peripheral base pointer |
port | GPIO port number. Each port contains 32 GPIOs. |
mask | GPIO pin bit mask. Bit position stands for the pin number in the port. |
__STATIC_INLINE uint32_t GPIO_PinRead |
( |
GPIO_Type * |
base, |
|
|
uint32_t |
pin |
|
) |
| |
- Parameters
-
base | GPIO peripheral base pointer |
pin | GPIO pin number |
- Return values
-
GPIO | port input value
- 0: corresponding pin input low-logic level.
- 1: corresponding pin input high-logic level.
|
- Parameters
-
base | GPIO peripheral base pointer. |
pin | GPIO pin number. |
config | GPIO pin interrupt configuration. |
__STATIC_INLINE void GPIO_PortEnableInterrupts |
( |
GPIO_Type * |
base, |
|
|
uint32_t |
port, |
|
|
uint32_t |
mask |
|
) |
| |
- Parameters
-
base | GPIO base pointer. |
port | GPIO port number. Each port contains 32 GPIOs. |
mask | GPIO pin bit mask. Bit position stands for the pin number in the port. |
__STATIC_INLINE void GPIO_PortDisableInterrupts |
( |
GPIO_Type * |
base, |
|
|
uint32_t |
port, |
|
|
uint32_t |
mask |
|
) |
| |
- Parameters
-
base | GPIO base pointer. |
port | GPIO port number. Each port contains 32 GPIOs. |
mask | GPIO pin bit mask. Bit position stands for the pin number in the port. |
__STATIC_INLINE uint32_t GPIO_PortGetInterruptFlags |
( |
GPIO_Type * |
base, |
|
|
uint32_t |
port |
|
) |
| |
The flag remains set until a logic one is written to that flag.
- Parameters
-
base | GPIO peripheral base pointer |
port | GPIO port number. Each port contains 32 GPIOs. |
- Return values
-
The | current GPIO port interrupt status flag, for example, 0x00010001 means the pin 0 and 16 have the interrupt. |
__STATIC_INLINE void GPIO_PortClearInterruptFlags |
( |
GPIO_Type * |
base, |
|
|
uint32_t |
port, |
|
|
uint32_t |
mask |
|
) |
| |
- Parameters
-
base | GPIO peripheral base pointer |
port | GPIO port number. Each port contains 32 GPIOs. |
mask | GPIO pin bit mask. Bit position stands for the pin number in the port. |