PDK API Guide for J721E
|
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... | |
#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 */ |
#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 */ |
#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.
#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.
#define GPIO_MAX_CONFIG_CNT (3U) |
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
typedef void(* GPIO_CallbackFxn) (void) |
GPIO callback function type.
typedef void(* GPIO_InitFxn) (void) |
Initializes the GPIO module.
typedef uint32_t(* GPIO_ReadFxn) (uint32_t idx) |
Reads the value of a GPIO pin.
typedef void(* GPIO_WriteFxn) (uint32_t idx, uint32_t value) |
Writes the value to a GPIO pin.
typedef void(* GPIO_clearIntFxn) (uint32_t idx) |
Clear a GPIO pin interrupt flag.
typedef void(* GPIO_disableIntFxn) (uint32_t idx) |
Disable a GPIO pin interrupt.
typedef void(* GPIO_enableIntFxn) (uint32_t idx) |
Enable a GPIO pin interrupt.
typedef void(* GPIO_setCallbackFxn) (uint32_t idx, GPIO_CallbackFxn callback) |
Bind a callback function to a GPIO pin interrupt.
typedef void(* GPIO_setConfigFxn) (uint32_t idx, GPIO_PinConfig pinConfig) |
Configure the gpio pin.
typedef void(* GPIO_toggleFxn) (uint32_t idx) |
Toggles the current state of a GPIO.
idx | GPIO index |
typedef GPIO_Config GPIOConfigList[GPIO_MAX_CONFIG_CNT] |
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.
idx | GPIO index |
void GPIO_disableInt | ( | uint32_t | idx | ) |
Disable a GPIO pin interrupt.
Disables interrupts for the specified GPIO index.
idx | GPIO index |
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.
idx | GPIO index |
void GPIO_init | ( | void | ) |
Initializes the GPIO module.
The pins defined in the application-provided GPIOXXX_config structure are initialized accordingly.
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.
idx | GPIO index |
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.
idx | GPIO index |
callback | address of the callback function |
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.
idx | GPIO index |
pinConfig | device specific pin configuration settings |
void GPIO_toggle | ( | uint32_t | idx | ) |
Toggles the current state of a GPIO.
idx | GPIO index |
void GPIO_write | ( | uint32_t | idx, |
uint32_t | value | ||
) |
Writes the value to a GPIO pin.
idx | GPIO index |
value | must be either 0 or 1 |