This module contains APIs to program and use the GPIO module.
Files | |
file | gpio/v0/gpio.h |
GPIO Driver API/interface file. | |
Functions | |
void | GPIO_setDirMode (uint32_t baseAddr, uint32_t pinNum, uint32_t pinDir) |
This API configures the direction of a specified GPIO pin as being either input or output. More... | |
static void | GPIO_pinWriteHigh (uint32_t baseAddr, uint32_t pinNum) |
This API drives an output GPIO pin to a logic HIGH state. More... | |
static void | GPIO_pinWriteLow (uint32_t baseAddr, uint32_t pinNum) |
This API drives an output GPIO pin to a logic LOW state. More... | |
uint32_t | GPIO_pinRead (uint32_t baseAddr, uint32_t pinNum) |
This API reads the logic level(value) on a specified GPIO pin. More... | |
uint32_t | GPIO_pinOutValueRead (uint32_t baseAddr, uint32_t pinNum) |
This API determines the output logic level(value) on a specified GPIO pin. More... | |
void | GPIO_setTrigType (uint32_t baseAddr, uint32_t pinNum, uint32_t trigType) |
This API configures the trigger type for a specified input GPIO pin. More... | |
void | GPIO_bankIntrEnable (uint32_t baseAddr, uint32_t bankNum) |
This API enables the bank interrupt. This has to be called after setting all the GPIO pin triggers of a bank to get interrupt. More... | |
void | GPIO_bankIntrDisable (uint32_t baseAddr, uint32_t bankNum) |
This API disables the bank interrupt. More... | |
static uint32_t | GPIO_getIntrStatus (uint32_t baseAddr, uint32_t pinNum) |
This API determines the enabled interrupt status of a specified pin. More... | |
static void | GPIO_clearIntrStatus (uint32_t baseAddr, uint32_t pinNum) |
This API clears the enabled interrupt status of a specified GPIO pin. More... | |
static uint32_t | GPIO_getBankIntrStatus (uint32_t baseAddr, uint32_t bankNum) |
This API returns the interrupt status of the specified bank. More... | |
static void | GPIO_clearBankIntrStatus (uint32_t baseAddr, uint32_t bankNum, uint32_t intrStatus) |
This API clears the interrupt status of the specified bank. More... | |
Macros | |
#define | GPIO_MAX_BANKS (9U) |
Maximum number of banks per instance/module. More... | |
#define | GPIO_MAX_PIN_PER_BANK (16U) |
Maximum number of pins per bank. More... | |
#define | GPIO_MAX_PIN_PER_INSTANCE (GPIO_MAX_BANKS * GPIO_MAX_PIN_PER_BANK) |
Maximum number of pins per instance/module. More... | |
#define | GPIO_BANKS_PER_REG (2U) |
Number of banks per register. More... | |
#define | GPIO_PINS_PER_REG (GPIO_BANKS_PER_REG * GPIO_MAX_PIN_PER_BANK) |
Number of pins per register - 32 pins. More... | |
#define | GPIO_PINS_PER_REG_SHIFT (5U) |
Number of pins per register - shift value - used instead of divide operator. More... | |
#define | GPIO_PINS_PER_BANK_SHIFT (4U) |
Number of pins per bank - shift value - used instead of divide operator. More... | |
#define | GPIO_GET_BANK_INDEX(pinNum) (((uint32_t) pinNum) >> GPIO_PINS_PER_BANK_SHIFT) |
Returns the bank index based on pin number. More... | |
#define | GPIO_GET_REG_INDEX(pinNum) (((uint32_t) pinNum) >> GPIO_PINS_PER_REG_SHIFT) |
Returns the register index based on pin number. More... | |
#define | GPIO_GET_BIT_POS(pinNum) (pinNum - ((GPIO_GET_REG_INDEX(pinNum)) << GPIO_PINS_PER_REG_SHIFT)) |
Returns the bit position within a register based on pin number. More... | |
#define | GPIO_GET_BIT_MASK(pinNum) (((uint32_t) 1U) << GPIO_GET_BIT_POS(pinNum)) |
Returns the bit mask within a register based on pin number. More... | |
#define | GPIO_GET_BANK_BIT_POS(pinNum) (pinNum - ((GPIO_GET_BANK_INDEX(pinNum)) << GPIO_PINS_PER_BANK_SHIFT)) |
Returns the bit position within a bank based on pin number. More... | |
#define | GPIO_GET_BANK_BIT_MASK(pinNum) (((uint32_t) 1U) << GPIO_GET_BANK_BIT_POS(pinNum)) |
Returns the bit mask within a bank 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 (0U) |
#define | GPIO_DIRECTION_INPUT (1U) |
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... | |
#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 (0U) |
#define GPIO_DIRECTION_INPUT (1U) |
#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_MAX_BANKS (9U) |
Maximum number of banks per instance/module.
#define GPIO_MAX_PIN_PER_BANK (16U) |
Maximum number of pins per bank.
#define GPIO_MAX_PIN_PER_INSTANCE (GPIO_MAX_BANKS * GPIO_MAX_PIN_PER_BANK) |
Maximum number of pins per instance/module.
#define GPIO_BANKS_PER_REG (2U) |
Number of banks per register.
#define GPIO_PINS_PER_REG (GPIO_BANKS_PER_REG * GPIO_MAX_PIN_PER_BANK) |
Number of pins per register - 32 pins.
#define GPIO_PINS_PER_REG_SHIFT (5U) |
Number of pins per register - shift value - used instead of divide operator.
#define GPIO_PINS_PER_BANK_SHIFT (4U) |
Number of pins per bank - shift value - used instead of divide operator.
#define GPIO_GET_BANK_INDEX | ( | pinNum | ) | (((uint32_t) pinNum) >> GPIO_PINS_PER_BANK_SHIFT) |
Returns the bank index based on pin number.
#define GPIO_GET_REG_INDEX | ( | pinNum | ) | (((uint32_t) pinNum) >> GPIO_PINS_PER_REG_SHIFT) |
Returns the register index based on pin number.
#define GPIO_GET_BIT_POS | ( | pinNum | ) | (pinNum - ((GPIO_GET_REG_INDEX(pinNum)) << GPIO_PINS_PER_REG_SHIFT)) |
Returns the bit position within a register based on pin number.
#define GPIO_GET_BIT_MASK | ( | pinNum | ) | (((uint32_t) 1U) << GPIO_GET_BIT_POS(pinNum)) |
Returns the bit mask within a register based on pin number.
#define GPIO_GET_BANK_BIT_POS | ( | pinNum | ) | (pinNum - ((GPIO_GET_BANK_INDEX(pinNum)) << GPIO_PINS_PER_BANK_SHIFT)) |
Returns the bit position within a bank based on pin number.
#define GPIO_GET_BANK_BIT_MASK | ( | pinNum | ) | (((uint32_t) 1U) << GPIO_GET_BANK_BIT_POS(pinNum)) |
Returns the bit mask within a bank based on pin number.
void GPIO_setDirMode | ( | uint32_t | baseAddr, |
uint32_t | pinNum, | ||
uint32_t | pinDir | ||
) |
This API configures the direction of a specified GPIO pin as being either input or output.
baseAddr | The memory address of the GPIO instance being used |
pinNum | The number of the pin in the GPIO instance 'pinNum' can take one of the following values: (0 <= pinNum <= GPIO_MAX_PIN_PER_INSTANCE - 1) |
pinDir | The required direction for the GPIO pin. This can take one of the value from the following enum: |
|
inlinestatic |
This API drives an output GPIO pin to a logic HIGH state.
baseAddr | The memory address of the GPIO instance being used |
pinNum | The number of the pin in the GPIO instance 'pinNum' can take one of the following values: (0 <= pinNum <= GPIO_MAX_PIN_PER_INSTANCE - 1) |
|
inlinestatic |
This API drives an output GPIO pin to a logic LOW state.
baseAddr | The memory address of the GPIO instance being used |
pinNum | The number of the pin in the GPIO instance 'pinNum' can take one of the following values: (0 <= pinNum <= GPIO_MAX_PIN_PER_INSTANCE - 1) |
uint32_t GPIO_pinRead | ( | uint32_t | baseAddr, |
uint32_t | pinNum | ||
) |
This API reads the logic level(value) on a specified GPIO pin.
baseAddr | The memory address of the GPIO instance being used |
pinNum | The number of the pin in the GPIO instance 'pinNum' can take one of the following values: (0 <= pinNum <= GPIO_MAX_PIN_PER_INSTANCE - 1) |
uint32_t GPIO_pinOutValueRead | ( | uint32_t | baseAddr, |
uint32_t | pinNum | ||
) |
This API determines the output logic level(value) on a specified GPIO pin.
baseAddr | The memory address of the GPIO instance being used |
pinNum | The number of the pin in the GPIO instance 'pinNum' can take one of the following values: (0 <= pinNum <= GPIO_MAX_PIN_PER_INSTANCE - 1) |
void GPIO_setTrigType | ( | uint32_t | baseAddr, |
uint32_t | pinNum, | ||
uint32_t | trigType | ||
) |
This API configures the trigger type for a specified input GPIO pin.
Whenever the selected trigger occurs on that GPIO pin and if interrupt generation is enabled for that pin, the GPIO module will send an interrupt to CPU. To disable the per pin event/interrupt generation, set the trigger type to #GPIO_TRIG_TYPE_NONE
baseAddr | The memory address of the GPIO instance being used |
pinNum | The number of the pin in the GPIO instance 'pinNum' can take one of the following values: (0 <= pinNum <= 63). |
trigType | This specifies the trigger type on whose detection, the GPIO module will send an interrupt to CPU, provided interrupt generation for that pin is enabled. 'trigType' can take one of the following values following enum: |
void GPIO_bankIntrEnable | ( | uint32_t | baseAddr, |
uint32_t | bankNum | ||
) |
This API enables the bank interrupt. This has to be called after setting all the GPIO pin triggers of a bank to get interrupt.
baseAddr | The memory address of the GPIO instance being used |
bankNum | The bank index 'bankNum' can take one of the following values: (0 <= bankNum <= GPIO_MAX_BANKS - 1) |
void GPIO_bankIntrDisable | ( | uint32_t | baseAddr, |
uint32_t | bankNum | ||
) |
This API disables the bank interrupt.
baseAddr | The memory address of the GPIO instance being used |
bankNum | The bank index 'bankNum' can take one of the following values: (0 <= bankNum <= GPIO_MAX_BANKS - 1) |
|
inlinestatic |
This API determines the enabled interrupt status of a specified pin.
baseAddr | The memory address of the GPIO instance being used |
pinNum | The number of the pin in the GPIO instance 'pinNum' can take one of the following values: (0 <= pinNum <= GPIO_MAX_PIN_PER_INSTANCE - 1) |
|
inlinestatic |
This API clears the enabled interrupt status of a specified GPIO pin.
baseAddr | The memory address of the GPIO instance being used |
pinNum | The number of the pin in the GPIO instance 'pinNum' can take one of the following values: (0 <= pinNum <= GPIO_MAX_PIN_PER_INSTANCE - 1) |
|
inlinestatic |
This API returns the interrupt status of the specified bank.
baseAddr | The memory address of the GPIO instance being used |
bankNum | Bank index of the GPIO instance. |
|
inlinestatic |
This API clears the interrupt status of the specified bank.
baseAddr | The memory address of the GPIO instance being used |
bankNum | Bank index of the GPIO instance. |
intrStatus | Interrupt mask to clear the status |