MCUXpresso SDK API Reference Manual  Rev 2.12.1
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...
 
void GPIO_GetVersionInfo (GPIO_Type *base, gpio_version_info_t *info)
 Get GPIO version information. More...
 
static void GPIO_SecurePrivilegeLock (GPIO_Type *base, gpio_pin_interrupt_control_t mask)
 lock or unlock secure privilege. More...
 
static void GPIO_EnablePinControlNonSecure (GPIO_Type *base, uint32_t mask)
 Enable Pin Control Non-Secure. More...
 
static void GPIO_DisablePinControlNonSecure (GPIO_Type *base, uint32_t mask)
 Disable Pin Control Non-Secure. More...
 
static void GPIO_EnablePinControlNonPrivilege (GPIO_Type *base, uint32_t mask)
 Enable Pin Control Non-Privilege. More...
 
static void GPIO_DisablePinControlNonPrivilege (GPIO_Type *base, uint32_t mask)
 Disable Pin Control Non-Privilege. More...
 
static void GPIO_EnableInterruptControlNonSecure (GPIO_Type *base, uint32_t mask)
 Enable Interrupt Control Non-Secure. More...
 
static void GPIO_DisableInterruptControlNonSecure (GPIO_Type *base, uint32_t mask)
 Disable Interrupt Control Non-Secure. More...
 
static void GPIO_EnableInterruptControlNonPrivilege (GPIO_Type *base, uint32_t mask)
 Enable Interrupt Control Non-Privilege. More...
 
static void GPIO_DisableInterruptControlNonPrivilege (GPIO_Type *base, uint32_t mask)
 Disable Interrupt Control Non-Privilege. More...
 
static void GPIO_PortInputEnable (GPIO_Type *base, uint32_t mask)
 Enable port input. More...
 
static void GPIO_PortInputDisable (GPIO_Type *base, uint32_t mask)
 Disable port input. More...
 

GPIO Output Operations

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

GPIO Input Operations

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

GPIO Interrupt

static void GPIO_SetPinInterruptConfig (GPIO_Type *base, uint32_t pin, gpio_interrupt_config_t config)
 Configures the gpio pin interrupt/DMA request. More...
 
static void GPIO_SetPinInterruptChannel (GPIO_Type *base, uint32_t pin, gpio_interrupt_selection_t selection)
 Configures the gpio pin interrupt/DMA request/trigger output channel selection. More...
 
uint32_t GPIO_GpioGetInterruptFlags (GPIO_Type *base)
 Read the GPIO interrupt status flags. More...
 
uint32_t GPIO_GpioGetInterruptChannelFlags (GPIO_Type *base, uint32_t channel)
 Read the GPIO interrupt status flags based on selected interrupt channel(IRQS). More...
 
uint8_t GPIO_PinGetInterruptFlag (GPIO_Type *base, uint32_t pin)
 Read individual pin's interrupt status flag. More...
 
void GPIO_GpioClearInterruptFlags (GPIO_Type *base, uint32_t mask)
 Clears GPIO pin interrupt status flags. More...
 
void GPIO_GpioClearInterruptChannelFlags (GPIO_Type *base, uint32_t mask, uint32_t channel)
 Clears GPIO pin interrupt status flags based on selected interrupt channel(IRQS). More...
 
void GPIO_PinClearInterruptFlag (GPIO_Type *base, uint32_t pin)
 Clear GPIO individual pin's interrupt status flag. More...
 
static uint32_t GPIO_GetPinsDMARequestFlags (GPIO_Type *base)
 Reads the GPIO DMA request flags. More...
 
static void GPIO_SetMultipleInterruptPinsConfig (GPIO_Type *base, uint32_t mask, gpio_interrupt_config_t config)
 Sets the GPIO interrupt configuration in PCR register for multiple pins. 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 (GPIOA, GPIOB, GPIOC, and so on.)
pinGPIO port pin number
configGPIO pin configuration pointer
void GPIO_GetVersionInfo ( GPIO_Type *  base,
gpio_version_info_t info 
)
Parameters
baseGPIO peripheral base pointer (GPIOA, GPIOB, GPIOC, and so on.)
infoGPIO version information
static void GPIO_SecurePrivilegeLock ( GPIO_Type *  base,
gpio_pin_interrupt_control_t  mask 
)
inlinestatic
Parameters
baseGPIO peripheral base pointer (GPIOA, GPIOB, GPIOC, and so on.)
maskpin or interrupt macro
static void GPIO_EnablePinControlNonSecure ( GPIO_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseGPIO peripheral base pointer (GPIOA, GPIOB, GPIOC, and so on.)
maskGPIO pin number macro
static void GPIO_DisablePinControlNonSecure ( GPIO_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseGPIO peripheral base pointer (GPIOA, GPIOB, GPIOC, and so on.)
maskGPIO pin number macro
static void GPIO_EnablePinControlNonPrivilege ( GPIO_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseGPIO peripheral base pointer (GPIOA, GPIOB, GPIOC, and so on.)
maskGPIO pin number macro
static void GPIO_DisablePinControlNonPrivilege ( GPIO_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseGPIO peripheral base pointer (GPIOA, GPIOB, GPIOC, and so on.)
maskGPIO pin number macro
static void GPIO_EnableInterruptControlNonSecure ( GPIO_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseGPIO peripheral base pointer (GPIOA, GPIOB, GPIOC, and so on.)
maskGPIO pin number macro
static void GPIO_DisableInterruptControlNonSecure ( GPIO_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseGPIO peripheral base pointer (GPIOA, GPIOB, GPIOC, and so on.)
maskGPIO pin number macro
static void GPIO_EnableInterruptControlNonPrivilege ( GPIO_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseGPIO peripheral base pointer (GPIOA, GPIOB, GPIOC, and so on.)
maskGPIO pin number macro
static void GPIO_DisableInterruptControlNonPrivilege ( GPIO_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseGPIO peripheral base pointer (GPIOA, GPIOB, GPIOC, and so on.)
maskGPIO pin number macro
static void GPIO_PortInputEnable ( GPIO_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseGPIO peripheral base pointer (GPIOA, GPIOB, GPIOC, and so on.)
maskGPIO pin number macro
static void GPIO_PortInputDisable ( GPIO_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseGPIO peripheral base pointer (GPIOA, GPIOB, GPIOC, and so on.)
maskGPIO pin number macro
static void GPIO_PinWrite ( GPIO_Type *  base,
uint32_t  pin,
uint8_t  output 
)
inlinestatic
Parameters
baseGPIO peripheral base pointer (GPIOA, GPIOB, GPIOC, and so on.)
pinGPIO pin number
outputGPIO pin output logic level.
  • 0: corresponding pin output low-logic level.
  • 1: corresponding pin output high-logic level.
static void GPIO_PortSet ( GPIO_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseGPIO peripheral base pointer (GPIOA, GPIOB, GPIOC, and so on.)
maskGPIO pin number macro
static void GPIO_PortClear ( GPIO_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseGPIO peripheral base pointer (GPIOA, GPIOB, GPIOC, and so on.)
maskGPIO pin number macro
static void GPIO_PortToggle ( GPIO_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseGPIO peripheral base pointer (GPIOA, GPIOB, GPIOC, and so on.)
maskGPIO pin number macro
static uint32_t GPIO_PinRead ( GPIO_Type *  base,
uint32_t  pin 
)
inlinestatic
Parameters
baseGPIO peripheral base pointer (GPIOA, GPIOB, GPIOC, and so on.)
pinGPIO pin number
Return values
GPIOport input value
  • 0: corresponding pin input low-logic level.
  • 1: corresponding pin input high-logic level.
static void GPIO_SetPinInterruptConfig ( GPIO_Type *  base,
uint32_t  pin,
gpio_interrupt_config_t  config 
)
inlinestatic
Parameters
baseGPIO peripheral base pointer.
pinGPIO pin number.
configGPIO pin interrupt configuration.
static void GPIO_SetPinInterruptChannel ( GPIO_Type *  base,
uint32_t  pin,
gpio_interrupt_selection_t  selection 
)
inlinestatic
Parameters
baseGPIO peripheral base pointer.
pinGPIO pin number.
selectionGPIO pin interrupt output selection.
uint32_t GPIO_GpioGetInterruptFlags ( GPIO_Type *  base)
Parameters
baseGPIO peripheral base pointer. (GPIOA, GPIOB, GPIOC, and so on.)
Returns
The current GPIO's interrupt status flag. '1' means the related pin's flag is set, '0' means the related pin's flag not set. For example, the return value 0x00010001 means the pin 0 and 17 have the interrupt pending.
uint32_t GPIO_GpioGetInterruptChannelFlags ( GPIO_Type *  base,
uint32_t  channel 
)
Parameters
baseGPIO peripheral base pointer. (GPIOA, GPIOB, GPIOC, and so on.)
channel'0' means selete interrupt channel 0, '1' means selete interrupt channel 1.
Returns
The current GPIO's interrupt status flag based on the selected interrupt channel. '1' means the related pin's flag is set, '0' means the related pin's flag not set. For example, the return value 0x00010001 means the pin 0 and 17 have the interrupt pending.
uint8_t GPIO_PinGetInterruptFlag ( GPIO_Type *  base,
uint32_t  pin 
)
Parameters
baseGPIO peripheral base pointer. (GPIOA, GPIOB, GPIOC, and so on)
pinGPIO specific pin number.
Returns
The current selected pin's interrupt status flag.
void GPIO_GpioClearInterruptFlags ( GPIO_Type *  base,
uint32_t  mask 
)
Parameters
baseGPIO peripheral base pointer (GPIOA, GPIOB, GPIOC, and so on.)
maskGPIO pin number macro
void GPIO_GpioClearInterruptChannelFlags ( GPIO_Type *  base,
uint32_t  mask,
uint32_t  channel 
)
Parameters
baseGPIO peripheral base pointer (GPIOA, GPIOB, GPIOC, and so on.)
maskGPIO pin number macro
channel'0' means selete interrupt channel 0, '1' means selete interrupt channel 1.
void GPIO_PinClearInterruptFlag ( GPIO_Type *  base,
uint32_t  pin 
)
Parameters
baseGPIO peripheral base pointer (GPIOA, GPIOB, GPIOC, and so on).
pinGPIO specific pin number.
static uint32_t GPIO_GetPinsDMARequestFlags ( GPIO_Type *  base)
inlinestatic

The corresponding flag will be cleared automatically at the completion of the requested DMA transfer

static void GPIO_SetMultipleInterruptPinsConfig ( GPIO_Type *  base,
uint32_t  mask,
gpio_interrupt_config_t  config 
)
inlinestatic
Parameters
baseGPIO peripheral base pointer.
maskGPIO pin number macro.
configGPIO pin interrupt configuration.