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

Files

file  fsl_gpio.h
 

Data Structures

struct  gpio_pin_config_t
 The GPIO pin configuration structure. More...
 
struct  gpio_interrupt_config_t
 Configures the interrupt generation condition. More...
 

Enumerations

enum  gpio_pin_direction_t {
  kGPIO_DigitalInput = 0U,
  kGPIO_DigitalOutput = 1U
}
 LPC GPIO direction definition. More...
 
enum  gpio_pin_enable_mode_t {
  kGPIO_PinIntEnableLevel = GPIO_PIN_INT_LEVEL,
  kGPIO_PinIntEnableEdge = GPIO_PIN_INT_EDGE
}
 GPIO Pin Interrupt enable mode. More...
 
enum  gpio_pin_enable_polarity_t {
  kGPIO_PinIntEnableHighOrRise,
  kGPIO_PinIntEnableLowOrFall
}
 GPIO Pin Interrupt enable polarity. More...
 
enum  gpio_interrupt_index_t {
  kGPIO_InterruptA = 0U,
  kGPIO_InterruptB = 1U
}
 LPC GPIO interrupt index definition. More...
 

Functions

static 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 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...
 
static void GPIO_PortToggle (GPIO_Type *base, uint32_t port, uint32_t mask)
 Reverses current output logic of the multiple GPIO pins. More...
 

Driver version

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

GPIO Configuration

void GPIO_PortInit (GPIO_Type *base, uint32_t port)
 Initializes the GPIO peripheral. More...
 
void GPIO_PinInit (GPIO_Type *base, uint32_t port, uint32_t pin, const gpio_pin_config_t *config)
 Initializes a GPIO pin used by the board. More...
 

GPIO Output Operations

static void GPIO_PinWrite (GPIO_Type *base, uint32_t port, uint32_t pin, uint8_t output)
 Sets the output level of the one GPIO pin to the logic 1 or 0. More...
 

GPIO Input Operations

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

Detailed Description

The MCUXpresso SDK provides a peripheral driver for the General Purpose I/O (GPIO) module of MCUXpresso SDK devices.

Function groups

Initialization and deinitialization

The function GPIO_PinInit() initializes the GPIO with specified configuration.

Pin manipulation

The function GPIO_PinWrite() set output state of selected GPIO pin. The function GPIO_PinRead() read input value of selected GPIO pin.

Port manipulation

The function GPIO_PortSet() sets the output level of selected GPIO pins to the logic 1. The function GPIO_PortClear() sets the output level of selected GPIO pins to the logic 0. The function GPIO_PortToggle() reverse the output level of selected GPIO pins. The function GPIO_PortRead() read input value of selected port.

Port masking

The function GPIO_PortMaskedSet() set port mask, only pins masked by 0 will be enabled in following functions. The function GPIO_PortMaskedWrite() sets the state of selected GPIO port, only pins masked by 0 will be affected. The function GPIO_PortMaskedRead() reads the state of selected GPIO port, only pins masked by 0 are enabled for read, pins masked by 1 are read as 0.

Typical use case

Example use of GPIO API. Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/gpio


Data Structure Documentation

struct gpio_pin_config_t

Every pin can only be configured as either output pin or input pin at a time. If configured as a input pin, then leave the outputConfig unused.

Data Fields

gpio_pin_direction_t pinDirection
 GPIO direction, input or output.
 
uint8_t outputLogic
 Set default output logic, no use in input.
 
struct gpio_interrupt_config_t

Macro Definition Documentation

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

Enumeration Type Documentation

Enumerator
kGPIO_DigitalInput 

Set current pin as digital input.

kGPIO_DigitalOutput 

Set current pin as digital output.

Enumerator
kGPIO_PinIntEnableLevel 

Generate Pin Interrupt on level mode.

kGPIO_PinIntEnableEdge 

Generate Pin Interrupt on edge mode.

Enumerator
kGPIO_PinIntEnableHighOrRise 

Generate Pin Interrupt on high level or rising edge.

kGPIO_PinIntEnableLowOrFall 

Generate Pin Interrupt on low level or falling edge.

Enumerator
kGPIO_InterruptA 

Set current pin as interrupt A.

kGPIO_InterruptB 

Set current pin as interrupt B.

Function Documentation

void GPIO_PortInit ( GPIO_Type *  base,
uint32_t  port 
)

This function ungates the GPIO clock.

Parameters
baseGPIO peripheral base pointer.
portGPIO port number.
void GPIO_PinInit ( GPIO_Type *  base,
uint32_t  port,
uint32_t  pin,
const gpio_pin_config_t config 
)

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

This is an example to define an input pin or output pin configuration:

* Define a digital input pin configuration,
* {
* 0,
* }
* Define a digital output pin configuration,
* {
* 0,
* }
*
Parameters
baseGPIO peripheral base pointer(Typically GPIO)
portGPIO port number
pinGPIO pin number
configGPIO pin configuration pointer
static void GPIO_PinWrite ( GPIO_Type *  base,
uint32_t  port,
uint32_t  pin,
uint8_t  output 
)
inlinestatic
Parameters
baseGPIO peripheral base pointer(Typically GPIO)
portGPIO port number
pinGPIO pin number
outputGPIO pin output logic level.
  • 0: corresponding pin output low-logic level.
  • 1: corresponding pin output high-logic level.
static uint32_t GPIO_PinRead ( GPIO_Type *  base,
uint32_t  port,
uint32_t  pin 
)
inlinestatic
Parameters
baseGPIO peripheral base pointer(Typically GPIO)
portGPIO port number
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_PortSet ( GPIO_Type *  base,
uint32_t  port,
uint32_t  mask 
)
inlinestatic
Parameters
baseGPIO peripheral base pointer(Typically GPIO)
portGPIO port number
maskGPIO pin number macro
static void GPIO_PortClear ( GPIO_Type *  base,
uint32_t  port,
uint32_t  mask 
)
inlinestatic
Parameters
baseGPIO peripheral base pointer(Typically GPIO)
portGPIO port number
maskGPIO pin number macro
static void GPIO_PortToggle ( GPIO_Type *  base,
uint32_t  port,
uint32_t  mask 
)
inlinestatic
Parameters
baseGPIO peripheral base pointer(Typically GPIO)
portGPIO port number
maskGPIO pin number macro