MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
GPIO: General-Purpose Input/Output Driver

Overview

The MCUXpresso SDK provides a peripheral driver for the General-Purpose Input/Output (GPIO) module of MCUXpresso SDK devices.

Typical use case

Input Operation

Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/gpio

Data Structures

struct  gpio_pin_config_t
 GPIO Init structure definition. More...
 

Enumerations

enum  gpio_pin_direction_t {
  kGPIO_DigitalInput = 0U,
  kGPIO_DigitalOutput = 1U
}
 GPIO direction definition. More...
 
enum  gpio_interrupt_mode_t {
  kGPIO_NoIntmode = 0U,
  kGPIO_IntLowLevel = 1U,
  kGPIO_IntHighLevel = 2U,
  kGPIO_IntRisingEdge = 3U,
  kGPIO_IntFallingEdge = 4U,
  kGPIO_IntRisingOrFallingEdge = 5U
}
 GPIO interrupt mode definition. More...
 

Driver version

#define FSL_GPIO_DRIVER_VERSION   (MAKE_VERSION(2, 0, 5))
 GPIO driver version. More...
 

GPIO Initialization and Configuration functions

void GPIO_PinInit (GPIO_Type *base, uint32_t pin, const gpio_pin_config_t *Config)
 Initializes the GPIO peripheral according to the specified parameters in the initConfig. More...
 

GPIO Reads and Write Functions

void GPIO_PinWrite (GPIO_Type *base, uint32_t pin, uint8_t output)
 Sets the output level of the individual GPIO pin to logic 1 or 0. More...
 
static void GPIO_WritePinOutput (GPIO_Type *base, uint32_t pin, uint8_t output)
 Sets the output level of the individual GPIO pin to 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_SetPinsOutput (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_ClearPinsOutput (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...
 
static uint32_t GPIO_PinRead (GPIO_Type *base, uint32_t pin)
 Reads the current input value of the GPIO port. More...
 
static uint32_t GPIO_ReadPinInput (GPIO_Type *base, uint32_t pin)
 Reads the current input value of the GPIO port. More...
 

GPIO Reads Pad Status Functions

static uint8_t GPIO_PinReadPadStatus (GPIO_Type *base, uint32_t pin)
 Reads the current GPIO pin pad status. More...
 
static uint8_t GPIO_ReadPadStatus (GPIO_Type *base, uint32_t pin)
 Reads the current GPIO pin pad status. More...
 

Interrupts and flags management functions

void GPIO_PinSetInterruptConfig (GPIO_Type *base, uint32_t pin, gpio_interrupt_mode_t pinInterruptMode)
 Sets the current pin interrupt mode. More...
 
static void GPIO_SetPinInterruptConfig (GPIO_Type *base, uint32_t pin, gpio_interrupt_mode_t pinInterruptMode)
 Sets the current pin interrupt mode. More...
 
static void GPIO_PortEnableInterrupts (GPIO_Type *base, uint32_t mask)
 Enables the specific pin interrupt. More...
 
static void GPIO_EnableInterrupts (GPIO_Type *base, uint32_t mask)
 Enables the specific pin interrupt. More...
 
static void GPIO_PortDisableInterrupts (GPIO_Type *base, uint32_t mask)
 Disables the specific pin interrupt. More...
 
static void GPIO_DisableInterrupts (GPIO_Type *base, uint32_t mask)
 Disables the specific pin interrupt. More...
 
static uint32_t GPIO_PortGetInterruptFlags (GPIO_Type *base)
 Reads individual pin interrupt status. More...
 
static uint32_t GPIO_GetPinsInterruptFlags (GPIO_Type *base)
 Reads individual pin interrupt status. More...
 
static void GPIO_PortClearInterruptFlags (GPIO_Type *base, uint32_t mask)
 Clears pin interrupt flag. More...
 
static void GPIO_ClearPinsInterruptFlags (GPIO_Type *base, uint32_t mask)
 Clears pin interrupt flag. More...
 

Data Structure Documentation

struct gpio_pin_config_t

Data Fields

gpio_pin_direction_t direction
 Specifies the pin direction. More...
 
uint8_t outputLogic
 Set a default output logic, which has no use in input.
 
gpio_interrupt_mode_t interruptMode
 Specifies the pin interrupt mode, a value of gpio_interrupt_mode_t. More...
 

Field Documentation

gpio_pin_direction_t gpio_pin_config_t::direction
gpio_interrupt_mode_t gpio_pin_config_t::interruptMode

Macro Definition Documentation

#define FSL_GPIO_DRIVER_VERSION   (MAKE_VERSION(2, 0, 5))

Enumeration Type Documentation

Enumerator
kGPIO_DigitalInput 

Set current pin as digital input.

kGPIO_DigitalOutput 

Set current pin as digital output.

Enumerator
kGPIO_NoIntmode 

Set current pin general IO functionality.

kGPIO_IntLowLevel 

Set current pin interrupt is low-level sensitive.

kGPIO_IntHighLevel 

Set current pin interrupt is high-level sensitive.

kGPIO_IntRisingEdge 

Set current pin interrupt is rising-edge sensitive.

kGPIO_IntFallingEdge 

Set current pin interrupt is falling-edge sensitive.

kGPIO_IntRisingOrFallingEdge 

Enable the edge select bit to override the ICR register's configuration.

Function Documentation

void GPIO_PinInit ( GPIO_Type *  base,
uint32_t  pin,
const gpio_pin_config_t Config 
)
Parameters
baseGPIO base pointer.
pinSpecifies the pin number
Configpointer to a gpio_pin_config_t structure that contains the configuration information.
void GPIO_PinWrite ( GPIO_Type *  base,
uint32_t  pin,
uint8_t  output 
)
Parameters
baseGPIO base pointer.
pinGPIO port pin number.
outputGPIOpin output logic level.
  • 0: corresponding pin output low-logic level.
  • 1: corresponding pin output high-logic level.
static void GPIO_WritePinOutput ( GPIO_Type *  base,
uint32_t  pin,
uint8_t  output 
)
inlinestatic
Deprecated:
Do not use this function. It has been superceded by GPIO_PinWrite.
static void GPIO_PortSet ( GPIO_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseGPIO peripheral base pointer (GPIO1, GPIO2, GPIO3, and so on.)
maskGPIO pin number macro
static void GPIO_SetPinsOutput ( GPIO_Type *  base,
uint32_t  mask 
)
inlinestatic
Deprecated:
Do not use this function. It has been superceded by GPIO_PortSet.
static void GPIO_PortClear ( GPIO_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseGPIO peripheral base pointer (GPIO1, GPIO2, GPIO3, and so on.)
maskGPIO pin number macro
static void GPIO_ClearPinsOutput ( GPIO_Type *  base,
uint32_t  mask 
)
inlinestatic
Deprecated:
Do not use this function. It has been superceded by GPIO_PortClear.
static void GPIO_PortToggle ( GPIO_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseGPIO peripheral base pointer (GPIO1, GPIO2, GPIO3, and so on.)
maskGPIO pin number macro
static uint32_t GPIO_PinRead ( GPIO_Type *  base,
uint32_t  pin 
)
inlinestatic
Parameters
baseGPIO base pointer.
pinGPIO port pin number.
Return values
GPIOport input value.
static uint32_t GPIO_ReadPinInput ( GPIO_Type *  base,
uint32_t  pin 
)
inlinestatic
Deprecated:
Do not use this function. It has been superceded by GPIO_PinRead.
static uint8_t GPIO_PinReadPadStatus ( GPIO_Type *  base,
uint32_t  pin 
)
inlinestatic
Parameters
baseGPIO base pointer.
pinGPIO port pin number.
Return values
GPIOpin pad status value.
static uint8_t GPIO_ReadPadStatus ( GPIO_Type *  base,
uint32_t  pin 
)
inlinestatic
Deprecated:
Do not use this function. It has been superceded by GPIO_PinReadPadStatus.
void GPIO_PinSetInterruptConfig ( GPIO_Type *  base,
uint32_t  pin,
gpio_interrupt_mode_t  pinInterruptMode 
)
Parameters
baseGPIO base pointer.
pinGPIO port pin number.
pinInterruptModepointer to a gpio_interrupt_mode_t structure that contains the interrupt mode information.
static void GPIO_SetPinInterruptConfig ( GPIO_Type *  base,
uint32_t  pin,
gpio_interrupt_mode_t  pinInterruptMode 
)
inlinestatic
Deprecated:
Do not use this function. It has been superceded by GPIO_PinSetInterruptConfig.
static void GPIO_PortEnableInterrupts ( GPIO_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseGPIO base pointer.
maskGPIO pin number macro.
static void GPIO_EnableInterrupts ( GPIO_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseGPIO base pointer.
maskGPIO pin number macro.
static void GPIO_PortDisableInterrupts ( GPIO_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseGPIO base pointer.
maskGPIO pin number macro.
static void GPIO_DisableInterrupts ( GPIO_Type *  base,
uint32_t  mask 
)
inlinestatic
Deprecated:
Do not use this function. It has been superceded by GPIO_PortDisableInterrupts.
static uint32_t GPIO_PortGetInterruptFlags ( GPIO_Type *  base)
inlinestatic
Parameters
baseGPIO base pointer.
Return values
currentpin interrupt status flag.
static uint32_t GPIO_GetPinsInterruptFlags ( GPIO_Type *  base)
inlinestatic
Parameters
baseGPIO base pointer.
Return values
currentpin interrupt status flag.
static void GPIO_PortClearInterruptFlags ( GPIO_Type *  base,
uint32_t  mask 
)
inlinestatic

Status flags are cleared by writing a 1 to the corresponding bit position.

Parameters
baseGPIO base pointer.
maskGPIO pin number macro.
static void GPIO_ClearPinsInterruptFlags ( GPIO_Type *  base,
uint32_t  mask 
)
inlinestatic

Status flags are cleared by writing a 1 to the corresponding bit position.

Parameters
baseGPIO base pointer.
maskGPIO pin number macro.