AM273x MCU+ SDK
09.02.00
The General-Purpose Input/Output (GPIO) driver provides API to configure general-purpose pins as either inputs or outputs. It also provided API to configure GPIO to produce host CPU interrupts and DMA synchronization events in different interrupt/event generation modes.
Features Supported
Supports up to 8-bit ports for a total of 64 GPIO
Supports up to 32 GPIO's which can be configured as interrupt
Supports up to 32 interrupt generating GPIO's.
Set/clear functionality
SysConfig Features
Note It is strongly recommend to use SysConfig where it is available instead of using direct SW API calls. This will help simplify the SW application and also catch common mistakes early in the development cycle.
Set pin direction: input or output
Set interrupt trigger type
Set openDrain: enable or disable
Set interrupt level: high or low
Configuring pinmux based on selected pin
Features NOT Supported
NA
Important Usage Guidelines
Note: Not all GPIO pins, are present in a particular device. Refer device TRM for actual GPIO instances and pins supported
Example Usage
Include the below file to access the APIs
GPIO configuration as output
uint32_t pinNum = gGpioPinNum, pinValue;
{
}
GPIO configuration as input
uint32_t pinNum = gGpioPinNum, pinValue;
{
}
else
{
}
GPIO configuration for interrupt
static void GPIO_portIsrFxn(
void *
args )
{
uint32_t pinNum = (uint32_t)
args ;
uint32_t pendingInterrupt;
if (pendingInterrupt )
{
}
}
void gpio_interrupt_init(void )
{
int32_t retVal;
uint32_t pinNum = gGpioIntrPinNum;
hwiPrms.
intNum = gGpioIntrNum;
hwiPrms.
args = (
void *) pinNum;
{
}
}
void gpio_interrupt_deinit(void )
{
uint32_t pinNum = gGpioIntrPinNum, pendingInterrupt;
(void)pendingInterrupt;
}
API
APIs for GPIO
void * args
Definition: hsmclient_msg.h:4
void HwiP_destruct(HwiP_Object *obj)
Cleanup, delete, destruct a Hwi object.
Parameters passed during HwiP_construct.
Definition: HwiP.h:74
void GPIO_pinWriteLow(uint32_t baseAddr, uint32_t pinNum)
The function is used to write logic LOW state to a specific GPIO Port/Pin.
void ClockP_sleep(uint32_t sec)
Sleep for user specified seconds.
#define GPIO_PIN_LOW
GPIO pin is at logic low.
Definition: gpio/v1/gpio.h:78
int32_t GPIO_disableInterrupt(uint32_t baseAddr, uint32_t pinNum)
The function is used to disable the interrupt on the GPIO Pin.
int32_t HwiP_construct(HwiP_Object *obj, HwiP_Params *params)
Create a Hwi object.
int32_t GPIO_clearInterrupt(uint32_t baseAddr, uint32_t pinNum)
The function is used to clear the interrupt on the GPIO Pin.
#define GPIO_DIRECTION_INPUT
Set GPIO direction as input.
Definition: gpio/v1/gpio.h:91
void GPIO_pinWriteHigh(uint32_t baseAddr, uint32_t pinNum)
The function is used to write logic HIGH state to a to a specific GPIO Pin.
#define GPIO_PIN_HIGH
GPIO pin is at logic high.
Definition: gpio/v1/gpio.h:80
void HwiP_Params_init(HwiP_Params *params)
Set default values to HwiP_Params.
#define DebugP_log(format,...)
Function to log a string to the enabled console.
Definition: DebugP.h:225
#define GPIO_TRIG_TYPE_RISE_EDGE
Interrupt request on occurrence of a rising edge on the input pin.
Definition: gpio/v1/gpio.h:113
void GPIO_setDirMode(uint32_t baseAddr, uint32_t pinNum, uint32_t pinDir)
The function is used to set the output data direction associated with a GPIO Pin.
int32_t GPIO_enableInterrupt(uint32_t baseAddr, uint32_t pinNum)
The function is used to enable the interrupt on the GPIO Pin.
#define SystemP_SUCCESS
Return status when the API execution was successful.
Definition: SystemP.h:56
#define GPIO_DIRECTION_OUTPUT
Set GPIO direction as output.
Definition: gpio/v1/gpio.h:89
int32_t GPIO_setTrigType(uint32_t baseAddr, uint32_t pinNum, uint32_t polLevel)
The function is used to configure the GPIO Pin to control the interrupt polarity.
int32_t GPIO_ignoreOrHonorPolarity(uint32_t baseAddr, uint32_t pinNum, uint32_t polLevel)
The function is used to configure the GPIO Pin to ignore or honor polarity.
int32_t GPIO_markHighLowLevelInterrupt(uint32_t baseAddr, uint32_t pinNum, uint32_t interruptLevel)
The function is used to mark the interrupt as high level or low level for the specific GPIO Pin.
#define GPIO_INTR_LEVEL_LOW
GPIO low interrupt level.
Definition: gpio/v1/gpio.h:126
HwiP_FxnCallback callback
Definition: HwiP.h:77
void * args
Definition: HwiP.h:78
#define DebugP_assert(expression)
Function to call for assert check.
Definition: DebugP.h:177
uint32_t intNum
Definition: HwiP.h:76
#define GPIO_TRIG_TYPE_NONE
No interrupt request on either rising or falling edges on the pin.
Definition: gpio/v1/gpio.h:111
uint32_t GPIO_getHighLowLevelPendingInterrupt(uint32_t baseAddr, uint32_t interruptLevel)
The function is used to get the high level or low level interrupt pending. The driver will need to cy...
uint32_t GPIO_pinRead(uint32_t baseAddr, uint32_t pinNum)
The function is used to get the data input for a specific GPIO Port/Pin.