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
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
-
port | GPIO PORT number, see "gpio_port_num_t". For each group GPIO (GPIOA, GPIOB,etc) control registers, they handles four PORT number controls. GPIOA serial registers --— PTA 0 ~ 7, PTB 0 ~7 ... PTD 0 ~ 7. GPIOB serial registers --— PTE 0 ~ 7, PTF 0 ~7 ... PTH 0 ~ 7. ... |
pin | GPIO port pin number |
config | GPIO pin configuration pointer |
- Parameters
-
port | GPIO PORT number, see "gpio_port_num_t". For each group GPIO (GPIOA, GPIOB,etc) control registers, they handles four PORT number controls. GPIOA serial registers --— PTA 0 ~ 7, PTB 0 ~7 ... PTD 0 ~ 7. GPIOB serial registers --— PTE 0 ~ 7, PTF 0 ~7 ... PTH 0 ~ 7. ... |
pin | GPIO pin number |
output | GPIO pin output logic level.
- 0: corresponding pin output low-logic level.
- 1: corresponding pin output high-logic level.
|
- Parameters
-
port | GPIO PORT number, see "gpio_port_num_t". For each group GPIO (GPIOA, GPIOB,etc) control registers, they handles four PORT number controls. GPIOA serial registers --— PTA 0 ~ 7, PTB 0 ~7 ... PTD 0 ~ 7. GPIOB serial registers --— PTE 0 ~ 7, PTF 0 ~7 ... PTH 0 ~ 7. ... |
mask | GPIO pin number macro |
- Parameters
-
port | GPIO PORT number, see "gpio_port_num_t". For each group GPIO (GPIOA, GPIOB,etc) control registers, they handles four PORT number controls. GPIOA serial registers --— PTA 0 ~ 7, PTB 0 ~7 ... PTD 0 ~ 7. GPIOB serial registers --— PTE 0 ~ 7, PTF 0 ~7 ... PTH 0 ~ 7. ... |
mask | GPIO pin number macro |
- Parameters
-
port | GPIO PORT number, see "gpio_port_num_t". For each group GPIO (GPIOA, GPIOB,etc) control registers, they handles four PORT number controls. GPIOA serial registers --— PTA 0 ~ 7, PTB 0 ~7 ... PTD 0 ~ 7. GPIOB serial registers --— PTE 0 ~ 7, PTF 0 ~7 ... PTH 0 ~ 7. ... |
mask | GPIO pin number macro |
- Parameters
-
port | GPIO PORT number, see "gpio_port_num_t". For each group GPIO (GPIOA, GPIOB,etc) control registers, they handles four PORT number controls. GPIOA serial registers --— PTA 0 ~ 7, PTB 0 ~7 ... PTD 0 ~ 7. GPIOB serial registers --— PTE 0 ~ 7, PTF 0 ~7 ... PTH 0 ~ 7. ... |
pin | GPIO pin number |
- Return values
-
GPIO | port input value
- 0: corresponding pin input low-logic level.
- 1: corresponding pin input high-logic level.
|