MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages

Overview

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

GPIO Configuration

void GPIO_PinInit (gpio_port_num_t port, uint8_t pin, const gpio_pin_config_t *config)
 Initializes a GPIO pin used by the board. More...
 

GPIO Output Operations

void GPIO_PinWrite (gpio_port_num_t port, uint8_t pin, uint8_t output)
 Sets the output level of the multiple GPIO pins to the logic 1 or 0. More...
 
void GPIO_PortSet (gpio_port_num_t port, uint8_t mask)
 Sets the output level of the multiple GPIO pins to the logic 1. More...
 
void GPIO_PortClear (gpio_port_num_t port, uint8_t mask)
 Sets the output level of the multiple GPIO pins to the logic 0. More...
 
void GPIO_PortToggle (gpio_port_num_t port, uint8_t mask)
 Reverses the current output logic of the multiple GPIO pins. More...
 

GPIO Input Operations

uint32_t GPIO_PinRead (gpio_port_num_t port, uint8_t pin)
 Reads the current input value of the GPIO port. More...
 

Function Documentation

void GPIO_PinInit ( gpio_port_num_t  port,
uint8_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
portGPIO 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. ...
pinGPIO port pin number
configGPIO pin configuration pointer
void GPIO_PinWrite ( gpio_port_num_t  port,
uint8_t  pin,
uint8_t  output 
)
Parameters
portGPIO 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. ...
pinGPIO pin number
outputGPIO pin output logic level.
  • 0: corresponding pin output low-logic level.
  • 1: corresponding pin output high-logic level.
void GPIO_PortSet ( gpio_port_num_t  port,
uint8_t  mask 
)
Parameters
portGPIO 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. ...
maskGPIO pin number macro
void GPIO_PortClear ( gpio_port_num_t  port,
uint8_t  mask 
)
Parameters
portGPIO 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. ...
maskGPIO pin number macro
void GPIO_PortToggle ( gpio_port_num_t  port,
uint8_t  mask 
)
Parameters
portGPIO 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. ...
maskGPIO pin number macro
uint32_t GPIO_PinRead ( gpio_port_num_t  port,
uint8_t  pin 
)
Parameters
portGPIO 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. ...
pinGPIO pin number
Return values
GPIOport input value
  • 0: corresponding pin input low-logic level.
  • 1: corresponding pin input high-logic level.