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_Type *base, uint32_t pin, const gpio_pin_config_t *config)
 Initializes a GPIO pin used by the board. More...
 

GPIO Output Operations

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...
 

GPIO Input Operations

__STATIC_INLINE uint32_t GPIO_PinRead (GPIO_Type *base, uint32_t pin)
 Reads the current input value of the GPIO port. More...
 

GPIO Interrupt

void GPIO_PinSetInterruptConfig (GPIO_Type *base, uint32_t pin, gpio_interrupt_config_t config)
 Configures the gpio pin interrupt. More...
 
__STATIC_INLINE void GPIO_PortEnableInterrupts (GPIO_Type *base, uint32_t port, uint32_t mask)
 Enables the specific pin interrupt. More...
 
__STATIC_INLINE void GPIO_PortDisableInterrupts (GPIO_Type *base, uint32_t port, uint32_t mask)
 Disables the specific pin interrupt. More...
 
__STATIC_INLINE uint32_t GPIO_PortGetInterruptFlags (GPIO_Type *base, uint32_t port)
 Reads the GPIO port interrupt status flag. More...
 
__STATIC_INLINE void GPIO_PortClearInterruptFlags (GPIO_Type *base, uint32_t port, uint32_t mask)
 Clears multiple GPIO pin interrupt status flags. More...
 

Function Documentation

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
baseGPIO peripheral base pointer
pinGPIO pin number
configGPIO pin configuration pointer
void GPIO_PinWrite ( GPIO_Type *  base,
uint32_t  pin,
uint8_t  output 
)
Parameters
baseGPIO peripheral base pointer
pinGPIO pin number
outputGPIO 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
baseGPIO peripheral base pointer (GPIOA, GPIOB, GPIOC, and so on.)
portGPIO port number. Each port contains 32 GPIOs.
maskGPIO 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
baseGPIO peripheral base pointer
portGPIO port number. Each port contains 32 GPIOs.
maskGPIO 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
baseGPIO peripheral base pointer
portGPIO port number. Each port contains 32 GPIOs.
maskGPIO 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
baseGPIO peripheral base pointer
pinGPIO pin number
Return values
GPIOport input value
  • 0: corresponding pin input low-logic level.
  • 1: corresponding pin input high-logic level.
void GPIO_PinSetInterruptConfig ( GPIO_Type *  base,
uint32_t  pin,
gpio_interrupt_config_t  config 
)
Parameters
baseGPIO peripheral base pointer.
pinGPIO pin number.
configGPIO pin interrupt configuration.
__STATIC_INLINE void GPIO_PortEnableInterrupts ( GPIO_Type *  base,
uint32_t  port,
uint32_t  mask 
)
Parameters
baseGPIO base pointer.
portGPIO port number. Each port contains 32 GPIOs.
maskGPIO 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
baseGPIO base pointer.
portGPIO port number. Each port contains 32 GPIOs.
maskGPIO 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
baseGPIO peripheral base pointer
portGPIO port number. Each port contains 32 GPIOs.
Return values
Thecurrent 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
baseGPIO peripheral base pointer
portGPIO port number. Each port contains 32 GPIOs.
maskGPIO pin bit mask. Bit position stands for the pin number in the port.