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

Read Guidance

This document consists of sections titled with Driver Overview, Data Structures, Enumerations, Functions, etc., each with an overview list and detailed documentation. It is recommended to read the Driver Overview first for it includes a comprehensive description of the peripheral, driver and driver changes. Other sections give detailed information for APIs, enums, macros, etc., for your further reference.

Driver Overview

 GPIO Peripheral and Driver Overview
 Content including 1) peripheral features; 2) driver design logic and use method; 3) typical use case.
 
 The Driver Change Log
 The current GPIO driver version is 2.0.0.
 

Data Structures

struct  gpio_config_t
 GPIO Pin configuration covering all configurable fields when GPIO is configured in GPIO mode. More...
 

Macros

#define GPIO_MUX_ENUM_TO_PORT_INDEX(emux)   (((uint16_t)(emux)&0xF00U) >> 0x08U)
 Helper MACRO function to extract Port Index. More...
 
#define GPIO_MUX_ENUM_TO_PIN_INDEX(emux)   (((uint16_t)(emux)&0xF0U) >> 0x04U)
 Helper MACRO function to extract Pin Index. More...
 
#define GPIO_MUX_ENUM_TO_REG_VALUE(emux)   ((uint16_t)(emux)&0x3U)
 Helper MACRO function to extract Pin mux config register value. More...
 
#define GPIO_MUX_ENUM_TO_PIN_MASK(emux)
 Helper MACRO function to extract Pin mux config mask. More...
 
#define GPIO_MUX_ENUM_TO_PIN_VALUE(emux)
 Helper MACRO function to extract Pin mux config register value on a GPIO Pin. More...
 

Enumerations

enum  gpio_pin_t {
  kGPIO_Pin0 = (0x1U << 0U),
  kGPIO_Pin1 = (0x1U << 1U),
  kGPIO_Pin2 = (0x1U << 2U),
  kGPIO_Pin3 = (0x1U << 3U),
  kGPIO_Pin4 = (0x1U << 4U),
  kGPIO_Pin5 = (0x1U << 5U),
  kGPIO_Pin6 = (0x1U << 6U),
  kGPIO_Pin7 = (0x1U << 7U),
  kGPIO_Pin8 = (0x1U << 8U),
  kGPIO_Pin9 = (0x1U << 9U),
  kGPIO_Pin10 = (0x1U << 10U),
  kGPIO_Pin11 = (0x1U << 11U),
  kGPIO_Pin12 = (0x1U << 12U),
  kGPIO_Pin13 = (0x1U << 13U),
  kGPIO_Pin14 = (0x1U << 14U),
  kGPIO_Pin15 = (0x1U << 15U)
}
 GPIO Pin identifier with each pin get a unique bit thus they can be ORed. More...
 
enum  gpio_peripheral_mode_t {
  kGPIO_ModeGpio = 0U,
  kGPIO_ModePeripheral = 1U
}
 GPIO Pin peripheral/gpio mode option. More...
 
enum  gpio_direction_t {
  kGPIO_DigitalInput = 0U,
  kGPIO_DigitalOutput = 1U
}
 GPIO Pin input/output direction option. More...
 
enum  gpio_pull_mode_t {
  kGPIO_PullDown = 0U,
  kGPIO_PullUp = 1U,
  kGPIO_PullDisable = 2U
}
 GPIO Pin pull resistor mode option. More...
 
enum  gpio_output_mode_t {
  kGPIO_OutputOpenDrain = 0U,
  kGPIO_OutputPushPull = 1U
}
 GPIO Pin output mode option. More...
 
enum  gpio_output_level_t {
  kGPIO_OutputLow = 0U,
  kGPIO_OutputHigh = 1U
}
 GPIO Pin output High/Low level option. More...
 
enum  gpio_output_slew_rate_t {
  kGPIO_SlewRateFast = 0U,
  kGPIO_SlewRateSlow = 1U
}
 GPIO Pin output Fast/Slow slew rate option. More...
 
enum  gpio_output_drive_strength_t {
  kGPIO_DriveStrengthLow = 0U,
  kGPIO_DriveStrengthHigh = 1U
}
 GPIO Pin output High/Low drive strength option. More...
 
enum  gpio_interrupt_mode_t {
  kGPIO_InterruptRisingEdge = 0x0U,
  kGPIO_InterruptFallingEdge = 0x1U,
  kGPIO_InterruptDisable = 0x2U
}
 GPIO Pin interrupt detect option. More...
 

Driver version

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

Initialization and De-initialization Interfaces

void GPIO_PinInit (GPIO_Type *base, gpio_pin_t ePin, const gpio_config_t *psConfig)
 Initializes a GPIO pin with provided structure _gpio_config covering all configuration fields. More...
 

GPIO Peripheral Mode Interfaces

static void GPIO_PinSetPeripheralMode (GPIO_Type *base, gpio_pin_t ePin, gpio_peripheral_mode_t eMode)
 Configure the GPIO Pin as Peripheral mode or GPIO mode for one pin. More...
 
static void GPIO_PinSetPeripheralMux (gpio_peripheral_mux_t eMux)
 Configure the multiplexing of GPIO pins to different peripheral. More...
 

GPIO Pin Configuration Interfaces

static void GPIO_PinSetDirection (GPIO_Type *base, gpio_pin_t ePin, gpio_direction_t eDirection)
 Configure the GPIO pin as Input or Output for one pin. More...
 
static void GPIO_PinSetOutputMode (GPIO_Type *base, gpio_pin_t ePin, gpio_output_mode_t eOutMode)
 Configure GPIO pin output as Push-Pull or Open-Drain for one pin. More...
 
static void GPIO_PinSetDriveStrength (GPIO_Type *base, gpio_pin_t ePin, gpio_output_drive_strength_t eDriveStrength)
 Configure High/Low drive strength when Pin is configured as output for one pin. More...
 
static void GPIO_PinSetSlewRate (GPIO_Type *base, gpio_pin_t ePin, gpio_output_slew_rate_t eSlewRate)
 Configure GPIO pin Fast/Slow slew rate when pin is configured as output. More...
 
static void GPIO_PinSetPullResistorMode (GPIO_Type *base, gpio_pin_t ePin, gpio_pull_mode_t ePullMode)
 Configure Pull resistor for GPIO pin to Disable/Pull-Up/Pull-Down. More...
 

GPIO PIN/PORT Write/Read/Toggle Interfaces

static void GPIO_PinWrite (GPIO_Type *base, gpio_pin_t ePin, gpio_output_level_t eOutput)
 Set GPIO Pin as High/Low voltage level on Output. More...
 
static void GPIO_PortSet (GPIO_Type *base, uint16_t u16Pins)
 Set GPIO multiple pins output High voltage level without impact pins. More...
 
static void GPIO_PinSet (GPIO_Type *base, gpio_pin_t ePin)
 Output High voltage level for GPIO Pin when configured as Output. More...
 
static void GPIO_PortClear (GPIO_Type *base, uint16_t u16Pins)
 Set GPIO multiple pins belong to same PORT output Low voltage level when these pins are configured as output. More...
 
static void GPIO_PinClear (GPIO_Type *base, gpio_pin_t ePin)
 Output Low voltage level for GPIO Pin when configured as Output. More...
 
static void GPIO_PortToggle (GPIO_Type *base, uint16_t u16Pins)
 Toggle GPIO multiple pins belong to same PORT when these pins are configured as output. More...
 
static void GPIO_PinToggle (GPIO_Type *base, gpio_pin_t ePin)
 Toggle the GPIO output voltage level when configured as Output. More...
 
static uint16_t GPIO_PortRead (GPIO_Type *base)
 Read High/Low voltage level for multiple GPIO pins from the pin or the data bus. More...
 
static uint8_t GPIO_PinRead (GPIO_Type *base, gpio_pin_t ePin)
 Read High/Low voltage level for one GPIO pin from the pin or the data bus. More...
 
static uint16_t GPIO_PortReadRawData (GPIO_Type *base)
 Read Raw voltage high/low level data from the pins or peripheral bus for multiple pins belong to same PORT. More...
 
static uint8_t GPIO_PinReadRawData (GPIO_Type *base, gpio_pin_t ePin)
 Read Raw logic level data from the pins or peripheral bus for one pin. More...
 

GPIO Interrupt Interfaces

static void GPIO_PinSetInterruptConfig (GPIO_Type *base, gpio_pin_t ePin, gpio_interrupt_mode_t eIntConfig)
 Configure GPIO Pin interrupt detection condition. More...
 
static void GPIO_PortAssertSWInterrupts (GPIO_Type *base, uint16_t u16Pins)
 Assert software interrupt for multiple pins belong to same port which will generate interrupt. More...
 
static void GPIO_PortDeassertSWInterrupts (GPIO_Type *base, uint16_t u16Pins)
 De-Assert software interrupt for multiple pins belong to same port which will stop generating interrupt. More...
 
static void GPIO_PinAssertSWInterrupt (GPIO_Type *base, gpio_pin_t ePin)
 Assert software interrupt for one pin which will generate interrupt. More...
 
static void GPIO_PinDeassertSWInterrupt (GPIO_Type *base, gpio_pin_t ePin)
 De-Assert software interrupt for one pin which will stop generating interrupt. More...
 
static void GPIO_PortEnableInterrupts (GPIO_Type *base, uint16_t u16Pins)
 Enable interrupt detection for multiple pins belong to same port. More...
 
static void GPIO_PortDisableInterrupts (GPIO_Type *base, uint16_t u16Pins)
 Disable interrupt detection for multiple pins belong to same port. More...
 
static void GPIO_PinEnableInterrupt (GPIO_Type *base, gpio_pin_t ePin)
 Enable interrupt detection for one pin. More...
 
static void GPIO_PinDisableInterrupt (GPIO_Type *base, gpio_pin_t ePin)
 Disable interrupt detection for one pin. More...
 

GPIO Status Get/Clear Interfaces

static uint16_t GPIO_PortGetInterruptPendingStatusFlags (GPIO_Type *base)
 Get interrupt pending status flags all pins belong to same port. More...
 
static uint16_t GPIO_PinGetInterruptPendingStatusFlags (GPIO_Type *base, gpio_pin_t ePin)
 Get interrupt pending status flags for one pin. More...
 
static uint16_t GPIO_PortGetEdgeDetectedStatusFlags (GPIO_Type *base)
 Get Edge detected status flags for all pins belong to same port. More...
 
static uint8_t GPIO_PinGetEdgeDetectedStatusFlag (GPIO_Type *base, gpio_pin_t ePin)
 Get Edge detected status flags for one pin. More...
 
static uint16_t GPIO_PortClearEdgeDetectedStatusFlags (GPIO_Type *base, uint16_t u16Pins)
 Clear Edge detected status flags for multiple pins belong to same port. More...
 
static uint16_t GPIO_PinClearEdgeDetectedStatusFlags (GPIO_Type *base, gpio_pin_t ePin)
 Clear Edge detected status flags for one pin. More...
 

Data Structure Documentation

struct gpio_config_t

Data Fields

gpio_direction_t eDirection
 GPIO direction, input or output.
 
gpio_peripheral_mode_t eMode
 GPIO mode as peripheral or GPIO.
 
gpio_peripheral_mux_t eMux
 Set the peripheral type if GPIO is configured as peripheral.
 
gpio_output_mode_t eOutMode
 GPIO Open-Drain/Push-Pull output mode. More...
 
gpio_output_slew_rate_t eSlewRate
 GPIO Fast/Slow slew rate output mode. More...
 
gpio_output_level_t eOutLevel
 GPIO Output High/Low level. More...
 
gpio_output_drive_strength_t eDriveStrength
 GPIO output Drive strength High/Low. More...
 
gpio_pull_mode_t ePull
 GPIO Pull resistor mode configuration. More...
 
gpio_interrupt_mode_t eInterruptMode
 GPIO interrupt detection condition configuration. More...
 

Field Documentation

gpio_output_mode_t gpio_config_t::eOutMode
gpio_output_slew_rate_t gpio_config_t::eSlewRate
gpio_output_level_t gpio_config_t::eOutLevel
gpio_output_drive_strength_t gpio_config_t::eDriveStrength
gpio_pull_mode_t gpio_config_t::ePull
gpio_interrupt_mode_t gpio_config_t::eInterruptMode

Macro Definition Documentation

#define FSL_GPIO_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))
#define GPIO_MUX_ENUM_TO_PORT_INDEX (   emux)    (((uint16_t)(emux)&0xF00U) >> 0x08U)

(GPIOA, GPIOB, GPIOC, and so on.) The fields located in bit 8 - bit 11.

#define GPIO_MUX_ENUM_TO_PIN_INDEX (   emux)    (((uint16_t)(emux)&0xF0U) >> 0x04U)

The fields located in bit 4 - bit 7.

#define GPIO_MUX_ENUM_TO_REG_VALUE (   emux)    ((uint16_t)(emux)&0x3U)

The fields located in bit 0 - bit 1.

#define GPIO_MUX_ENUM_TO_PIN_MASK (   emux)
Value:
((GPIO_MUX_ENUM_TO_PIN_INDEX(emux) < 8U) ? (3UL << (GPIO_MUX_ENUM_TO_PIN_INDEX(emux) * 2U)) : \
(3UL << ((GPIO_MUX_ENUM_TO_PIN_INDEX(emux) - 8U) * 2U)))
#define GPIO_MUX_ENUM_TO_PIN_INDEX(emux)
Helper MACRO function to extract Pin Index.
Definition: fsl_gpio.h:242
#define GPIO_MUX_ENUM_TO_PIN_VALUE (   emux)
Value:
((GPIO_MUX_ENUM_TO_PIN_INDEX(emux) < 8U) ? \
#define GPIO_MUX_ENUM_TO_PIN_INDEX(emux)
Helper MACRO function to extract Pin Index.
Definition: fsl_gpio.h:242
#define GPIO_MUX_ENUM_TO_REG_VALUE(emux)
Helper MACRO function to extract Pin mux config register value.
Definition: fsl_gpio.h:245

Enumeration Type Documentation

enum gpio_pin_t
Enumerator
kGPIO_Pin0 

GPIO PORT Pin 0.

kGPIO_Pin1 

GPIO PORT Pin 1.

kGPIO_Pin2 

GPIO PORT Pin 2.

kGPIO_Pin3 

GPIO PORT Pin 3.

kGPIO_Pin4 

GPIO PORT Pin 4.

kGPIO_Pin5 

GPIO PORT Pin 5.

kGPIO_Pin6 

GPIO PORT Pin 6.

kGPIO_Pin7 

GPIO PORT Pin 7.

kGPIO_Pin8 

GPIO PORT Pin 8.

kGPIO_Pin9 

GPIO PORT Pin 9.

kGPIO_Pin10 

GPIO PORT Pin 10.

kGPIO_Pin11 

GPIO PORT Pin 11.

kGPIO_Pin12 

GPIO PORT Pin 12.

kGPIO_Pin13 

GPIO PORT Pin 13.

kGPIO_Pin14 

GPIO PORT Pin 14.

kGPIO_Pin15 

GPIO PORT Pin 15.

Enumerator
kGPIO_ModeGpio 

Set GPIO pin as GPIO Mode.

kGPIO_ModePeripheral 

Set GPIO pin as Peripheral Mode.

Enumerator
kGPIO_DigitalInput 

Set GPIO pin as digital input.

kGPIO_DigitalOutput 

Set GPIO pin as digital output.

Enumerator
kGPIO_PullDown 

Internal pull-down resistor is enabled.

kGPIO_PullUp 

Internal pull-up resistor is enabled.

kGPIO_PullDisable 

Internal pull-up/down resistor is disabled.

Enumerator
kGPIO_OutputOpenDrain 

Open drain output mode.

kGPIO_OutputPushPull 

Push pull output mode.

Enumerator
kGPIO_OutputLow 

Set GPIO pin output low voltage level.

kGPIO_OutputHigh 

Set GPIO pin output high voltage level.

Enumerator
kGPIO_SlewRateFast 

Set GPIO pin output Fast slew rate.

kGPIO_SlewRateSlow 

Set GPIO pin output Slow slew rate.

Enumerator
kGPIO_DriveStrengthLow 

Set GPIO pin output Low-drive strength.

kGPIO_DriveStrengthHigh 

Set GPIO pin output High-drive strength.

Enumerator
kGPIO_InterruptRisingEdge 

Interrupt on rising edge.

kGPIO_InterruptFallingEdge 

Interrupt on falling edge.

kGPIO_InterruptDisable 

Interrupt is disabled.

Function Documentation

void GPIO_PinInit ( GPIO_Type *  base,
gpio_pin_t  ePin,
const gpio_config_t psConfig 
)

To initialize the GPIO, define a pin configuration, as either input or output, in the user file. Then, call the GPIO_PinInit() function.

Note
If GPIO glitch is critical for your application, do not use this API instead using the API in GPIO pin configuration interfaces to do with the glitch during GPIO mode transition in accordance to your board design.

This is function to configure all GPIO Pin configurable fields.

gpio_config_t sConfig = {
.eMode = kGPIO_ModeGpio,
.eOutMode = kGPIO_OutputOpenDrain,
.eSlewRate = kGPIO_SlewRateFast,
.eOutLevel = kGPIO_OutputLow,
.eDriveStrength = kGPIO_DriveStrengthLow,
.eInterruptMode = kGPIO_InterruptDisable,
}
GPIO_PinInit(GPIOA, kGPIO_Pin1, &psConfig);
Parameters
baseGPIO peripheral base pointer (GPIOA, GPIOB, GPIOC, and so on.)
ePinGPIO pin identifier. User enumerator provided by _gpio_pin. Note that not all Pins existed in SoC and user need to check the data sheet.
psConfigGPIO pin configuration pointer
static void GPIO_PinSetPeripheralMode ( GPIO_Type *  base,
gpio_pin_t  ePin,
gpio_peripheral_mode_t  eMode 
)
inlinestatic

Configure GPIO can be configured as Peripheral mode or GPIO mode for one pin.

Parameters
baseGPIO peripheral base pointer
ePinGPIO pin identifier. User enumerator provided by _gpio_pin. Note that not all Pins existed in SoC and user need to check the data sheet.
eModePeripheral mode or GPIO mode for this pin. See _gpio_peripheral_mode
static void GPIO_PinSetPeripheralMux ( gpio_peripheral_mux_t  eMux)
inlinestatic

Configure the MUX of GPIO pins to different peripheral functionality.

Note
User still need to call the GPIO_PinSetPeripheralMode.
Parameters
eMuxGPIO peripheral MUX when configured as peripheral mode. See _gpio_peripheral_mux
static void GPIO_PinSetDirection ( GPIO_Type *  base,
gpio_pin_t  ePin,
gpio_direction_t  eDirection 
)
inlinestatic

Configure the GPIO pin as Input or Output for one pin.

Parameters
baseGPIO peripheral base pointer
ePinGPIO pin identifier. User enumerator provided by _gpio_pin. Note that not all Pins existed in SoC and user need to check the data sheet.
eDirectionDirection of GPIO pin. _gpio_direction
static void GPIO_PinSetOutputMode ( GPIO_Type *  base,
gpio_pin_t  ePin,
gpio_output_mode_t  eOutMode 
)
inlinestatic

Configure GPIO pin output as Push-Pull or Open-Drain. This function applies while pin is configured as output. See _gpio_direction and API GPIO_PinSetDirection.

Parameters
baseGPIO peripheral base pointer
ePinGPIO pin identifier. User enumerator provided by _gpio_pin. Note that not all Pins existed in SoC and user need to check the data sheet.
eOutModePush-Pull/Open-Drain output mode. See _gpio_output_mode.
static void GPIO_PinSetDriveStrength ( GPIO_Type *  base,
gpio_pin_t  ePin,
gpio_output_drive_strength_t  eDriveStrength 
)
inlinestatic

Configure High/Low drive strength when Pin is configured as output. See _gpio_direction and API GPIO_PinSetDirection.

Parameters
baseGPIO peripheral base pointer
ePinGPIO pin identifier. User enumerator provided by _gpio_pin. Note that not all Pins existed in SoC and user need to check the data sheet.
eDriveStrengthHigh/Low driver strength. See _gpio_output_drive_strength
static void GPIO_PinSetSlewRate ( GPIO_Type *  base,
gpio_pin_t  ePin,
gpio_output_slew_rate_t  eSlewRate 
)
inlinestatic

Configure GPIO pin Fast/Slow slew rate when pin is configured as output. See _gpio_direction and API GPIO_PinSetDirection.

Parameters
baseGPIO peripheral base pointer
ePinGPIO pin identifier. User enumerator provided by _gpio_pin. Note that not all Pins existed in SoC and user need to check the data sheet.
eSlewRateFast/Slow slewrate. See _gpio_output_slew_rate
static void GPIO_PinSetPullResistorMode ( GPIO_Type *  base,
gpio_pin_t  ePin,
gpio_pull_mode_t  ePullMode 
)
inlinestatic

Configure Pull resistor for GPIO pin to Disable/Pull-Up/Pull-Down.

Parameters
baseGPIO peripheral base pointer
ePinGPIO pin identifier. User enumerator provided by _gpio_pin. Note that not all Pins existed in SoC and user need to check the data sheet.
ePullModePull Mode as Disable/Pull-Up/Pull-Down. See _gpio_pull_mode
static void GPIO_PinWrite ( GPIO_Type *  base,
gpio_pin_t  ePin,
gpio_output_level_t  eOutput 
)
inlinestatic

Set GPIO Pin as High/Low voltage level on Output.

Parameters
baseGPIO peripheral base pointer
ePinGPIO pin identifier. User enumerator provided by _gpio_pin. Note that not all Pins existed in SoC and user need to check the data sheet.
eOutputOutput as High level or Low Level. See _gpio_output_level.
static void GPIO_PortSet ( GPIO_Type *  base,
uint16_t  u16Pins 
)
inlinestatic

Set GPIO multiple pins output High voltage level without impact other pins. Multiple pins are configured by OR enumerator from _gpio_pin

Parameters
baseGPIO peripheral base pointer
u16PinsGPIO pins which is ORed by _gpio_pin. # kGPIO_Pin0 | kGPIO_Pin3 means Pin 0 and Pin 3.
static void GPIO_PinSet ( GPIO_Type *  base,
gpio_pin_t  ePin 
)
inlinestatic

Output High voltage level for GPIO Pin when configured as Output.

Parameters
baseGPIO peripheral base pointer
ePinGPIO pin identifier. User enumerator provided by _gpio_pin. Note that not all Pins existed in SoC and user need to check the data sheet.
static void GPIO_PortClear ( GPIO_Type *  base,
uint16_t  u16Pins 
)
inlinestatic

Set GPIO multiple pins belong to same PORT output Low voltage level when these pins are configured as output. Multiple pins are configured by ORing enumerators from _gpio_pin

Parameters
baseGPIO peripheral base pointer
u16PinsGPIO pins which is ORed by _gpio_pin. # kGPIO_Pin0 | kGPIO_Pin3 means Pin 0 and Pin 3.
static void GPIO_PinClear ( GPIO_Type *  base,
gpio_pin_t  ePin 
)
inlinestatic

Output Low voltage level for GPIO Pin when configured as Output.

Parameters
baseGPIO peripheral base pointer
ePinGPIO pin identifier. User enumerator provided by _gpio_pin. Note that not all Pins existed in SoC and user need to check the data sheet.
static void GPIO_PortToggle ( GPIO_Type *  base,
uint16_t  u16Pins 
)
inlinestatic

Toggle GPIO multiple pins belong to same PORT when these pins are configured as output. Multiple pins are configured by ORing enumerators from _gpio_pin

Parameters
baseGPIO peripheral base pointer
u16PinsGPIO pins which is ORed by _gpio_pin. # kGPIO_Pin0 | kGPIO_Pin3 means Pin 0 and Pin 3.
static void GPIO_PinToggle ( GPIO_Type *  base,
gpio_pin_t  ePin 
)
inlinestatic

Toggle the GPIO output voltage level when configured as Output.

Note
GPIO peripheral register do not get register to toggle directly. It is implemented by read back the GPIO output level and write to the register with reverted level.
Parameters
baseGPIO peripheral base pointer
ePinGPIO pin identifier. User enumerator provided by _gpio_pin. Note that not all Pins existed in SoC and user need to check the data sheet.
static uint16_t GPIO_PortRead ( GPIO_Type *  base)
inlinestatic

Read High/Low voltage level for multiple GPIO pins from the pin if the pin is configured as input or the data bus. When the device comes out of reset, GPIO pins are configured as inputs with internal pull disabled. As a result, the reset value of this pin is undefined. For different PORT, the available pins number is different. User need use the return value to OR with the _gpio_pin to decide whether that pin is logic high or low.

* if (GPIO_PortRead(GPIOA) & (uint16_t)kGPIO_Pin0)
* {
* //GPIOA Pin 0 is High
* }
* else
* {
* //GPIOA Pin 0 is Low
* }
*
Parameters
baseGPIO peripheral base pointer
u16PinsGPIO pins which is ORed by _gpio_pin. # kGPIO_Pin0 | kGPIO_Pin3 means Pin 0 and Pin 3.
Returns
Voltage level for multiple GPIO pins from the pin or the data bus.
static uint8_t GPIO_PinRead ( GPIO_Type *  base,
gpio_pin_t  ePin 
)
inlinestatic

Read High/Low voltage level from the pin if the pin is configured as input or the data bus.

Note
When the device comes out of reset, GPIO pins are configured as inputs with internal pull disabled. As a result, the reset value of this pin is undefined.
Parameters
baseGPIO peripheral base pointer
ePinGPIO pin identifier. User enumerator provided by _gpio_pin. Note that not all Pins existed in SoC and user need to check the data sheet.
Return values
1Voltage level for one GPIO pin from the pin or the data bus is high.
0Voltage level for one GPIO pin from the pin or the data bus is low.
static uint16_t GPIO_PortReadRawData ( GPIO_Type *  base)
inlinestatic

Read Raw voltage high/low level data from the pins or peripheral bus. Values are not clocked and are subject to change at any time. Read several times to ensure a stable value. The reset value of this register depends on the default PIN state. User need use the return value to OR with the _gpio_pin to decide whether that pin is logic high or low.

* if (GPIO_PortReadRawData(GPIOA) & (uint16_t)kGPIO_Pin0)
* {
* //GPIOA Pin 0 is High
* }
* else
* {
* //GPIOA Pin 0 is Low
* }
*
Parameters
baseGPIO peripheral base pointer
Returns
Voltage high/low level data from the pins or peripheral bus for multiple pins belong to same PORT.
static uint8_t GPIO_PinReadRawData ( GPIO_Type *  base,
gpio_pin_t  ePin 
)
inlinestatic

Read Raw voltage high/low level data from the pins or peripheral bus. Values are not clocked and are subject to change at any time. Read several times to ensure a stable value. The reset value of this register depends on the default PIN state.

Parameters
baseGPIO peripheral base pointer
ePinGPIO pin identifier. User enumerator provided by _gpio_pin. Note that not all Pins existed in SoC and user need to check the data sheet.
Return values
1Raw voltage level data from the pins or peripheral bus is high.
0Raw voltage level data from the pins or peripheral bus is low.
static void GPIO_PinSetInterruptConfig ( GPIO_Type *  base,
gpio_pin_t  ePin,
gpio_interrupt_mode_t  eIntConfig 
)
inlinestatic

Configure GPIO Pin interrupt detection condition

Parameters
baseGPIO peripheral base pointer
ePinGPIO pin identifier. User enumerator provided by _gpio_pin. Note that not all Pins existed in SoC and user need to check the data sheet.
eIntConfigInterrupt detection condition for rising edge/down edge or no detection. See _gpio_interrupt_mode
static void GPIO_PortAssertSWInterrupts ( GPIO_Type *  base,
uint16_t  u16Pins 
)
inlinestatic

This API is only for software testing of a software interrupt capability. When the software interrupt is asserted, an interrupt is generated. The interrupt is generated continually until this software interrupt is de-asserted.

Parameters
baseGPIO peripheral base pointer
u16PinsGPIO pins which is ORed by _gpio_pin. # kGPIO_Pin0 | kGPIO_Pin3 means Pin 0 and Pin 3.
static void GPIO_PortDeassertSWInterrupts ( GPIO_Type *  base,
uint16_t  u16Pins 
)
inlinestatic

This API is only for software testing of a software interrupt capability.

Parameters
baseGPIO peripheral base pointer
u16PinsGPIO pins which is ORed by _gpio_pin. # kGPIO_Pin0 | kGPIO_Pin3 means Pin 0 and Pin 3.
static void GPIO_PinAssertSWInterrupt ( GPIO_Type *  base,
gpio_pin_t  ePin 
)
inlinestatic

This API is only for software testing of a software interrupt capability. When the software interrupt is asserted, an interrupt is generated. The interrupt is generated continually until this software interrupt is de-asserted.

Parameters
baseGPIO peripheral base pointer
ePinGPIO pin identifier. User enumerator provided by _gpio_pin. Note that not all Pins existed in SoC and user need to check the data sheet.
static void GPIO_PinDeassertSWInterrupt ( GPIO_Type *  base,
gpio_pin_t  ePin 
)
inlinestatic

This API is only for software testing of a software interrupt capability.

Parameters
baseGPIO peripheral base pointer
ePinGPIO pin identifier. User enumerator provided by _gpio_pin. Note that not all Pins existed in SoC and user need to check the data sheet.
static void GPIO_PortEnableInterrupts ( GPIO_Type *  base,
uint16_t  u16Pins 
)
inlinestatic

This API is to enable interrupt detection on rising edge or falling edge.

Parameters
baseGPIO peripheral base pointer
u16PinsGPIO pins which is ORed by _gpio_pin. # kGPIO_Pin0 | kGPIO_Pin3 means Pin 0 and Pin 3.
static void GPIO_PortDisableInterrupts ( GPIO_Type *  base,
uint16_t  u16Pins 
)
inlinestatic

This API is to disable interrupt detection on rising edge or falling edge.

Parameters
baseGPIO peripheral base pointer
u16PinsGPIO pins which is ORed by _gpio_pin. # kGPIO_Pin0 | kGPIO_Pin3 means Pin 0 and Pin 3.
static void GPIO_PinEnableInterrupt ( GPIO_Type *  base,
gpio_pin_t  ePin 
)
inlinestatic

This API is to enable interrupt detection on rising edge or falling edge.

Parameters
baseGPIO peripheral base pointer
ePinGPIO pin identifier. User enumerator provided by _gpio_pin. Note that not all Pins existed in SoC and user need to check the data sheet.
static void GPIO_PinDisableInterrupt ( GPIO_Type *  base,
gpio_pin_t  ePin 
)
inlinestatic

This API is to disable interrupt detection on rising edge or falling edge.

Parameters
baseGPIO peripheral base pointer
ePinGPIO pin identifier. User enumerator provided by _gpio_pin. Note that not all Pins existed in SoC and user need to check the data sheet.
static uint16_t GPIO_PortGetInterruptPendingStatusFlags ( GPIO_Type *  base)
inlinestatic

Get interrupt pending status flags for all pins belong to same port. User need to use the _gpio_pin_t to OR with the return value, if the result is not 0, this flag is set. otherwise, this flag is not set.

Note
this flags can only be cleared by calling GPIO_PortClearEdgeDetectedStatusFlag if it is caused by edge detected or by calling GPIO_PortEnableSWInterrupt if it is caused by SW interrupt.
* if (GPIO_PortGetInterruptPendingStatusFlags(GPIOA) & (uint16_t)kGPIO_Pin0)
* {
* //Interrupt occurred on GPIOA Pin 0.
* }
* else
* {
* //No Interrupt on GPIOA Pin 0.
* }
*
Parameters
baseGPIO peripheral base pointer
Returns
Interrupt pending status flags all pins belong to same port.
static uint16_t GPIO_PinGetInterruptPendingStatusFlags ( GPIO_Type *  base,
gpio_pin_t  ePin 
)
inlinestatic

Get interrupt pending status flags for one pin.

Note
this flags can only be cleared by calling GPIO_PortClearEdgeDetectedStatusFlag if it is caused by edge detected or by calling GPIO_PortEnableSWInterrupt if it is caused by SW interrupt.
Parameters
baseGPIO peripheral base pointer
ePinGPIO pin identifier. User enumerator provided by _gpio_pin. Note that not all Pins existed in SoC and user need to check the data sheet.
Return values
1Interrupt occurred.
0No Interrupt.
static uint16_t GPIO_PortGetEdgeDetectedStatusFlags ( GPIO_Type *  base)
inlinestatic

Get edge detected status flags for all pins in the PORT. This status flag can only be detected when interrupt detection is enabled by GPIO_PortEnableInterrupt or GPIO_PinEnableInterrupt.

* if (GPIO_PortGetEdgeDetectedStatusFlags(GPIOA) & (uint16_t)kGPIO_Pin0)
* {
* //An edge detected on GPIOA Pin 0.
* }
* else
* {
* //No edge detected on GPIOA Pin 0.
* }
*
Parameters
baseGPIO peripheral base pointer
Returns
Detected edge status flags for all pins belong to same port.
static uint8_t GPIO_PinGetEdgeDetectedStatusFlag ( GPIO_Type *  base,
gpio_pin_t  ePin 
)
inlinestatic

Get edge detected status flags for one pin. This status flag can only be detected when interrupt detection is enabled by GPIO_PortEnableInterrupt or GPIO_PinEnableInterrupt.

Parameters
baseGPIO peripheral base pointer
ePinGPIO pin identifier. User enumerator provided by _gpio_pin. Note that not all Pins existed in SoC and user need to check the data sheet.
Return values
1An edge detected.
0No edge detected.
static uint16_t GPIO_PortClearEdgeDetectedStatusFlags ( GPIO_Type *  base,
uint16_t  u16Pins 
)
inlinestatic

Clear Edge Detected status flags for multiple pins belong to same port.

Parameters
baseGPIO peripheral base pointer
u16PinsGPIO pins which is ORed by _gpio_pin. # kGPIO_Pin0 | kGPIO_Pin3 means Pin 0 and Pin 3.
static uint16_t GPIO_PinClearEdgeDetectedStatusFlags ( GPIO_Type *  base,
gpio_pin_t  ePin 
)
inlinestatic

Clear Edge Detected status flags for one pin.

Parameters
baseGPIO peripheral base pointer
ePinGPIO pin identifier. User enumerator provided by _gpio_pin. Note that not all Pins existed in SoC and user need to check the data sheet.