GPIO Module¶
The GPIO module provides an API to read from, and write to the GPIO pins. Functions fall into the two categories, control and data. Control functions configure properties like direction, pin muxing, and qualification. Data functions allow you to read the value on a pin or write a value to it.
GPIO module on CM side supports only data functions i.e. to read from or write to GPIO pin. Please use GPIO module on C28x side for control functions.
-
group
gpio_api Defines
-
GPIO_DATA_REGS_STEP((GPIO_O_GPBDAT - GPIO_O_GPADAT) / 4U)¶
-
GPIO_DATA_READ_REGS_STEP((GPIO_O_GPBDAT_R - GPIO_O_GPADAT_R) / 4U)¶
-
GPIO_GPxDAT_INDEX(GPIO_O_GPADAT / 4U)¶
-
GPIO_GPxSET_INDEX(GPIO_O_GPASET / 4U)¶
-
GPIO_GPxCLEAR_INDEX(GPIO_O_GPACLEAR / 4U)¶
-
GPIO_GPxTOGGLE_INDEX(GPIO_O_GPATOGGLE / 4U)¶
-
GPIO_GPxDAT_R_INDEX(GPIO_O_GPADAT_R / 4U)¶
-
GPIO_PIN_TYPE_STD0x0000U¶ Push-pull output or floating input.
-
GPIO_PIN_TYPE_PULLUP0x0001U¶ Pull-up enable for input.
-
GPIO_PIN_TYPE_INVERT0x0002U¶ Invert polarity on input.
-
GPIO_PIN_TYPE_OD0x0004U¶ Open-drain on output.
Enums
-
enum
GPIO_Port¶ Values that can be passed to GPIO_readPortData(), GPIO_setPortPins(), GPIO_clearPortPins(), and GPIO_togglePortPins() as the port parameter.
Values:
-
enumerator
GPIO_PORT_A= 0¶ GPIO port A.
-
enumerator
GPIO_PORT_B= 1¶ GPIO port B.
-
enumerator
GPIO_PORT_C= 2¶ GPIO port C.
-
enumerator
GPIO_PORT_D= 3¶ GPIO port D.
-
enumerator
GPIO_PORT_E= 4¶ GPIO port E.
-
enumerator
GPIO_PORT_F= 5¶ GPIO port F.
-
enumerator
Functions
-
uint32_t
GPIO_readPin(uint32_t pin)¶ Reads the value present on the specified pin.
The value at the specified pin are read, as specified by
pin. The value is returned for both input and output pins.- Parameters
pin: is the identifying GPIO number of the pin.
The pin is specified by its numerical value. For example, GPIO34 is specified by passing 34 as pin.
- Return
Returns the value in the data register for the specified pin.
-
uint32_t
GPIO_readPinDataRegister(uint32_t pin)¶ Reads the data register value for specified pin.
The value available at the data register for the specified pin is read, as specified by
pin. The value is returned for both input and output pins.- Parameters
pin: is the identifying GPIO number of the pin.
The pin is specified by its numerical value. For example, GPIO34 is specified by passing 34 as pin.
- See
- Return
Returns the value in the data register for the specified pin.
-
void
GPIO_writePin(uint32_t pin, uint32_t outVal)¶ Writes a value to the specified pin.
Writes the corresponding bit values to the output pin specified by
pin. Writing to a pin configured as an input pin has no effect.- Parameters
pin: is the identifying GPIO number of the pin.outVal: is the value to write to the pin.
The pin is specified by its numerical value. For example, GPIO34 is specified by passing 34 as pin.
- Return
None.
-
void
GPIO_togglePin(uint32_t pin)¶ Toggles the specified pin.
Writes the corresponding bit values to the output pin specified by
pin. Writing to a pin configured as an input pin has no effect.- Parameters
pin: is the identifying GPIO number of the pin.
The pin is specified by its numerical value. For example, GPIO34 is specified by passing 34 as pin.
- Return
None.
-
uint32_t
GPIO_readPortData(GPIO_Port port)¶ Reads the data on the specified port.
- Return
Returns the value available on pin for the specified port. Each bit of the the return value represents a pin on the port, where bit 0 represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on.
- Parameters
port: is the GPIO port being accessed in the form of GPIO_PORT_X where X is the port letter.
-
uint32_t
GPIO_readPortDataRegister(GPIO_Port port)¶ Reads the data written in GPIO Data Register.
Reads the data written in GPIO Data Register for the specified port. In previous devices, read of GPIO data registers resulted in read of corespoinding pins. The function
GPIO_readPortData() returns the value on pin.- Parameters
port: is the GPIO port being accessed in the form of GPIO_PORT_X where X is the port letter.
- See
- Return
Returns the value in the data register for the specified port. Each bit of the the return value represents a pin on the port, where bit 0 represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on.
-
void
GPIO_writePortData(GPIO_Port port, uint32_t outVal)¶ Writes a value to the specified port.
This function writes the value
outVal to the port specified by the port parameter which takes a value in the form of GPIO_PORT_X where X is the port letter. For example, use GPIO_PORT_A to affect port A (GPIOs 0-31).- Parameters
port: is the GPIO port being accessed.outVal: is the value to write to the port.
The outVal is a bit-packed value, where each bit represents a bit on a GPIO port. Bit 0 represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on.
- Return
None.
-
void
GPIO_setPortPins(GPIO_Port port, uint32_t pinMask)¶ Sets all of the specified pins on the specified port.
This function sets all of the pins specified by the
pinMask parameter on the port specified by the port parameter which takes a value in the form of GPIO_PORT_X where X is the port letter. For example, use GPIO_PORT_A to affect port A (GPIOs 0-31).- Parameters
port: is the GPIO port being accessed.pinMask: is a mask of which of the 32 pins on the port are affected.
The pinMask is a bit-packed value, where each bit that is set identifies the pin to be set. Bit 0 represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on.
- Return
None.
-
void
GPIO_clearPortPins(GPIO_Port port, uint32_t pinMask)¶ Clears all of the specified pins on the specified port.
This function clears all of the pins specified by the
pinMask parameter on the port specified by the port parameter which takes a value in the form of GPIO_PORT_X where X is the port letter. For example, use GPIO_PORT_A to affect port A (GPIOs 0-31).- Parameters
port: is the GPIO port being accessed.pinMask: is a mask of which of the 32 pins on the port are affected.
The pinMask is a bit-packed value, where each bit that is set identifies the pin to be cleared. Bit 0 represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on.
- Return
None.
-
void
GPIO_togglePortPins(GPIO_Port port, uint32_t pinMask)¶ Toggles all of the specified pins on the specified port.
This function toggles all of the pins specified by the
pinMask parameter on the port specified by the port parameter which takes a value in the form of GPIO_PORT_X where X is the port letter. For example, use GPIO_PORT_A to affect port A (GPIOs 0-31).- Parameters
port: is the GPIO port being accessed.pinMask: is a mask of which of the 32 pins on the port are affected.
The pinMask is a bit-packed value, where each bit that is set identifies the pin to be toggled. Bit 0 represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on.
- Return
None.
-
Most functions operate on one pin at a time. However, there are a few functions that can operate on an entire port at once for the sake of efficiency. These are the data functions GPIO_readPortData(), GPIO_writePortData(), GPIO_setPortPins(), GPIO_clearPortPins(), and GPIO_togglePortPins(). Other data functions that affect a single pin at a time are GPIO_readPin(), GPIO_writePin(), and GPIO_togglePin().
The code for this module is contained in driverlib_cm/gpio.c, with driverlib_cm/gpio.h containing the API declarations for use by applications.