TI-RTOS Drivers  tidrivers_full_2_20_00_08
Data Structures | Macros | Typedefs
GPIOTiva.h File Reference

Detailed Description

Tiva GPIO driver.

============================================================================

The GPIO header file should be included in an application as follows:

Refer to GPIO.h for a complete description of APIs.

Operation

The GPIO module allows you to manage General Purpose I/O pins via simple and portable APIs. The application is required to supply a GPIOTiva_Config structure to the module (see example below). This structure communicates to the GPIO module how to configure the pins used by the application (See the description of GPIO_PinConfig in the GPIO.h file).

The application is required to call GPIO_init(). This function will initialize all the GPIO pins defined in the GPIO_PinConfig table to the configurations specified. Once completed the other APIs can be used to access the pins.

Asserts are used to verify that the driver has been initialized, and is reading/writing a valid index.

The following is an example of the code required to use 2 switches and 2 LEDs on an EK_TM4C1294XL Launchpad board.

Board header file:

// Enum of GPIO names on the EK_TM4C1294XL dev board
typedef enum EK_TM4C1294XL_GPIOName {
EK_TM4C1294XL_USR_SW1 = 0,
EK_TM4C1294XL_USR_SW2,
EK_TM4C1294XL_D1,
EK_TM4C1294XL_D2,
EK_TM4C1294XL_GPIOCOUNT
} EK_TM4C1294XL_GPIOName;

Board initialization code:

// Array of pin configurations
// NOTE: The order of the pin configurations must coincide with what was
// defined in EK_TM4C1294XL.h
// NOTE: Pins not used for interrupts should be placed at the end of the
array. Callback entries can be omitted from callbacks array to
reduce memory usage.
const GPIO_PinConfig gpioPinConfigs[] = {
// Input pins
// EK_TM4C1294XL_USR_SW1
// EK_TM4C1294XL_USR_SW2
// Output pins
// EK_TM4C1294XL_USR_D1
// EK_TM4C1294XL_USR_D2
};
// Array of callback function pointers
// NOTE: The order of the pin configurations must coincide with what was
// defined in EK_TM4C1294XL.h
// NOTE: Pins not used for interrupts can be omitted from callbacks array to
reduce memory usage (if placed at end of gpioPinConfigs array).
const GPIO_callbackFxn gpioCallbackFunctions[] = {
NULL, // EK_TM4C1294XL_USR_SW1
NULL // EK_TM4C1294XL_USR_SW2
};
// The device-specific GPIO_config structure
const GPIOTiva_Config GPIOTiva_config = {
.pinConfigs = (GPIO_PinConfig *) gpioPinConfigs,
.callbacks = (GPIO_CallbackFxn *) gpioCallbackFunctions,
.numberOfPinConfigs = sizeof(gpioPinConfigs) / sizeof(GPIO_PinConfig),
.numberOfCallbacks = sizeof(gpioCallbackFunctions) / sizeof(GPIO_CallbackFxn),
.intPriority = (~0)
};
// Initialize peripheral and pins
void EK_TM4C1294XL_initGPIO(void)
{
}

Keep in mind that the callback functions will be called in the context of an interrupt service routine and should be designed accordingly. When an interrupt is triggered, the interrupt status of all (interrupt enabled) pins on a port will be read, cleared, and the respective callbacks will be executed. Callbacks will be called in order from least significant bit to most significant bit.

On select Tiva devices, ports P & Q are capable of per-pin interrupts (each pin has its own interrupt vector). If multiple interrupts on port P (or Q) are triggered, the first interrupt will clear all flags and execute the respective callbacks. Interrupts for other pins on P (or Q) will run, but will not execute callbacks.

Instrumentation

The GPIO driver interface produces log statements if instrumentation is enabled.

Diagnostics Mask Log details
Diags_USER1 basic operations performed

#include <stdint.h>
#include <ti/drivers/GPIO.h>
Include dependency graph for GPIOTiva.h:

Go to the source code of this file.

Data Structures

struct  GPIOTiva_Config
 GPIO device specific driver configuration structure. More...
 

Macros

#define GPIOTiva_EMPTY_PIN   0x0000
 Device specific port/pin definition macros. More...
 
#define GPIOTiva_PA_0   0x0001
 
#define GPIOTiva_PA_1   0x0002
 
#define GPIOTiva_PA_2   0x0004
 
#define GPIOTiva_PA_3   0x0008
 
#define GPIOTiva_PA_4   0x0010
 
#define GPIOTiva_PA_5   0x0020
 
#define GPIOTiva_PA_6   0x0040
 
#define GPIOTiva_PA_7   0x0080
 
#define GPIOTiva_PB_0   0x0101
 
#define GPIOTiva_PB_1   0x0102
 
#define GPIOTiva_PB_2   0x0104
 
#define GPIOTiva_PB_3   0x0108
 
#define GPIOTiva_PB_4   0x0110
 
#define GPIOTiva_PB_5   0x0120
 
#define GPIOTiva_PB_6   0x0140
 
#define GPIOTiva_PB_7   0x0180
 
#define GPIOTiva_PC_0   0x0201
 
#define GPIOTiva_PC_1   0x0202
 
#define GPIOTiva_PC_2   0x0204
 
#define GPIOTiva_PC_3   0x0208
 
#define GPIOTiva_PC_4   0x0210
 
#define GPIOTiva_PC_5   0x0220
 
#define GPIOTiva_PC_6   0x0240
 
#define GPIOTiva_PC_7   0x0280
 
#define GPIOTiva_PD_0   0x0301
 
#define GPIOTiva_PD_1   0x0302
 
#define GPIOTiva_PD_2   0x0304
 
#define GPIOTiva_PD_3   0x0308
 
#define GPIOTiva_PD_4   0x0310
 
#define GPIOTiva_PD_5   0x0320
 
#define GPIOTiva_PD_6   0x0340
 
#define GPIOTiva_PD_7   0x0380
 
#define GPIOTiva_PE_0   0x0401
 
#define GPIOTiva_PE_1   0x0402
 
#define GPIOTiva_PE_2   0x0404
 
#define GPIOTiva_PE_3   0x0408
 
#define GPIOTiva_PE_4   0x0410
 
#define GPIOTiva_PE_5   0x0420
 
#define GPIOTiva_PE_6   0x0440
 
#define GPIOTiva_PE_7   0x0480
 
#define GPIOTiva_PF_0   0x0501
 
#define GPIOTiva_PF_1   0x0502
 
#define GPIOTiva_PF_2   0x0504
 
#define GPIOTiva_PF_3   0x0508
 
#define GPIOTiva_PF_4   0x0510
 
#define GPIOTiva_PF_5   0x0520
 
#define GPIOTiva_PF_6   0x0540
 
#define GPIOTiva_PF_7   0x0580
 
#define GPIOTiva_PG_0   0x0601
 
#define GPIOTiva_PG_1   0x0602
 
#define GPIOTiva_PG_2   0x0604
 
#define GPIOTiva_PG_3   0x0608
 
#define GPIOTiva_PG_4   0x0610
 
#define GPIOTiva_PG_5   0x0620
 
#define GPIOTiva_PG_6   0x0640
 
#define GPIOTiva_PG_7   0x0680
 
#define GPIOTiva_PH_0   0x0701
 
#define GPIOTiva_PH_1   0x0702
 
#define GPIOTiva_PH_2   0x0704
 
#define GPIOTiva_PH_3   0x0708
 
#define GPIOTiva_PH_4   0x0710
 
#define GPIOTiva_PH_5   0x0720
 
#define GPIOTiva_PH_6   0x0740
 
#define GPIOTiva_PH_7   0x0780
 
#define GPIOTiva_PJ_0   0x0801
 
#define GPIOTiva_PJ_1   0x0802
 
#define GPIOTiva_PJ_2   0x0804
 
#define GPIOTiva_PJ_3   0x0808
 
#define GPIOTiva_PJ_4   0x0810
 
#define GPIOTiva_PJ_5   0x0820
 
#define GPIOTiva_PJ_6   0x0840
 
#define GPIOTiva_PJ_7   0x0880
 
#define GPIOTiva_PK_0   0x0901
 
#define GPIOTiva_PK_1   0x0902
 
#define GPIOTiva_PK_2   0x0904
 
#define GPIOTiva_PK_3   0x0908
 
#define GPIOTiva_PK_4   0x0910
 
#define GPIOTiva_PK_5   0x0920
 
#define GPIOTiva_PK_6   0x0940
 
#define GPIOTiva_PK_7   0x0980
 
#define GPIOTiva_PL_0   0x0A01
 
#define GPIOTiva_PL_1   0x0A02
 
#define GPIOTiva_PL_2   0x0A04
 
#define GPIOTiva_PL_3   0x0A08
 
#define GPIOTiva_PL_4   0x0A10
 
#define GPIOTiva_PL_5   0x0A20
 
#define GPIOTiva_PL_6   0x0A40
 
#define GPIOTiva_PL_7   0x0A80
 
#define GPIOTiva_PM_0   0x0B01
 
#define GPIOTiva_PM_1   0x0B02
 
#define GPIOTiva_PM_2   0x0B04
 
#define GPIOTiva_PM_3   0x0B08
 
#define GPIOTiva_PM_4   0x0B10
 
#define GPIOTiva_PM_5   0x0B20
 
#define GPIOTiva_PM_6   0x0B40
 
#define GPIOTiva_PM_7   0x0B80
 
#define GPIOTiva_PN_0   0x0C01
 
#define GPIOTiva_PN_1   0x0C02
 
#define GPIOTiva_PN_2   0x0C04
 
#define GPIOTiva_PN_3   0x0C08
 
#define GPIOTiva_PN_4   0x0C10
 
#define GPIOTiva_PN_5   0x0C20
 
#define GPIOTiva_PN_6   0x0C40
 
#define GPIOTiva_PN_7   0x0C80
 

Typedefs

typedef struct GPIOTiva_Config GPIOTiva_Config
 GPIO device specific driver configuration structure. More...
 

Macro Definition Documentation

#define GPIOTiva_EMPTY_PIN   0x0000

Device specific port/pin definition macros.

Below are the port/pin definitions to be used within the board's pin configuration table. These macros should be OR'd in with the respective pin configuration settings.

#define GPIOTiva_PA_0   0x0001
#define GPIOTiva_PA_1   0x0002
#define GPIOTiva_PA_2   0x0004
#define GPIOTiva_PA_3   0x0008
#define GPIOTiva_PA_4   0x0010
#define GPIOTiva_PA_5   0x0020
#define GPIOTiva_PA_6   0x0040
#define GPIOTiva_PA_7   0x0080
#define GPIOTiva_PB_0   0x0101
#define GPIOTiva_PB_1   0x0102
#define GPIOTiva_PB_2   0x0104
#define GPIOTiva_PB_3   0x0108
#define GPIOTiva_PB_4   0x0110
#define GPIOTiva_PB_5   0x0120
#define GPIOTiva_PB_6   0x0140
#define GPIOTiva_PB_7   0x0180
#define GPIOTiva_PC_0   0x0201
#define GPIOTiva_PC_1   0x0202
#define GPIOTiva_PC_2   0x0204
#define GPIOTiva_PC_3   0x0208
#define GPIOTiva_PC_4   0x0210
#define GPIOTiva_PC_5   0x0220
#define GPIOTiva_PC_6   0x0240
#define GPIOTiva_PC_7   0x0280
#define GPIOTiva_PD_0   0x0301
#define GPIOTiva_PD_1   0x0302
#define GPIOTiva_PD_2   0x0304
#define GPIOTiva_PD_3   0x0308
#define GPIOTiva_PD_4   0x0310
#define GPIOTiva_PD_5   0x0320
#define GPIOTiva_PD_6   0x0340
#define GPIOTiva_PD_7   0x0380
#define GPIOTiva_PE_0   0x0401
#define GPIOTiva_PE_1   0x0402
#define GPIOTiva_PE_2   0x0404
#define GPIOTiva_PE_3   0x0408
#define GPIOTiva_PE_4   0x0410
#define GPIOTiva_PE_5   0x0420
#define GPIOTiva_PE_6   0x0440
#define GPIOTiva_PE_7   0x0480
#define GPIOTiva_PF_0   0x0501
#define GPIOTiva_PF_1   0x0502
#define GPIOTiva_PF_2   0x0504
#define GPIOTiva_PF_3   0x0508
#define GPIOTiva_PF_4   0x0510
#define GPIOTiva_PF_5   0x0520
#define GPIOTiva_PF_6   0x0540
#define GPIOTiva_PF_7   0x0580
#define GPIOTiva_PG_0   0x0601
#define GPIOTiva_PG_1   0x0602
#define GPIOTiva_PG_2   0x0604
#define GPIOTiva_PG_3   0x0608
#define GPIOTiva_PG_4   0x0610
#define GPIOTiva_PG_5   0x0620
#define GPIOTiva_PG_6   0x0640
#define GPIOTiva_PG_7   0x0680
#define GPIOTiva_PH_0   0x0701
#define GPIOTiva_PH_1   0x0702
#define GPIOTiva_PH_2   0x0704
#define GPIOTiva_PH_3   0x0708
#define GPIOTiva_PH_4   0x0710
#define GPIOTiva_PH_5   0x0720
#define GPIOTiva_PH_6   0x0740
#define GPIOTiva_PH_7   0x0780
#define GPIOTiva_PJ_0   0x0801
#define GPIOTiva_PJ_1   0x0802
#define GPIOTiva_PJ_2   0x0804
#define GPIOTiva_PJ_3   0x0808
#define GPIOTiva_PJ_4   0x0810
#define GPIOTiva_PJ_5   0x0820
#define GPIOTiva_PJ_6   0x0840
#define GPIOTiva_PJ_7   0x0880
#define GPIOTiva_PK_0   0x0901
#define GPIOTiva_PK_1   0x0902
#define GPIOTiva_PK_2   0x0904
#define GPIOTiva_PK_3   0x0908
#define GPIOTiva_PK_4   0x0910
#define GPIOTiva_PK_5   0x0920
#define GPIOTiva_PK_6   0x0940
#define GPIOTiva_PK_7   0x0980
#define GPIOTiva_PL_0   0x0A01
#define GPIOTiva_PL_1   0x0A02
#define GPIOTiva_PL_2   0x0A04
#define GPIOTiva_PL_3   0x0A08
#define GPIOTiva_PL_4   0x0A10
#define GPIOTiva_PL_5   0x0A20
#define GPIOTiva_PL_6   0x0A40
#define GPIOTiva_PL_7   0x0A80
#define GPIOTiva_PM_0   0x0B01
#define GPIOTiva_PM_1   0x0B02
#define GPIOTiva_PM_2   0x0B04
#define GPIOTiva_PM_3   0x0B08
#define GPIOTiva_PM_4   0x0B10
#define GPIOTiva_PM_5   0x0B20
#define GPIOTiva_PM_6   0x0B40
#define GPIOTiva_PM_7   0x0B80
#define GPIOTiva_PN_0   0x0C01
#define GPIOTiva_PN_1   0x0C02
#define GPIOTiva_PN_2   0x0C04
#define GPIOTiva_PN_3   0x0C08
#define GPIOTiva_PN_4   0x0C10
#define GPIOTiva_PN_5   0x0C20
#define GPIOTiva_PN_6   0x0C40
#define GPIOTiva_PN_7   0x0C80

Typedef Documentation

GPIO device specific driver configuration structure.

Copyright 2016, Texas Instruments Incorporated