Tiva Driver Lib
gpio.h
1 //*****************************************************************************
2 //
3 // gpio.h - Defines and Macros for GPIO API.
4 //
5 // Copyright (c) 2005-2013 Texas Instruments Incorporated. All rights reserved.
6 // Software License Agreement
7 //
8 // Redistribution and use in source and binary forms, with or without
9 // modification, are permitted provided that the following conditions
10 // are met:
11 //
12 // Redistributions of source code must retain the above copyright
13 // notice, this list of conditions and the following disclaimer.
14 //
15 // Redistributions in binary form must reproduce the above copyright
16 // notice, this list of conditions and the following disclaimer in the
17 // documentation and/or other materials provided with the
18 // distribution.
19 //
20 // Neither the name of Texas Instruments Incorporated nor the names of
21 // its contributors may be used to endorse or promote products derived
22 // from this software without specific prior written permission.
23 //
24 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 //
36 // This is part of revision 1.1 of the Tiva Peripheral Driver Library.
37 //
38 //*****************************************************************************
39 
40 #ifndef __DRIVERLIB_GPIO_H__
41 #define __DRIVERLIB_GPIO_H__
42 
43 //*****************************************************************************
44 //
45 // If building with a C++ compiler, make all of the definitions in this header
46 // have a C binding.
47 //
48 //*****************************************************************************
49 #ifdef __cplusplus
50 extern "C"
51 {
52 #endif
53 
54 //*****************************************************************************
55 //
56 // The following values define the bit field for the ui8Pins argument to
57 // several of the APIs.
58 //
59 //*****************************************************************************
60 #define GPIO_PIN_0 0x00000001 // GPIO pin 0
61 #define GPIO_PIN_1 0x00000002 // GPIO pin 1
62 #define GPIO_PIN_2 0x00000004 // GPIO pin 2
63 #define GPIO_PIN_3 0x00000008 // GPIO pin 3
64 #define GPIO_PIN_4 0x00000010 // GPIO pin 4
65 #define GPIO_PIN_5 0x00000020 // GPIO pin 5
66 #define GPIO_PIN_6 0x00000040 // GPIO pin 6
67 #define GPIO_PIN_7 0x00000080 // GPIO pin 7
68 
69 //*****************************************************************************
70 //
71 // Values that can be passed to GPIODirModeSet as the ui32PinIO parameter, and
72 // returned from GPIODirModeGet.
73 //
74 //*****************************************************************************
75 #define GPIO_DIR_MODE_IN 0x00000000 // Pin is a GPIO input
76 #define GPIO_DIR_MODE_OUT 0x00000001 // Pin is a GPIO output
77 #define GPIO_DIR_MODE_HW 0x00000002 // Pin is a peripheral function
78 
79 //*****************************************************************************
80 //
81 // Values that can be passed to GPIOIntTypeSet as the ui32IntType parameter,
82 // and returned from GPIOIntTypeGet.
83 //
84 //*****************************************************************************
85 #define GPIO_FALLING_EDGE 0x00000000 // Interrupt on falling edge
86 #define GPIO_RISING_EDGE 0x00000004 // Interrupt on rising edge
87 #define GPIO_BOTH_EDGES 0x00000001 // Interrupt on both edges
88 #define GPIO_LOW_LEVEL 0x00000002 // Interrupt on low level
89 #define GPIO_HIGH_LEVEL 0x00000006 // Interrupt on high level
90 #define GPIO_DISCRETE_INT 0x00010000 // Interrupt for individual pins
91 
92 //*****************************************************************************
93 //
94 // Values that can be passed to GPIOPadConfigSet as the ui32Strength parameter,
95 // and returned by GPIOPadConfigGet in the *pui32Strength parameter.
96 //
97 //*****************************************************************************
98 #define GPIO_STRENGTH_2MA 0x00000001 // 2mA drive strength
99 #define GPIO_STRENGTH_4MA 0x00000002 // 4mA drive strength
100 #define GPIO_STRENGTH_8MA 0x00000004 // 8mA drive strength
101 #define GPIO_STRENGTH_8MA_SC 0x0000000C // 8mA drive with slew rate control
102 
103 //*****************************************************************************
104 //
105 // Values that can be passed to GPIOPadConfigSet as the ui32PadType parameter,
106 // and returned by GPIOPadConfigGet in the *pui32PadType parameter.
107 //
108 //*****************************************************************************
109 #define GPIO_PIN_TYPE_STD 0x00000008 // Push-pull
110 #define GPIO_PIN_TYPE_STD_WPU 0x0000000A // Push-pull with weak pull-up
111 #define GPIO_PIN_TYPE_STD_WPD 0x0000000C // Push-pull with weak pull-down
112 #define GPIO_PIN_TYPE_OD 0x00000009 // Open-drain
113 #define GPIO_PIN_TYPE_ANALOG 0x00000000 // Analog comparator
114 
115 //*****************************************************************************
116 //
117 // Values that can be passed to GPIOIntEnable() and GPIOIntDisable() functions
118 // in the ui32IntFlags parameter.
119 //
120 //*****************************************************************************
121 #define GPIO_INT_PIN_0 0x00000001
122 #define GPIO_INT_PIN_1 0x00000002
123 #define GPIO_INT_PIN_2 0x00000004
124 #define GPIO_INT_PIN_3 0x00000008
125 #define GPIO_INT_PIN_4 0x00000010
126 #define GPIO_INT_PIN_5 0x00000020
127 #define GPIO_INT_PIN_6 0x00000040
128 #define GPIO_INT_PIN_7 0x00000080
129 
130 //*****************************************************************************
131 //
132 // Prototypes for the APIs.
133 //
134 //*****************************************************************************
135 extern void GPIODirModeSet(uint32_t ui32Port, uint8_t ui8Pins,
136  uint32_t ui32PinIO);
137 extern uint32_t GPIODirModeGet(uint32_t ui32Port, uint8_t ui8Pin);
138 extern void GPIOIntTypeSet(uint32_t ui32Port, uint8_t ui8Pins,
139  uint32_t ui32IntType);
140 extern uint32_t GPIOIntTypeGet(uint32_t ui32Port, uint8_t ui8Pin);
141 extern void GPIOPadConfigSet(uint32_t ui32Port, uint8_t ui8Pins,
142  uint32_t ui32Strength, uint32_t ui32PadType);
143 extern void GPIOPadConfigGet(uint32_t ui32Port, uint8_t ui8Pin,
144  uint32_t *pui32Strength, uint32_t *pui32PadType);
145 extern void GPIOIntEnable(uint32_t ui32Port, uint32_t ui32IntFlags);
146 extern void GPIOIntDisable(uint32_t ui32Port, uint32_t ui32IntFlags);
147 extern uint32_t GPIOIntStatus(uint32_t ui32Port, bool bMasked);
148 extern void GPIOIntClear(uint32_t ui32Port, uint32_t ui32IntFlags);
149 extern void GPIOIntRegister(uint32_t ui32Port, void (*pfnIntHandler)(void));
150 extern void GPIOIntUnregister(uint32_t ui32Port);
151 extern int32_t GPIOPinRead(uint32_t ui32Port, uint8_t ui8Pins);
152 extern void GPIOPinWrite(uint32_t ui32Port, uint8_t ui8Pins, uint8_t ui8Val);
153 extern void GPIOPinConfigure(uint32_t ui32PinConfig);
154 extern void GPIOPinTypeADC(uint32_t ui32Port, uint8_t ui8Pins);
155 extern void GPIOPinTypeCAN(uint32_t ui32Port, uint8_t ui8Pins);
156 extern void GPIOPinTypeComparator(uint32_t ui32Port, uint8_t ui8Pins);
157 extern void GPIOPinTypeEPI(uint32_t ui32Port, uint8_t ui8Pins);
158 extern void GPIOPinTypeEthernetLED(uint32_t ui32Port, uint8_t ui8Pins);
159 extern void GPIOPinTypeEthernetMII(uint32_t ui32Port, uint8_t ui8Pins);
160 extern void GPIOPinTypeFan(uint32_t ui32Port, uint8_t ui8Pins);
161 extern void GPIOPinTypeGPIOInput(uint32_t ui32Port, uint8_t ui8Pins);
162 extern void GPIOPinTypeGPIOOutput(uint32_t ui32Port, uint8_t ui8Pins);
163 extern void GPIOPinTypeGPIOOutputOD(uint32_t ui32Port, uint8_t ui8Pins);
164 extern void GPIOPinTypeI2C(uint32_t ui32Port, uint8_t ui8Pins);
165 extern void GPIOPinTypeI2CSCL(uint32_t ui32Port, uint8_t ui8Pins);
166 extern void GPIOPinTypeLPC(uint32_t ui32Port, uint8_t ui8Pins);
167 extern void GPIOPinTypePECIRx(uint32_t ui32Port, uint8_t ui8Pins);
168 extern void GPIOPinTypePECITx(uint32_t ui32Port, uint8_t ui8Pins);
169 extern void GPIOPinTypePWM(uint32_t ui32Port, uint8_t ui8Pins);
170 extern void GPIOPinTypeQEI(uint32_t ui32Port, uint8_t ui8Pins);
171 extern void GPIOPinTypeSSI(uint32_t ui32Port, uint8_t ui8Pins);
172 extern void GPIOPinTypeTimer(uint32_t ui32Port, uint8_t ui8Pins);
173 extern void GPIOPinTypeUART(uint32_t ui32Port, uint8_t ui8Pins);
174 extern void GPIOPinTypeUSBAnalog(uint32_t ui32Port, uint8_t ui8Pins);
175 extern void GPIOPinTypeUSBDigital(uint32_t ui32Port, uint8_t ui8Pins);
176 extern void GPIODMATriggerEnable(uint32_t ui32Port, uint8_t ui8Pins);
177 extern void GPIODMATriggerDisable(uint32_t ui32Port, uint8_t ui8Pins);
178 extern void GPIOADCTriggerEnable(uint32_t ui32Port, uint8_t ui8Pins);
179 extern void GPIOADCTriggerDisable(uint32_t ui32Port, uint8_t ui8Pins);
180 
181 //*****************************************************************************
182 //
183 // Mark the end of the C bindings section for C++ compilers.
184 //
185 //*****************************************************************************
186 #ifdef __cplusplus
187 }
188 #endif
189 
190 #endif // __DRIVERLIB_GPIO_H__
void GPIOIntTypeSet(uint32_t ui32Port, uint8_t ui8Pins, uint32_t ui32IntType)
Definition: gpio.c:350
void GPIOPinTypeEthernetMII(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1143
void GPIOPinWrite(uint32_t ui32Port, uint8_t ui8Pins, uint8_t ui8Val)
Definition: gpio.c:896
void GPIOPinTypeI2C(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1337
void GPIOPinTypeUART(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1715
void GPIOIntUnregister(uint32_t ui32Port)
Definition: gpio.c:815
void GPIOPinTypeEthernetLED(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1102
void GPIOIntDisable(uint32_t ui32Port, uint32_t ui32IntFlags)
Definition: gpio.c:661
uint32_t GPIODirModeGet(uint32_t ui32Port, uint8_t ui8Pin)
Definition: gpio.c:286
void GPIOPinTypeEPI(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1061
uint32_t GPIOIntTypeGet(uint32_t ui32Port, uint8_t ui8Pin)
Definition: gpio.c:402
void GPIODMATriggerDisable(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1939
void GPIOPadConfigSet(uint32_t ui32Port, uint8_t ui8Pins, uint32_t ui32Strength, uint32_t ui32PadType)
Definition: gpio.c:475
void GPIOADCTriggerDisable(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:2004
void GPIOPinTypePECITx(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1504
void GPIOPinTypeI2CSCL(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1379
void GPIOPinTypeUSBDigital(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1804
void GPIOIntEnable(uint32_t ui32Port, uint32_t ui32IntFlags)
Definition: gpio.c:622
void GPIOPinTypeLPC(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1421
void GPIOPadConfigGet(uint32_t ui32Port, uint8_t ui8Pin, uint32_t *pui32Strength, uint32_t *pui32PadType)
Definition: gpio.c:561
void GPIOIntRegister(uint32_t ui32Port, void(*pfnIntHandler)(void))
Definition: gpio.c:770
void GPIOPinTypePECIRx(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1462
void GPIOPinTypePWM(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1546
void GPIODMATriggerEnable(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1908
void GPIOPinTypeFan(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1185
void GPIOADCTriggerEnable(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1973
void GPIOPinTypeQEI(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1588
void GPIOPinTypeGPIOOutput(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1259
void GPIOPinTypeComparator(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1016
void GPIOPinConfigure(uint32_t ui32PinConfig)
Definition: gpio.c:1848
void GPIOPinTypeTimer(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1673
void GPIOPinTypeGPIOInput(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1222
void GPIOPinTypeADC(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:931
void GPIOPinTypeGPIOOutputOD(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1296
void GPIOPinTypeSSI(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1631
void GPIOPinTypeUSBAnalog(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1757
void GPIOIntClear(uint32_t ui32Port, uint32_t ui32IntFlags)
Definition: gpio.c:736
int32_t GPIOPinRead(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:864
void GPIOPinTypeCAN(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:974
void GPIODirModeSet(uint32_t ui32Port, uint8_t ui8Pins, uint32_t ui32PinIO)
Definition: gpio.c:246
uint32_t GPIOIntStatus(uint32_t ui32Port, bool bMasked)
Definition: gpio.c:691