PDK API Guide for J721E
GPIO Driver API

Introduction

GPIO driver interface

Files

file  GPIO.h
 GPIO driver.
 

Data Structures

struct  GPIO_FxnTable
 The definition of a GPIO function table that contains the required set of functions to control a specific GPIO driver implementation. More...
 
struct  GPIO_Config
 GPIO Global configuration. More...
 

Functions

void GPIO_clearInt (uint32_t idx)
 Clear a GPIO pin interrupt flag. More...
 
void GPIO_disableInt (uint32_t idx)
 Disable a GPIO pin interrupt. More...
 
void GPIO_enableInt (uint32_t idx)
 Enable a GPIO pin interrupt. More...
 
void GPIO_init (void)
 Initializes the GPIO module. More...
 
uint32_t GPIO_read (uint32_t idx)
 Reads the value of a GPIO pin. More...
 
void GPIO_setCallback (uint32_t idx, GPIO_CallbackFxn callback)
 Bind a callback function to a GPIO pin interrupt. More...
 
void GPIO_setConfig (uint32_t idx, GPIO_PinConfig pinConfig)
 Configure the gpio pin. More...
 
void GPIO_toggle (uint32_t idx)
 Toggles the current state of a GPIO. More...
 
void GPIO_write (uint32_t idx, uint32_t value)
 Writes the value to a GPIO pin. More...
 

Typedefs

typedef uint32_t GPIO_PinConfig
 GPIO pin configuration settings. More...
 
typedef void(* GPIO_CallbackFxn) (void)
 GPIO callback function type. More...
 
typedef void(* GPIO_InitFxn) (void)
 Initializes the GPIO module. More...
 
typedef uint32_t(* GPIO_ReadFxn) (uint32_t idx)
 Reads the value of a GPIO pin. More...
 
typedef void(* GPIO_WriteFxn) (uint32_t idx, uint32_t value)
 Writes the value to a GPIO pin. More...
 
typedef void(* GPIO_clearIntFxn) (uint32_t idx)
 Clear a GPIO pin interrupt flag. More...
 
typedef void(* GPIO_disableIntFxn) (uint32_t idx)
 Disable a GPIO pin interrupt. More...
 
typedef void(* GPIO_enableIntFxn) (uint32_t idx)
 Enable a GPIO pin interrupt. More...
 
typedef void(* GPIO_setCallbackFxn) (uint32_t idx, GPIO_CallbackFxn callback)
 Bind a callback function to a GPIO pin interrupt. More...
 
typedef void(* GPIO_setConfigFxn) (uint32_t idx, GPIO_PinConfig pinConfig)
 Configure the gpio pin. More...
 
typedef void(* GPIO_toggleFxn) (uint32_t idx)
 Toggles the current state of a GPIO. More...
 
typedef GPIO_Config GPIOConfigList[GPIO_MAX_CONFIG_CNT]
 

Macros

#define GPIO_MAX_CONFIG_CNT   (3U)
 

GPIO_PinConfig pin direction configuration macros

#define GPIO_CFG_OUTPUT   (((uint32_t) 0) << GPIO_CFG_IO_LSB) /*! Pin is an output. */
 
#define GPIO_CFG_OUT_STD   (((uint32_t) 0) << GPIO_CFG_IO_LSB) /*! Output pin is not Open Drain */
 
#define GPIO_CFG_OUT_OD_NOPULL   (((uint32_t) 2) << GPIO_CFG_IO_LSB) /*! Output pin is Open Drain */
 
#define GPIO_CFG_OUT_OD_PU   (((uint32_t) 4) << GPIO_CFG_IO_LSB) /*! Output pin is Open Drain w/ pull up */
 
#define GPIO_CFG_OUT_OD_PD   (((uint32_t) 6) << GPIO_CFG_IO_LSB) /*! Output pin is Open Drain w/ pull dn */
 
#define GPIO_CFG_OUT_HIGH   (((uint32_t) 1) << GPIO_CFG_OUT_BIT) /*! Set pin's output to 1. */
 
#define GPIO_CFG_OUT_LOW   (((uint32_t) 0) << GPIO_CFG_OUT_BIT) /*! Set pin's output to 0. */
 
#define GPIO_CFG_OUT_STR_LOW   (((uint32_t) 0) << GPIO_CFG_OUT_STRENGTH_LSB)
 
#define GPIO_CFG_OUT_STR_MED   (((uint32_t) 1) << GPIO_CFG_OUT_STRENGTH_LSB)
 
#define GPIO_CFG_OUT_STR_HIGH   (((uint32_t) 2) << GPIO_CFG_OUT_STRENGTH_LSB)
 
#define GPIO_CFG_INPUT   (((uint32_t) 1) << GPIO_CFG_IO_LSB) /*! Pin is an input. */
 
#define GPIO_CFG_IN_NOPULL   (((uint32_t) 1) << GPIO_CFG_IO_LSB) /*! Input pin has no PU/PD */
 
#define GPIO_CFG_IN_PU   (((uint32_t) 3) << GPIO_CFG_IO_LSB) /*! Input pin has Pullup */
 
#define GPIO_CFG_IN_PD   (((uint32_t) 5) << GPIO_CFG_IO_LSB) /*! Input pin has Pulldown */
 

GPIO_PinConfig pin interrupt configuration macros

#define GPIO_CFG_IN_INT_NONE   (((uint32_t) 0) << GPIO_CFG_INT_LSB) /*! No Interrupt */
 
#define GPIO_CFG_IN_INT_FALLING   (((uint32_t) 1) << GPIO_CFG_INT_LSB) /*! Interrupt on falling edge */
 
#define GPIO_CFG_IN_INT_RISING   (((uint32_t) 2) << GPIO_CFG_INT_LSB) /*! Interrupt on rising edge */
 
#define GPIO_CFG_IN_INT_BOTH_EDGES   (((uint32_t) 3) << GPIO_CFG_INT_LSB) /*! Interrupt on both edges */
 
#define GPIO_CFG_IN_INT_LOW   (((uint32_t) 4) << GPIO_CFG_INT_LSB) /*! Interrupt on low level */
 
#define GPIO_CFG_IN_INT_HIGH   (((uint32_t) 5) << GPIO_CFG_INT_LSB) /*! Interrupt on high level */
 

Special GPIO_PinConfig configuration macros

#define GPIO_CFG_IN_INT_ONLY   (((uint32_t) 1) << 27) /*! configure interrupt only */
 'Or' in this GPIO_PinConfig definition to inform GPIO_setConfig() to only configure the interrupt attributes of a GPIO input pin. More...
 
#define GPIO_DO_NOT_CONFIG   0x7fff0001U /*! Do not configure this Pin */
 Use this GPIO_PinConfig definition to inform GPIO_init() NOT to configure the corresponding pin. More...
 

Macro Definition Documentation

◆ GPIO_CFG_OUTPUT

#define GPIO_CFG_OUTPUT   (((uint32_t) 0) << GPIO_CFG_IO_LSB) /*! Pin is an output. */

◆ GPIO_CFG_OUT_STD

#define GPIO_CFG_OUT_STD   (((uint32_t) 0) << GPIO_CFG_IO_LSB) /*! Output pin is not Open Drain */

◆ GPIO_CFG_OUT_OD_NOPULL

#define GPIO_CFG_OUT_OD_NOPULL   (((uint32_t) 2) << GPIO_CFG_IO_LSB) /*! Output pin is Open Drain */

◆ GPIO_CFG_OUT_OD_PU

#define GPIO_CFG_OUT_OD_PU   (((uint32_t) 4) << GPIO_CFG_IO_LSB) /*! Output pin is Open Drain w/ pull up */

◆ GPIO_CFG_OUT_OD_PD

#define GPIO_CFG_OUT_OD_PD   (((uint32_t) 6) << GPIO_CFG_IO_LSB) /*! Output pin is Open Drain w/ pull dn */

◆ GPIO_CFG_OUT_HIGH

#define GPIO_CFG_OUT_HIGH   (((uint32_t) 1) << GPIO_CFG_OUT_BIT) /*! Set pin's output to 1. */

◆ GPIO_CFG_OUT_LOW

#define GPIO_CFG_OUT_LOW   (((uint32_t) 0) << GPIO_CFG_OUT_BIT) /*! Set pin's output to 0. */

◆ GPIO_CFG_OUT_STR_LOW

#define GPIO_CFG_OUT_STR_LOW   (((uint32_t) 0) << GPIO_CFG_OUT_STRENGTH_LSB)

◆ GPIO_CFG_OUT_STR_MED

#define GPIO_CFG_OUT_STR_MED   (((uint32_t) 1) << GPIO_CFG_OUT_STRENGTH_LSB)

◆ GPIO_CFG_OUT_STR_HIGH

#define GPIO_CFG_OUT_STR_HIGH   (((uint32_t) 2) << GPIO_CFG_OUT_STRENGTH_LSB)

◆ GPIO_CFG_INPUT

#define GPIO_CFG_INPUT   (((uint32_t) 1) << GPIO_CFG_IO_LSB) /*! Pin is an input. */

◆ GPIO_CFG_IN_NOPULL

#define GPIO_CFG_IN_NOPULL   (((uint32_t) 1) << GPIO_CFG_IO_LSB) /*! Input pin has no PU/PD */

◆ GPIO_CFG_IN_PU

#define GPIO_CFG_IN_PU   (((uint32_t) 3) << GPIO_CFG_IO_LSB) /*! Input pin has Pullup */

◆ GPIO_CFG_IN_PD

#define GPIO_CFG_IN_PD   (((uint32_t) 5) << GPIO_CFG_IO_LSB) /*! Input pin has Pulldown */

◆ GPIO_CFG_IN_INT_NONE

#define GPIO_CFG_IN_INT_NONE   (((uint32_t) 0) << GPIO_CFG_INT_LSB) /*! No Interrupt */

◆ GPIO_CFG_IN_INT_FALLING

#define GPIO_CFG_IN_INT_FALLING   (((uint32_t) 1) << GPIO_CFG_INT_LSB) /*! Interrupt on falling edge */

◆ GPIO_CFG_IN_INT_RISING

#define GPIO_CFG_IN_INT_RISING   (((uint32_t) 2) << GPIO_CFG_INT_LSB) /*! Interrupt on rising edge */

◆ GPIO_CFG_IN_INT_BOTH_EDGES

#define GPIO_CFG_IN_INT_BOTH_EDGES   (((uint32_t) 3) << GPIO_CFG_INT_LSB) /*! Interrupt on both edges */

◆ GPIO_CFG_IN_INT_LOW

#define GPIO_CFG_IN_INT_LOW   (((uint32_t) 4) << GPIO_CFG_INT_LSB) /*! Interrupt on low level */

◆ GPIO_CFG_IN_INT_HIGH

#define GPIO_CFG_IN_INT_HIGH   (((uint32_t) 5) << GPIO_CFG_INT_LSB) /*! Interrupt on high level */

◆ GPIO_CFG_IN_INT_ONLY

#define GPIO_CFG_IN_INT_ONLY   (((uint32_t) 1) << 27) /*! configure interrupt only */

'Or' in this GPIO_PinConfig definition to inform GPIO_setConfig() to only configure the interrupt attributes of a GPIO input pin.

◆ GPIO_DO_NOT_CONFIG

#define GPIO_DO_NOT_CONFIG   0x7fff0001U /*! Do not configure this Pin */

Use this GPIO_PinConfig definition to inform GPIO_init() NOT to configure the corresponding pin.

◆ GPIO_MAX_CONFIG_CNT

#define GPIO_MAX_CONFIG_CNT   (3U)

Typedef Documentation

◆ GPIO_PinConfig

typedef uint32_t GPIO_PinConfig

GPIO pin configuration settings.

The upper 16 bits of the 32 bit PinConfig is reserved for pin configuration settings.

The lower 16 bits are reserved for device-specific port/pin identifications

◆ GPIO_CallbackFxn

typedef void(* GPIO_CallbackFxn) (void)

GPIO callback function type.

◆ GPIO_InitFxn

typedef void(* GPIO_InitFxn) (void)

Initializes the GPIO module.

◆ GPIO_ReadFxn

typedef uint32_t(* GPIO_ReadFxn) (uint32_t idx)

Reads the value of a GPIO pin.

◆ GPIO_WriteFxn

typedef void(* GPIO_WriteFxn) (uint32_t idx, uint32_t value)

Writes the value to a GPIO pin.

◆ GPIO_clearIntFxn

typedef void(* GPIO_clearIntFxn) (uint32_t idx)

Clear a GPIO pin interrupt flag.

◆ GPIO_disableIntFxn

typedef void(* GPIO_disableIntFxn) (uint32_t idx)

Disable a GPIO pin interrupt.

◆ GPIO_enableIntFxn

typedef void(* GPIO_enableIntFxn) (uint32_t idx)

Enable a GPIO pin interrupt.

◆ GPIO_setCallbackFxn

typedef void(* GPIO_setCallbackFxn) (uint32_t idx, GPIO_CallbackFxn callback)

Bind a callback function to a GPIO pin interrupt.

◆ GPIO_setConfigFxn

typedef void(* GPIO_setConfigFxn) (uint32_t idx, GPIO_PinConfig pinConfig)

Configure the gpio pin.

◆ GPIO_toggleFxn

typedef void(* GPIO_toggleFxn) (uint32_t idx)

Toggles the current state of a GPIO.

Parameters
idxGPIO index

◆ GPIOConfigList

typedef GPIO_Config GPIOConfigList[GPIO_MAX_CONFIG_CNT]

Function Documentation

◆ GPIO_clearInt()

void GPIO_clearInt ( uint32_t  idx)

Clear a GPIO pin interrupt flag.

Clears the GPIO interrupt for the specified index.

Note: It is not necessary to call this API within a callback assigned to a pin.

Parameters
idxGPIO index

◆ GPIO_disableInt()

void GPIO_disableInt ( uint32_t  idx)

Disable a GPIO pin interrupt.

Disables interrupts for the specified GPIO index.

Parameters
idxGPIO index

◆ GPIO_enableInt()

void GPIO_enableInt ( uint32_t  idx)

Enable a GPIO pin interrupt.

Enables GPIO interrupts for the selected index to occur.

Note: Prior to enabling a GPIO pin interrupt, make sure that a corresponding callback function has been provided. Use the GPIO_setCallback() API for this purpose at runtime. Alternatively, the callback function can be statically configured in the GPIO_CallbackFxn array provided.

Parameters
idxGPIO index

◆ GPIO_init()

void GPIO_init ( void  )

Initializes the GPIO module.

The pins defined in the application-provided GPIOXXX_config structure are initialized accordingly.

Precondition
The GPIO_config structure must exist and be persistent before this function can be called. This function must also be called before any other GPIO driver APIs.

◆ GPIO_read()

uint32_t GPIO_read ( uint32_t  idx)

Reads the value of a GPIO pin.

The value returned will either be zero or one depending on the state of the pin.

Parameters
idxGPIO index
Returns
0 or 1, depending on the state of the pin.

◆ GPIO_setCallback()

void GPIO_setCallback ( uint32_t  idx,
GPIO_CallbackFxn  callback 
)

Bind a callback function to a GPIO pin interrupt.

Associate a callback function with a particular GPIO pin interrupt.

Callbacks can be changed at any time, making it easy to switch between efficient, state-specific interrupt handlers.

Note: The callback function is called within the context of an interrupt handler.

Note: This API does not enable the GPIO pin interrupt. Use GPIO_enableInt() and GPIO_disableInt() to enable and disable the pin interrupt as necessary.

Note: it is not necessary to call GPIO_clearInt() within a callback. That operation is performed internally before the callback is invoked.

Parameters
idxGPIO index
callbackaddress of the callback function

◆ GPIO_setConfig()

void GPIO_setConfig ( uint32_t  idx,
GPIO_PinConfig  pinConfig 
)

Configure the gpio pin.

Dynamically configure a gpio pin to a device specific setting. For many applications, the pin configurations provided in the static GPIO_PinConfig array is sufficient.

For input pins with interrupt configurations, a corresponding interrupt object will be created as needed.

Parameters
idxGPIO index
pinConfigdevice specific pin configuration settings

◆ GPIO_toggle()

void GPIO_toggle ( uint32_t  idx)

Toggles the current state of a GPIO.

Parameters
idxGPIO index

◆ GPIO_write()

void GPIO_write ( uint32_t  idx,
uint32_t  value 
)

Writes the value to a GPIO pin.

Parameters
idxGPIO index
valuemust be either 0 or 1