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... | |
#define GPIO_PIN_LOW (0U) |
GPIO pin is at logic low.
#define GPIO_PIN_HIGH (1U) |
GPIO pin is at logic high.
#define GPIO_DIRECTION_OUTPUT (1U) |
Set GPIO direction as output.
#define GPIO_DIRECTION_INPUT (0U) |
Set GPIO direction as input.
#define GPIO_OPEN_DRAIN_ENABLE (1U) |
GPIO OpenDrain Enable.
#define GPIO_OPEN_DRAIN_DISABLE (0U) |
GPIO OpenDrain Disable.
#define GPIO_TRIG_TYPE_NONE (0U) |
No interrupt request on either rising or falling edges on the pin.
#define GPIO_TRIG_TYPE_RISE_EDGE (1U) |
Interrupt request on occurrence of a rising edge on the input pin.
#define GPIO_TRIG_TYPE_FALL_EDGE (2U) |
Interrupt request on occurrence of a falling edge on the input pin.
#define GPIO_TRIG_TYPE_BOTH_EDGE (3U) |
Interrupt request on occurrence of a rising/falling edge on the input pin.
#define GPIO_INTR_LEVEL_LOW (0U) |
GPIO low interrupt level.
#define GPIO_INTR_LEVEL_HIGH (1U) |
GPIO high interrupt level.
#define GPIO_MAX_PORT (8U) |
This is the maximum number of ports.
#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.
#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.
#define GPIO_MAX_PINS (GPIO_MAX_PORT * GPIO_MAX_PINS_PER_PORT) |
Maximum number of pins
#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.
#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.
#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.
#define GPIO_GET_PIN_INDEX | ( | pinNum | ) | ((GPIO_GET_PIN_OFFSET(pinNum)) % GPIO_MAX_PINS_PER_PORT) |
Returns the pin Index based on pin number.
void GPIO_moduleEnable | ( | uint32_t | baseAddr | ) |
This API performs the module enable of the GPIO module.
baseAddr | GPIO base address |
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.
baseAddr | GPIO base address |
pinNum | GPIO Pin number associated with the port 'pinNum' can take one of the following values: (0 <= pinNum <= GPIO_MAX_PINS - 1) |
polLevel | polarity of the interrupt to be triggered 'polLevel' can take one of the following values following enum: |
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.
baseAddr | GPIO base address |
pinNum | GPIO Pin number associated with the port 'pinNum' can take one of the following values: (0 <= pinNum <= GPIO_MAX_PINS - 1) |
polLevel | polarity of the interrupt to be triggered 'polLevel' can take one of the following values following enum: |
int32_t GPIO_enableInterrupt | ( | uint32_t | baseAddr, |
uint32_t | pinNum | ||
) |
The function is used to enable the interrupt on the GPIO Pin.
baseAddr | GPIO base address |
pinNum | GPIO Pin number associated with the port 'pinNum' can take one of the following values: (0 <= pinNum <= GPIO_MAX_PINS - 1) |
int32_t GPIO_disableInterrupt | ( | uint32_t | baseAddr, |
uint32_t | pinNum | ||
) |
The function is used to disable the interrupt on the GPIO Pin.
baseAddr | GPIO base address |
pinNum | GPIO Pin number associated with the port 'pinNum' can take one of the following values: (0 <= pinNum <= GPIO_MAX_PINS - 1) |
int32_t GPIO_clearInterrupt | ( | uint32_t | baseAddr, |
uint32_t | pinNum | ||
) |
The function is used to clear the interrupt on the GPIO Pin.
baseAddr | GPIO base address |
pinNum | GPIO Pin number associated with the port 'pinNum' can take one of the following values: (0 <= pinNum <= GPIO_MAX_PINS - 1) |
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.
baseAddr | GPIO base address |
pinNum | GPIO Pin number associated with the port 'pinNum' can take one of the following values: (0 <= pinNum <= GPIO_MAX_PINS - 1) |
interruptLevel | GPIO Interrupt priority 'interruptLevel' can take one of the following values following enum: |
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.
baseAddr | GPIO base address |
interruptLevel | GPIO Interrupt priority 'interruptLevel' can take one of the following values following enum: |
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.
baseAddr | GPIO base address |
pinNum | GPIO Pin number associated with the port 'pinNum' can take one of the following values: (0 <= pinNum <= GPIO_MAX_PINS-1) |
pinDir | Pin Direction set This can take one of the value from the following enum: |
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.
baseAddr | GPIO base address |
pinNum | GPIO Pin number associated with the port 'pinNum' can take one of the following values: (0 <= pinNum <= GPIO_MAX_PINS-1) |
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.
baseAddr | GPIO base address |
pinNum | GPIO Pin number associated with the port 'pinNum' can take one of the following values: (0 <= pinNum <= GPIO_MAX_PINS-1) |
void GPIO_pinWriteLow | ( | uint32_t | baseAddr, |
uint32_t | pinNum | ||
) |
The function is used to write logic LOW state to a specific GPIO Port/Pin.
baseAddr | GPIO base address |
pinNum | GPIO Pin number associated with the port 'pin' can take one of the following values: (0 <= pin <= GPIO_MAX_PINS-1) |
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.
baseAddr | GPIO base address |
pinNum | GPIO Pin number associated with the port 'pinNum' can take one of the following values: (0 <= pinNum <= GPIO_MAX_PINS-1) |
openDrainStatus | Set open drain status This can take one of the value from the following enum: |