GPIO.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2018, 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  */
218 #ifndef ti_drivers_GPIO__include
219 #define ti_drivers_GPIO__include
220 
221 #ifdef __cplusplus
222 extern "C" {
223 #endif
224 
225 #include <stdint.h>
226 
245 #define GPIO_STATUS_RESERVED (-32)
246 
253 #define GPIO_STATUS_SUCCESS (0)
254 
261 #define GPIO_STATUS_ERROR (-1)
262 
273 typedef uint32_t GPIO_PinConfig;
274 
279 #define GPIO_CFG_IO_MASK 0x00ff0000
280 #define GPIO_CFG_IO_LSB 16
281 #define GPIO_CFG_OUT_TYPE_MASK 0x00060000
282 #define GPIO_CFG_OUT_TYPE_LSB 17
283 #define GPIO_CFG_IN_TYPE_MASK 0x00060000
284 #define GPIO_CFG_IN_TYPE_LSB 17
285 #define GPIO_CFG_OUT_STRENGTH_MASK 0x00f00000
286 #define GPIO_CFG_OUT_STRENGTH_LSB 20
287 #define GPIO_CFG_INT_MASK 0x07000000
288 #define GPIO_CFG_INT_LSB 24
289 #define GPIO_CFG_OUT_BIT 19
290 
299 #define GPIO_CFG_OUTPUT (((uint32_t) 0) << GPIO_CFG_IO_LSB)
300 #define GPIO_CFG_OUT_STD (((uint32_t) 0) << GPIO_CFG_IO_LSB)
301 #define GPIO_CFG_OUT_OD_NOPULL (((uint32_t) 2) << GPIO_CFG_IO_LSB)
302 #define GPIO_CFG_OUT_OD_PU (((uint32_t) 4) << GPIO_CFG_IO_LSB)
303 #define GPIO_CFG_OUT_OD_PD (((uint32_t) 6) << GPIO_CFG_IO_LSB)
305 #define GPIO_CFG_OUT_STR_LOW (((uint32_t) 0) << GPIO_CFG_OUT_STRENGTH_LSB)
306 #define GPIO_CFG_OUT_STR_MED (((uint32_t) 1) << GPIO_CFG_OUT_STRENGTH_LSB)
307 #define GPIO_CFG_OUT_STR_HIGH (((uint32_t) 2) << GPIO_CFG_OUT_STRENGTH_LSB)
309 #define GPIO_CFG_OUT_HIGH (((uint32_t) 1) << GPIO_CFG_OUT_BIT)
310 #define GPIO_CFG_OUT_LOW (((uint32_t) 0) << GPIO_CFG_OUT_BIT)
316 #define GPIO_CFG_INPUT (((uint32_t) 1) << GPIO_CFG_IO_LSB)
317 #define GPIO_CFG_IN_NOPULL (((uint32_t) 1) << GPIO_CFG_IO_LSB)
318 #define GPIO_CFG_IN_PU (((uint32_t) 3) << GPIO_CFG_IO_LSB)
319 #define GPIO_CFG_IN_PD (((uint32_t) 5) << GPIO_CFG_IO_LSB)
325 #define GPIO_CFG_IN_INT_NONE (((uint32_t) 0) << GPIO_CFG_INT_LSB)
326 #define GPIO_CFG_IN_INT_FALLING (((uint32_t) 1) << GPIO_CFG_INT_LSB)
327 #define GPIO_CFG_IN_INT_RISING (((uint32_t) 2) << GPIO_CFG_INT_LSB)
328 #define GPIO_CFG_IN_INT_BOTH_EDGES (((uint32_t) 3) << GPIO_CFG_INT_LSB)
329 #define GPIO_CFG_IN_INT_LOW (((uint32_t) 4) << GPIO_CFG_INT_LSB)
330 #define GPIO_CFG_IN_INT_HIGH (((uint32_t) 5) << GPIO_CFG_INT_LSB)
341 #define GPIO_CFG_IN_INT_ONLY (((uint32_t) 1) << 27)
347 #define GPIO_DO_NOT_CONFIG 0x40000000
361 typedef void (*GPIO_CallbackFxn)(uint_least8_t index);
362 
373 extern void GPIO_clearInt(uint_least8_t index);
374 
382 extern void GPIO_disableInt(uint_least8_t index);
383 
397 extern void GPIO_enableInt(uint_least8_t index);
398 
410 extern void GPIO_getConfig(uint_least8_t index, GPIO_PinConfig *pinConfig);
411 
422 extern void GPIO_init();
423 
434 extern uint_fast8_t GPIO_read(uint_least8_t index);
435 
457 extern void GPIO_setCallback(uint_least8_t index, GPIO_CallbackFxn callback);
458 
472 extern int_fast16_t GPIO_setConfig(uint_least8_t index,
473  GPIO_PinConfig pinConfig);
474 
480 extern void GPIO_toggle(uint_least8_t index);
481 
488 extern void GPIO_write(uint_least8_t index, unsigned int value);
489 
490 #ifdef __cplusplus
491 }
492 #endif
493 
494 #endif /* ti_drivers_GPIO__include */
void GPIO_write(uint_least8_t index, unsigned int value)
Writes the value to a GPIO pin.
void GPIO_clearInt(uint_least8_t index)
Clear a GPIO pin interrupt flag.
void GPIO_toggle(uint_least8_t index)
Toggles the current state of a GPIO.
void GPIO_enableInt(uint_least8_t index)
Enable a GPIO pin interrupt.
uint32_t GPIO_PinConfig
GPIO pin configuration settings.
Definition: GPIO.h:273
void GPIO_getConfig(uint_least8_t index, GPIO_PinConfig *pinConfig)
Get the current configuration for a gpio pin.
void GPIO_init()
Initializes the GPIO module.
int_fast16_t GPIO_setConfig(uint_least8_t index, GPIO_PinConfig pinConfig)
Configure the gpio pin.
void GPIO_setCallback(uint_least8_t index, GPIO_CallbackFxn callback)
Bind a callback function to a GPIO pin interrupt.
uint_fast8_t GPIO_read(uint_least8_t index)
Reads the value of a GPIO pin.
void GPIO_disableInt(uint_least8_t index)
Disable a GPIO pin interrupt.
void(* GPIO_CallbackFxn)(uint_least8_t index)
GPIO callback function type.
Definition: GPIO.h:361
© Copyright 1995-2018, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale