PDK API Guide for J721E
GPIO.h File Reference

Introduction

GPIO driver.

============================================================================

The GPIO header file should be included in an application as follows:

Operation

The GPIO module allows you to manage General Purpose I/O pins via simple and portable APIs. GPIO pin behaviour can be configured completely statically, or dynamically defined at runtime.

The application is required to supply a device specific GPIOXXX_Config structure to the module. This structure communicates to the GPIO module how to configure the pins that will be used by the application (See the description of GPIO_PinConfig).

The application is required to call GPIO_init(). This function will initialize all the GPIO pins defined in the GPIO_PinConfig table to the configurations specified. Once that is completed the other APIs can be used to access the pins.

Asserts are used to verify that the driver has been initialized and to validate pin indexes within the various APIs.

See the device specific GPIO header file for configuration details.


Go to the source code of this file.

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...
 

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...
 

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]
 

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...