AM273x MCU+ SDK  08.04.00

Introduction

This module contains APIs to program and use the GPIO module.

Files

file  gpio/v1/gpio.h
 GPIO Driver API/interface file.
 

Functions

void GPIO_moduleEnable (uint32_t baseAddr)
 This API performs the module enable of the GPIO module. More...
 
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. More...
 
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. More...
 
int32_t GPIO_enableInterrupt (uint32_t baseAddr, uint32_t pinNum)
 The function is used to enable the interrupt on the GPIO Pin. More...
 
int32_t GPIO_disableInterrupt (uint32_t baseAddr, uint32_t pinNum)
 The function is used to disable the interrupt on the GPIO Pin. More...
 
int32_t GPIO_clearInterrupt (uint32_t baseAddr, uint32_t pinNum)
 The function is used to clear the interrupt on the GPIO Pin. More...
 
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. More...
 
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 cycle through all the pending interrupts before the processing of the interrupt is over. More...
 
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. More...
 
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. More...
 
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. More...
 
void GPIO_pinWriteLow (uint32_t baseAddr, uint32_t pinNum)
 The function is used to write logic LOW state to a specific GPIO Port/Pin. More...
 
void GPIO_setOpenDrainStatus (uint32_t baseAddr, uint32_t pinNum, uint32_t openDrainStatus)
 The function is used to enable/disable open drain functionality for a specific GPIO Port/Pin. This function is applicable for GPIO pins which are configured as output. More...
 

Macros

#define GPIO_MAX_PORT   (8U)
 This is the maximum number of ports. More...
 
#define GPIO_MAX_INTERRUPT_PORT   (4U)
 This is the maximum number of interrupt ports which can be supported. Only Ports A, B, C and D are capable of interrupts. More...
 
#define GPIO_MAX_PINS_PER_PORT   (8U)
 This is the maximum number of pins per GPIO port This is a system limit on the GPIO IP Block. More...
 
#define GPIO_MAX_PINS   (GPIO_MAX_PORT * GPIO_MAX_PINS_PER_PORT)
 Maximum number of pins
More...
 
#define GPIO_MAX_INTERRUPT   (GPIO_MAX_INTERRUPT_PORT * GPIO_MAX_PINS_PER_PORT)
 This is the maximum number of interrupts which can be supported. Only Ports A, B, C and D are capable of interrupts. Also since each port can have a maximum of 8 pins this is the maximum number of interrupts which can be supported. More...
 
#define GPIO_GET_PIN_OFFSET(pinNum)   (((uint32_t)pinNum) % (GPIO_MAX_PORT * GPIO_MAX_PINS_PER_PORT))
 Returns the GPIO pin offset based on pin number. More...
 
#define GPIO_GET_PORT_NUM(pinNum)   ((GPIO_GET_PIN_OFFSET(pinNum)) / GPIO_MAX_PINS_PER_PORT)
 Returns the GPIO port number based on pin number. More...
 
#define GPIO_GET_PIN_INDEX(pinNum)   ((GPIO_GET_PIN_OFFSET(pinNum)) % GPIO_MAX_PINS_PER_PORT)
 Returns the pin Index based on pin number. More...
 

GPIO Pin Value

#define GPIO_PIN_LOW   (0U)
 GPIO pin is at logic low. More...
 
#define GPIO_PIN_HIGH   (1U)
 GPIO pin is at logic high. More...
 

GPIO Direction

#define GPIO_DIRECTION_OUTPUT   (1U)
 Set GPIO direction as output. More...
 
#define GPIO_DIRECTION_INPUT   (0U)
 Set GPIO direction as input. More...
 

GPIO OpenDrain

#define GPIO_OPEN_DRAIN_ENABLE   (1U)
 GPIO OpenDrain Enable. More...
 
#define GPIO_OPEN_DRAIN_DISABLE   (0U)
 GPIO OpenDrain Disable. More...
 

GPIO Trigger Type

#define GPIO_TRIG_TYPE_NONE   (0U)
 No interrupt request on either rising or falling edges on the pin. More...
 
#define GPIO_TRIG_TYPE_RISE_EDGE   (1U)
 Interrupt request on occurrence of a rising edge on the input pin. More...
 
#define GPIO_TRIG_TYPE_FALL_EDGE   (2U)
 Interrupt request on occurrence of a falling edge on the input pin. More...
 
#define GPIO_TRIG_TYPE_BOTH_EDGE   (3U)
 Interrupt request on occurrence of a rising/falling edge on the input pin. More...
 

GPIO Interrupt Level

#define GPIO_INTR_LEVEL_LOW   (0U)
 GPIO low interrupt level. More...
 
#define GPIO_INTR_LEVEL_HIGH   (1U)
 GPIO high interrupt level. More...
 

Macro Definition Documentation

◆ GPIO_PIN_LOW

#define GPIO_PIN_LOW   (0U)

GPIO pin is at logic low.

◆ GPIO_PIN_HIGH

#define GPIO_PIN_HIGH   (1U)

GPIO pin is at logic high.

◆ GPIO_DIRECTION_OUTPUT

#define GPIO_DIRECTION_OUTPUT   (1U)

Set GPIO direction as output.

◆ GPIO_DIRECTION_INPUT

#define GPIO_DIRECTION_INPUT   (0U)

Set GPIO direction as input.

◆ GPIO_OPEN_DRAIN_ENABLE

#define GPIO_OPEN_DRAIN_ENABLE   (1U)

GPIO OpenDrain Enable.

◆ GPIO_OPEN_DRAIN_DISABLE

#define GPIO_OPEN_DRAIN_DISABLE   (0U)

GPIO OpenDrain Disable.

◆ GPIO_TRIG_TYPE_NONE

#define GPIO_TRIG_TYPE_NONE   (0U)

No interrupt request on either rising or falling edges on the pin.

◆ GPIO_TRIG_TYPE_RISE_EDGE

#define GPIO_TRIG_TYPE_RISE_EDGE   (1U)

Interrupt request on occurrence of a rising edge on the input pin.

◆ GPIO_TRIG_TYPE_FALL_EDGE

#define GPIO_TRIG_TYPE_FALL_EDGE   (2U)

Interrupt request on occurrence of a falling edge on the input pin.

◆ GPIO_TRIG_TYPE_BOTH_EDGE

#define GPIO_TRIG_TYPE_BOTH_EDGE   (3U)

Interrupt request on occurrence of a rising/falling edge on the input pin.

◆ GPIO_INTR_LEVEL_LOW

#define GPIO_INTR_LEVEL_LOW   (0U)

GPIO low interrupt level.

◆ GPIO_INTR_LEVEL_HIGH

#define GPIO_INTR_LEVEL_HIGH   (1U)

GPIO high interrupt level.

◆ GPIO_MAX_PORT

#define GPIO_MAX_PORT   (8U)

This is the maximum number of ports.

◆ GPIO_MAX_INTERRUPT_PORT

#define GPIO_MAX_INTERRUPT_PORT   (4U)

This is the maximum number of interrupt ports which can be supported. Only Ports A, B, C and D are capable of interrupts.

◆ GPIO_MAX_PINS_PER_PORT

#define GPIO_MAX_PINS_PER_PORT   (8U)

This is the maximum number of pins per GPIO port This is a system limit on the GPIO IP Block.

◆ GPIO_MAX_PINS

#define GPIO_MAX_PINS   (GPIO_MAX_PORT * GPIO_MAX_PINS_PER_PORT)

Maximum number of pins

◆ GPIO_MAX_INTERRUPT

#define GPIO_MAX_INTERRUPT   (GPIO_MAX_INTERRUPT_PORT * GPIO_MAX_PINS_PER_PORT)

This is the maximum number of interrupts which can be supported. Only Ports A, B, C and D are capable of interrupts. Also since each port can have a maximum of 8 pins this is the maximum number of interrupts which can be supported.

◆ GPIO_GET_PIN_OFFSET

#define GPIO_GET_PIN_OFFSET (   pinNum)    (((uint32_t)pinNum) % (GPIO_MAX_PORT * GPIO_MAX_PINS_PER_PORT))

Returns the GPIO pin offset based on pin number.

◆ GPIO_GET_PORT_NUM

#define GPIO_GET_PORT_NUM (   pinNum)    ((GPIO_GET_PIN_OFFSET(pinNum)) / GPIO_MAX_PINS_PER_PORT)

Returns the GPIO port number based on pin number.

◆ GPIO_GET_PIN_INDEX

#define GPIO_GET_PIN_INDEX (   pinNum)    ((GPIO_GET_PIN_OFFSET(pinNum)) % GPIO_MAX_PINS_PER_PORT)

Returns the pin Index based on pin number.

Function Documentation

◆ GPIO_moduleEnable()

void GPIO_moduleEnable ( uint32_t  baseAddr)

This API performs the module enable of the GPIO module.

Parameters
baseAddrGPIO base address

◆ GPIO_ignoreOrHonorPolarity()

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.

Parameters
baseAddrGPIO base address
pinNumGPIO Pin number associated with the port 'pinNum' can take one of the following values: (0 <= pinNum <= GPIO_MAX_PINS - 1)
polLevelpolarity of the interrupt to be triggered 'polLevel' can take one of the following values following enum:
Returns
SystemP_SUCCESS if PortNum is within range; else error on failure

◆ GPIO_setTrigType()

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.

Parameters
baseAddrGPIO base address
pinNumGPIO Pin number associated with the port 'pinNum' can take one of the following values: (0 <= pinNum <= GPIO_MAX_PINS - 1)
polLevelpolarity of the interrupt to be triggered 'polLevel' can take one of the following values following enum:
Returns
SystemP_SUCCESS if PortNum is within range; else error on failure

◆ GPIO_enableInterrupt()

int32_t GPIO_enableInterrupt ( uint32_t  baseAddr,
uint32_t  pinNum 
)

The function is used to enable the interrupt on the GPIO Pin.

Parameters
baseAddrGPIO base address
pinNumGPIO Pin number associated with the port 'pinNum' can take one of the following values: (0 <= pinNum <= GPIO_MAX_PINS - 1)
Returns
SystemP_SUCCESS if PortNum is within range; else error on failure

◆ GPIO_disableInterrupt()

int32_t GPIO_disableInterrupt ( uint32_t  baseAddr,
uint32_t  pinNum 
)

The function is used to disable the interrupt on the GPIO Pin.

Parameters
baseAddrGPIO base address
pinNumGPIO Pin number associated with the port 'pinNum' can take one of the following values: (0 <= pinNum <= GPIO_MAX_PINS - 1)
Returns
SystemP_SUCCESS if PortNum is within range; else error on failure

◆ GPIO_clearInterrupt()

int32_t GPIO_clearInterrupt ( uint32_t  baseAddr,
uint32_t  pinNum 
)

The function is used to clear the interrupt on the GPIO Pin.

Parameters
baseAddrGPIO base address
pinNumGPIO Pin number associated with the port 'pinNum' can take one of the following values: (0 <= pinNum <= GPIO_MAX_PINS - 1)
Returns
SystemP_SUCCESS if PortNum is within range; else error on failure

◆ GPIO_markHighLowLevelInterrupt()

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.

Parameters
baseAddrGPIO base address
pinNumGPIO Pin number associated with the port 'pinNum' can take one of the following values: (0 <= pinNum <= GPIO_MAX_PINS - 1)
interruptLevelGPIO Interrupt priority 'interruptLevel' can take one of the following values following enum:
Returns
SystemP_SUCCESS if PortNum is within range; else error on failure

◆ GPIO_getHighLowLevelPendingInterrupt()

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 cycle through all the pending interrupts before the processing of the interrupt is over.

Parameters
baseAddrGPIO base address
interruptLevelGPIO Interrupt priority 'interruptLevel' can take one of the following values following enum:
Returns
pending interrupr number Zero - No pending interrupt Non Zero - Highest Pending Interrupt

◆ GPIO_setDirMode()

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.

Parameters
baseAddrGPIO base address
pinNumGPIO Pin number associated with the port 'pinNum' can take one of the following values: (0 <= pinNum <= GPIO_MAX_PINS-1)
pinDirPin Direction set This can take one of the value from the following enum:

◆ GPIO_pinRead()

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.

Parameters
baseAddrGPIO base address
pinNumGPIO Pin number associated with the port 'pinNum' can take one of the following values: (0 <= pinNum <= GPIO_MAX_PINS-1)
Returns
GPIO_PinValue_t

◆ GPIO_pinWriteHigh()

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.

Parameters
baseAddrGPIO base address
pinNumGPIO Pin number associated with the port 'pinNum' can take one of the following values: (0 <= pinNum <= GPIO_MAX_PINS-1)

◆ GPIO_pinWriteLow()

void GPIO_pinWriteLow ( uint32_t  baseAddr,
uint32_t  pinNum 
)

The function is used to write logic LOW state to a specific GPIO Port/Pin.

Parameters
baseAddrGPIO base address
pinNumGPIO Pin number associated with the port 'pin' can take one of the following values: (0 <= pin <= GPIO_MAX_PINS-1)

◆ GPIO_setOpenDrainStatus()

void GPIO_setOpenDrainStatus ( uint32_t  baseAddr,
uint32_t  pinNum,
uint32_t  openDrainStatus 
)

The function is used to enable/disable open drain functionality for a specific GPIO Port/Pin. This function is applicable for GPIO pins which are configured as output.

Parameters
baseAddrGPIO base address
pinNumGPIO Pin number associated with the port 'pinNum' can take one of the following values: (0 <= pinNum <= GPIO_MAX_PINS-1)
openDrainStatusSet open drain status This can take one of the value from the following enum: