gpio.h
Go to the documentation of this file.
1 //*****************************************************************************
2 //
3 // gpio.h - Defines and Macros for GPIO API.
4 //
5 // Copyright (c) 2005-2017 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 //*****************************************************************************
37 
38 #ifndef __DRIVERLIB_GPIO_H__
39 #define __DRIVERLIB_GPIO_H__
40 
41 #include <stdint.h>
42 #include <stdbool.h>
43 
44 //*****************************************************************************
45 //
46 // If building with a C++ compiler, make all of the definitions in this header
47 // have a C binding.
48 //
49 //*****************************************************************************
50 #ifdef __cplusplus
51 extern "C"
52 {
53 #endif
54 
55 //*****************************************************************************
56 //
57 // The following values define the bit field for the ui8Pins argument to
58 // several of the APIs.
59 //
60 //*****************************************************************************
61 #define GPIO_PIN_0 0x00000001 // GPIO pin 0
62 #define GPIO_PIN_1 0x00000002 // GPIO pin 1
63 #define GPIO_PIN_2 0x00000004 // GPIO pin 2
64 #define GPIO_PIN_3 0x00000008 // GPIO pin 3
65 #define GPIO_PIN_4 0x00000010 // GPIO pin 4
66 #define GPIO_PIN_5 0x00000020 // GPIO pin 5
67 #define GPIO_PIN_6 0x00000040 // GPIO pin 6
68 #define GPIO_PIN_7 0x00000080 // GPIO pin 7
69 
70 //*****************************************************************************
71 //
72 // Values that can be passed to GPIODirModeSet as the ui32PinIO parameter, and
73 // returned from GPIODirModeGet.
74 //
75 //*****************************************************************************
76 #define GPIO_DIR_MODE_IN 0x00000000 // Pin is a GPIO input
77 #define GPIO_DIR_MODE_OUT 0x00000001 // Pin is a GPIO output
78 #define GPIO_DIR_MODE_HW 0x00000002 // Pin is a peripheral function
79 
80 //*****************************************************************************
81 //
82 // Values that can be passed to GPIOIntTypeSet as the ui32IntType parameter,
83 // and returned from GPIOIntTypeGet.
84 //
85 //*****************************************************************************
86 #define GPIO_FALLING_EDGE 0x00000000 // Interrupt on falling edge
87 #define GPIO_RISING_EDGE 0x00000004 // Interrupt on rising edge
88 #define GPIO_BOTH_EDGES 0x00000001 // Interrupt on both edges
89 #define GPIO_LOW_LEVEL 0x00000002 // Interrupt on low level
90 #define GPIO_HIGH_LEVEL 0x00000006 // Interrupt on high level
91 #define GPIO_DISCRETE_INT 0x00010000 // Interrupt for individual pins
92 
93 //*****************************************************************************
94 //
95 // Values that can be passed to GPIOPadConfigSet as the ui32Strength parameter,
96 // and returned by GPIOPadConfigGet in the *pui32Strength parameter.
97 //
98 //*****************************************************************************
99 #define GPIO_STRENGTH_2MA 0x00000001 // 2mA drive strength
100 #define GPIO_STRENGTH_4MA 0x00000002 // 4mA drive strength
101 #define GPIO_STRENGTH_6MA 0x00000065 // 6mA drive strength
102 #define GPIO_STRENGTH_8MA 0x00000066 // 8mA drive strength
103 #define GPIO_STRENGTH_8MA_SC 0x0000006E // 8mA drive with slew rate control
104 #define GPIO_STRENGTH_10MA 0x00000075 // 10mA drive strength
105 #define GPIO_STRENGTH_12MA 0x00000077 // 12mA drive strength
106 
107 //*****************************************************************************
108 //
109 // Values that can be passed to GPIOPadConfigSet as the ui32PadType parameter,
110 // and returned by GPIOPadConfigGet in the *pui32PadType parameter.
111 //
112 //*****************************************************************************
113 #define GPIO_PIN_TYPE_STD 0x00000008 // Push-pull
114 #define GPIO_PIN_TYPE_STD_WPU 0x0000000A // Push-pull with weak pull-up
115 #define GPIO_PIN_TYPE_STD_WPD 0x0000000C // Push-pull with weak pull-down
116 #define GPIO_PIN_TYPE_OD 0x00000009 // Open-drain
117 #define GPIO_PIN_TYPE_ANALOG 0x00000000 // Analog comparator
118 #define GPIO_PIN_TYPE_WAKE_HIGH 0x00000208 // Hibernate wake, high
119 #define GPIO_PIN_TYPE_WAKE_LOW 0x00000108 // Hibernate wake, low
120 
121 //*****************************************************************************
122 //
123 // Values that can be passed to GPIOIntEnable() and GPIOIntDisable() functions
124 // in the ui32IntFlags parameter.
125 //
126 //*****************************************************************************
127 #define GPIO_INT_PIN_0 0x00000001
128 #define GPIO_INT_PIN_1 0x00000002
129 #define GPIO_INT_PIN_2 0x00000004
130 #define GPIO_INT_PIN_3 0x00000008
131 #define GPIO_INT_PIN_4 0x00000010
132 #define GPIO_INT_PIN_5 0x00000020
133 #define GPIO_INT_PIN_6 0x00000040
134 #define GPIO_INT_PIN_7 0x00000080
135 #define GPIO_INT_DMA 0x00000100
136 
137 //*****************************************************************************
138 //
139 // Prototypes for the APIs.
140 //
141 //*****************************************************************************
142 extern void GPIODirModeSet(uint32_t ui32Port, uint8_t ui8Pins,
143  uint32_t ui32PinIO);
144 extern uint32_t GPIODirModeGet(uint32_t ui32Port, uint8_t ui8Pin);
145 extern void GPIOIntTypeSet(uint32_t ui32Port, uint8_t ui8Pins,
146  uint32_t ui32IntType);
147 extern uint32_t GPIOIntTypeGet(uint32_t ui32Port, uint8_t ui8Pin);
148 extern void GPIOPadConfigSet(uint32_t ui32Port, uint8_t ui8Pins,
149  uint32_t ui32Strength, uint32_t ui32PadType);
150 extern void GPIOPadConfigGet(uint32_t ui32Port, uint8_t ui8Pin,
151  uint32_t *pui32Strength, uint32_t *pui32PadType);
152 extern void GPIOIntEnable(uint32_t ui32Port, uint32_t ui32IntFlags);
153 extern void GPIOIntDisable(uint32_t ui32Port, uint32_t ui32IntFlags);
154 extern uint32_t GPIOIntStatus(uint32_t ui32Port, bool bMasked);
155 extern void GPIOIntClear(uint32_t ui32Port, uint32_t ui32IntFlags);
156 extern void GPIOIntRegister(uint32_t ui32Port, void (*pfnIntHandler)(void));
157 extern void GPIOIntUnregister(uint32_t ui32Port);
158 extern void GPIOIntRegisterPin(uint32_t ui32Port, uint32_t ui32Pin,
159  void (*pfnIntHandler)(void));
160 extern void GPIOIntUnregisterPin(uint32_t ui32Port, uint32_t ui32Pin);
161 extern int32_t GPIOPinRead(uint32_t ui32Port, uint8_t ui8Pins);
162 extern void GPIOPinWrite(uint32_t ui32Port, uint8_t ui8Pins, uint8_t ui8Val);
163 extern void GPIOPinConfigure(uint32_t ui32PinConfig);
164 extern void GPIOPinTypeADC(uint32_t ui32Port, uint8_t ui8Pins);
165 extern void GPIOPinTypeCAN(uint32_t ui32Port, uint8_t ui8Pins);
166 extern void GPIOPinTypeComparator(uint32_t ui32Port, uint8_t ui8Pins);
167 extern void GPIOPinTypeComparatorOutput(uint32_t ui32Port, uint8_t ui8Pins);
168 extern void GPIOPinTypeDIVSCLK(uint32_t ui32Port, uint8_t ui8Pins);
169 extern void GPIOPinTypeEPI(uint32_t ui32Port, uint8_t ui8Pins);
170 extern void GPIOPinTypeEthernetLED(uint32_t ui32Port, uint8_t ui8Pins);
171 extern void GPIOPinTypeEthernetMII(uint32_t ui32Port, uint8_t ui8Pins);
172 extern void GPIOPinTypeGPIOInput(uint32_t ui32Port, uint8_t ui8Pins);
173 extern void GPIOPinTypeGPIOOutput(uint32_t ui32Port, uint8_t ui8Pins);
174 extern void GPIOPinTypeGPIOOutputOD(uint32_t ui32Port, uint8_t ui8Pins);
175 extern void GPIOPinTypeHibernateRTCCLK(uint32_t ui32Port, uint8_t ui8Pins);
176 extern void GPIOPinTypeI2C(uint32_t ui32Port, uint8_t ui8Pins);
177 extern void GPIOPinTypeI2CSCL(uint32_t ui32Port, uint8_t ui8Pins);
178 extern void GPIOPinTypeLCD(uint32_t ui32Port, uint8_t ui8Pins);
179 extern void GPIOPinTypeOneWire(uint32_t ui32Port, uint8_t ui8Pins);
180 extern void GPIOPinTypePWM(uint32_t ui32Port, uint8_t ui8Pins);
181 extern void GPIOPinTypeQEI(uint32_t ui32Port, uint8_t ui8Pins);
182 extern void GPIOPinTypeSSI(uint32_t ui32Port, uint8_t ui8Pins);
183 extern void GPIOPinTypeTimer(uint32_t ui32Port, uint8_t ui8Pins);
184 extern void GPIOPinTypeTrace(uint32_t ui32Port, uint8_t ui8Pins);
185 extern void GPIOPinTypeUART(uint32_t ui32Port, uint8_t ui8Pins);
186 extern void GPIOPinTypeUSBAnalog(uint32_t ui32Port, uint8_t ui8Pins);
187 extern void GPIOPinTypeUSBDigital(uint32_t ui32Port, uint8_t ui8Pins);
188 extern void GPIOPinTypeWakeHigh(uint32_t ui32Port, uint8_t ui8Pins);
189 extern void GPIOPinTypeWakeLow(uint32_t ui32Port, uint8_t ui8Pins);
190 extern uint32_t GPIOPinWakeStatus(uint32_t ui32Port);
191 extern void GPIODMATriggerEnable(uint32_t ui32Port, uint8_t ui8Pins);
192 extern void GPIODMATriggerDisable(uint32_t ui32Port, uint8_t ui8Pins);
193 extern void GPIOADCTriggerEnable(uint32_t ui32Port, uint8_t ui8Pins);
194 extern void GPIOADCTriggerDisable(uint32_t ui32Port, uint8_t ui8Pins);
195 
196 //*****************************************************************************
197 //
198 // Mark the end of the C bindings section for C++ compilers.
199 //
200 //*****************************************************************************
201 #ifdef __cplusplus
202 }
203 #endif
204 
205 #endif // __DRIVERLIB_GPIO_H__
void GPIOIntTypeSet(uint32_t ui32Port, uint8_t ui8Pins, uint32_t ui32IntType)
Definition: gpio.c:349
void GPIOIntUnregisterPin(uint32_t ui32Port, uint32_t ui32Pin)
Definition: gpio.c:991
void GPIOPinTypeWakeHigh(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:2227
void GPIOPinTypeEthernetMII(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1430
void GPIOPinWrite(uint32_t ui32Port, uint8_t ui8Pins, uint8_t ui8Val)
Definition: gpio.c:1071
void GPIOPinTypeI2C(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1643
void GPIOPinTypeUART(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:2083
void GPIOIntUnregister(uint32_t ui32Port)
Definition: gpio.c:897
void GPIOPinTypeEthernetLED(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1382
void GPIOIntDisable(uint32_t ui32Port, uint32_t ui32IntFlags)
Definition: gpio.c:743
uint32_t GPIODirModeGet(uint32_t ui32Port, uint8_t ui8Pin)
Definition: gpio.c:287
void GPIOPinTypeEPI(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1334
uint32_t GPIOIntTypeGet(uint32_t ui32Port, uint8_t ui8Pin)
Definition: gpio.c:403
void GPIODMATriggerDisable(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:2416
void GPIOPadConfigSet(uint32_t ui32Port, uint8_t ui8Pins, uint32_t ui32Strength, uint32_t ui32PadType)
Definition: gpio.c:492
void GPIOADCTriggerDisable(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:2475
void GPIOPinTypeI2CSCL(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1691
void GPIOPinTypeUSBDigital(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:2184
void GPIOIntEnable(uint32_t ui32Port, uint32_t ui32IntFlags)
Definition: gpio.c:703
void GPIOPadConfigGet(uint32_t ui32Port, uint8_t ui8Pin, uint32_t *pui32Strength, uint32_t *pui32PadType)
Definition: gpio.c:624
void GPIOIntRegister(uint32_t ui32Port, void(*pfnIntHandler)(void))
Definition: gpio.c:852
void GPIOIntRegisterPin(uint32_t ui32Port, uint32_t ui32Pin, void(*pfnIntHandler)(void))
Definition: gpio.c:945
void GPIOPinTypeOneWire(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1789
void GPIOPinTypePWM(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1838
void GPIODMATriggerEnable(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:2388
void GPIOADCTriggerEnable(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:2447
void GPIOPinTypeQEI(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1887
void GPIOPinTypeLCD(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1740
void GPIOPinTypeGPIOOutput(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1516
void GPIOPinTypeComparator(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1210
void GPIOPinTypeWakeLow(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:2271
void GPIOPinConfigure(uint32_t ui32PinConfig)
Definition: gpio.c:2339
void GPIOPinTypeTimer(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1986
void GPIOPinTypeGPIOInput(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1473
void GPIOPinTypeADC(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1112
void GPIOPinTypeGPIOOutputOD(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1559
uint32_t GPIOPinWakeStatus(uint32_t ui32Port)
Definition: gpio.c:2309
void GPIOPinTypeTrace(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:2034
void GPIOPinTypeSSI(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1937
void GPIOPinTypeUSBAnalog(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:2131
void GPIOPinTypeComparatorOutput(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1247
void GPIOIntClear(uint32_t ui32Port, uint32_t ui32IntFlags)
Definition: gpio.c:818
void GPIOPinTypeHibernateRTCCLK(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1595
int32_t GPIOPinRead(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1039
void GPIOPinTypeCAN(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1162
void GPIODirModeSet(uint32_t ui32Port, uint8_t ui8Pins, uint32_t ui32PinIO)
Definition: gpio.c:247
uint32_t GPIOIntStatus(uint32_t ui32Port, bool bMasked)
Definition: gpio.c:773
void GPIOPinTypeDIVSCLK(uint32_t ui32Port, uint8_t ui8Pins)
Definition: gpio.c:1283
Copyright 2017, Texas Instruments Incorporated