NOTICE: The Processors Wiki will End-of-Life on January 15, 2021. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.
StarterWare GPIO V2
GPIO[edit]
Introduction[edit]
Each GPIO module provides 32 dedicated general-purpose pins with input and output capabilities. These pins can be configured for the following applications:
- Data input (capture)/output (drive)
- Keyboard interface with a debounce cell
- Interrupt generation in active mode upon the detection of external events. Detected events are processed by two parallel independent interrupt-generation submodules to support biprocessor operations.
Programming[edit]
- Firstly, enable the functional clocks for the required GPIO instance.
- Perform a pin multiplexing for the required GPIO pin by calling the appropriate pin multiplexing function implemented in the respective Platform file.
- Enable the GPIO module using the API GPIOModuleEnable(). Doing this would confirm that the clocks to the GPIO module are not gated.
- Perform a module reset of the GPIO module using the API GPIOModuleReset(). This API also waits until the module reset is complete.
- A GPIO pin can be used either as an input or an output pin. This direction of the GPIO pin is configured using the API GPIODirModeSet().
- When a GPIO pin is configured as an input pin, the following configurations become relevant:
- Enable debouncing feature for the specified input GPIO pin if required, using the API GPIODebounceFuncControl().
- Program the debouncing time, if required using the API GPIODebounceTimeConfig().
- Interrupt trigger conditions need to be configured using the API GPIOIntTypeSet() using appropriate parameters.
- Enable GPIO to generate interrupts on detection of the specified transitions on the decided GPIO pin using the API GPIOPinIntEnable()
- When a GPIO pin is configured as an output pin, the following configurations become relevant:
- A logic HIGH or a logic LOW could be driven on the specified GPIO pin by invoking the API GPIOPinWrite() passing appropriate parameters.
Note: If GPIO peripheral interrupts will be used, then the system interrupt settings needs to be performed prior to enabling the GPIO peripheral interrupts. System interrupt settings involves configuring the ARM processor and the Interrupt Controller(INTC) to handle peripheral interrupts.