NOTICE: The Processors Wiki will End-of-Life in December of 2020. 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.
The GPIO peripheral is used to interface with external devices and peripherals. The GPIO pins can act as general purpose inputs to read digital signals from other devices or as general purpose outputs to control or signal to other devices.
The 144 GPIO pins are divided into 9 banks of 16 pins each. The pins can be programmed as input or output by using direction control registers. In output mode, a pin can be set or cleared by writing into separate set or clear registers without modifying the states of other pins. All GPIO pins can be programmed to generate CPU interrupts with configurable edge detection. All GPIO pins can also be programmed to generate events to the EDMA controller. StarterWare provides APIs to access GPIO pins in input or output mode. These APIs are listed in include/gpio.h.
General programming guidelines for GPIO are given below.
- Perform system specific settings such as power domain, clock or reset configurations.
- Perform platform specific settings like Pin Multiplexing to ensure that the required GPIO pin(s) is (are) available for use.
- The direction of a GPIO pin can be configured using the API GPIODirModeSet (). A GPIO pin can be configured as an input or an output pin.
- When a GPIO pin is configured as an input pin, the following configuration steps become relevant.
- GPIO peripheral can generate an interrupt to the CPU when a specified logic transition is detected on the GPIO input pin. This trigger type for interrupt generation is configured using the API GPIOIntTypeSet (). The trigger type thus set is for a particular pin. Different GPIO input pins can be set with different interrupt trigger types.
- Enable host interrupts of ARM processor. Further initialize the Interrupt Controller (INTC), register the ISR in context with the INTC and set the priority of the interrupt.
- Enable the system interrupt in INTC corresponding to the GPIO peripheral interrupt.
- Enable interrupts for the bank to which the GPIO pin belongs to using the API GPIOBankIntEnable ().
- When a GPIO pin is configured as an output pin, the following configurations become relevant.
- Drive logic high or a logic low on the desired pin using the API GPIOPinWrite (). To write to multiple pins in the same bank at a time, use the API GPIOBankPinsWrite ().