TI-RTOS Drivers  tidrivers_full_2_20_00_08
GPIO.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2016, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
66 #ifndef ti_drivers_GPIO__include
67 #define ti_drivers_GPIO__include
68 
69 #ifdef __cplusplus
70 extern "C" {
71 #endif
72 
73 #include <stdint.h>
74 
84 typedef uint32_t GPIO_PinConfig;
85 
90 #define GPIO_CFG_IO_MASK 0x00ff0000
91 #define GPIO_CFG_IO_LSB 16
92 #define GPIO_CFG_OUT_TYPE_MASK 0x00060000
93 #define GPIO_CFG_OUT_TYPE_LSB 17
94 #define GPIO_CFG_IN_TYPE_MASK 0x00060000
95 #define GPIO_CFG_IN_TYPE_LSB 17
96 #define GPIO_CFG_OUT_STRENGTH_MASK 0x00f00000
97 #define GPIO_CFG_OUT_STRENGTH_LSB 20
98 #define GPIO_CFG_INT_MASK 0x07000000
99 #define GPIO_CFG_INT_LSB 24
100 #define GPIO_CFG_OUT_BIT 19
101 
106 #define GPIO_CFG_OUTPUT (((uint32_t) 0) << GPIO_CFG_IO_LSB)
107 #define GPIO_CFG_OUT_STD (((uint32_t) 0) << GPIO_CFG_IO_LSB)
108 #define GPIO_CFG_OUT_OD_NOPULL (((uint32_t) 2) << GPIO_CFG_IO_LSB)
109 #define GPIO_CFG_OUT_OD_PU (((uint32_t) 4) << GPIO_CFG_IO_LSB)
110 #define GPIO_CFG_OUT_OD_PD (((uint32_t) 6) << GPIO_CFG_IO_LSB)
112 #define GPIO_CFG_OUT_HIGH (((uint32_t) 1) << GPIO_CFG_OUT_BIT)
113 #define GPIO_CFG_OUT_LOW (((uint32_t) 0) << GPIO_CFG_OUT_BIT)
115 #define GPIO_CFG_OUT_STR_LOW (((uint32_t) 0) << GPIO_CFG_OUT_STRENGTH_LSB)
116 #define GPIO_CFG_OUT_STR_MED (((uint32_t) 1) << GPIO_CFG_OUT_STRENGTH_LSB)
117 #define GPIO_CFG_OUT_STR_HIGH (((uint32_t) 2) << GPIO_CFG_OUT_STRENGTH_LSB)
118 
119 #define GPIO_CFG_INPUT (((uint32_t) 1) << GPIO_CFG_IO_LSB)
120 #define GPIO_CFG_IN_NOPULL (((uint32_t) 1) << GPIO_CFG_IO_LSB)
121 #define GPIO_CFG_IN_PU (((uint32_t) 3) << GPIO_CFG_IO_LSB)
122 #define GPIO_CFG_IN_PD (((uint32_t) 5) << GPIO_CFG_IO_LSB)
128 #define GPIO_CFG_IN_INT_NONE (((uint32_t) 0) << GPIO_CFG_INT_LSB)
129 #define GPIO_CFG_IN_INT_FALLING (((uint32_t) 1) << GPIO_CFG_INT_LSB)
130 #define GPIO_CFG_IN_INT_RISING (((uint32_t) 2) << GPIO_CFG_INT_LSB)
131 #define GPIO_CFG_IN_INT_BOTH_EDGES (((uint32_t) 3) << GPIO_CFG_INT_LSB)
132 #define GPIO_CFG_IN_INT_LOW (((uint32_t) 4) << GPIO_CFG_INT_LSB)
133 #define GPIO_CFG_IN_INT_HIGH (((uint32_t) 5) << GPIO_CFG_INT_LSB)
144 #define GPIO_CFG_IN_INT_ONLY (((uint32_t) 1) << 27)
150 #define GPIO_DO_NOT_CONFIG 0x40000000
163 typedef void (*GPIO_CallbackFxn)(unsigned int index);
164 
175 extern void GPIO_clearInt(unsigned int index);
176 
184 extern void GPIO_disableInt(unsigned int index);
185 
199 extern void GPIO_enableInt(unsigned int index);
200 
211 extern void GPIO_init();
212 
223 extern unsigned int GPIO_read(unsigned int index);
224 
246 extern void GPIO_setCallback(unsigned int index, GPIO_CallbackFxn callback);
247 
261 extern void GPIO_setConfig(unsigned int index, GPIO_PinConfig pinConfig);
262 
268 extern void GPIO_toggle(unsigned int index);
269 
276 extern void GPIO_write(unsigned int index, unsigned int value);
277 
278 #ifdef __cplusplus
279 }
280 #endif
281 
282 #endif /* ti_drivers_GPIO__include */
void GPIO_disableInt(unsigned int index)
Disable a GPIO pin interrupt.
void GPIO_write(unsigned int index, unsigned int value)
Writes the value to a GPIO pin.
void GPIO_enableInt(unsigned int index)
Enable a GPIO pin interrupt.
unsigned int GPIO_read(unsigned int index)
Reads the value of a GPIO pin.
void GPIO_setConfig(unsigned int index, GPIO_PinConfig pinConfig)
Configure the gpio pin.
void(* GPIO_CallbackFxn)(unsigned int index)
GPIO callback function type.
Definition: GPIO.h:163
void GPIO_setCallback(unsigned int index, GPIO_CallbackFxn callback)
Bind a callback function to a GPIO pin interrupt.
void GPIO_clearInt(unsigned int index)
Clear a GPIO pin interrupt flag.
void GPIO_toggle(unsigned int index)
Toggles the current state of a GPIO.
uint32_t GPIO_PinConfig
GPIO pin configuration settings.
Definition: GPIO.h:84
void GPIO_init()
Initializes the GPIO module.
Copyright 2016, Texas Instruments Incorporated