PDK API Guide for J721E
GPIO.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2015, 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  */
32 
38 /* @} */
39 
82 #ifndef GPIO__H
83 #define GPIO__H
84 
85 #ifdef __cplusplus
86 extern "C" {
87 #endif
88 
89 #include <stdint.h>
90 
100 typedef uint32_t GPIO_PinConfig;
101 
106 #define GPIO_CFG_IO_MASK 0x00ff0000U
107 #define GPIO_CFG_IO_LSB 16U
108 #define GPIO_CFG_OUT_TYPE_MASK 0x00060000U
109 #define GPIO_CFG_OUT_TYPE_LSB 17U
110 #define GPIO_CFG_IN_TYPE_MASK 0x00060000U
111 #define GPIO_CFG_IN_TYPE_LSB 17U
112 #define GPIO_CFG_OUT_STRENGTH_MASK 0x00f00000U
113 #define GPIO_CFG_OUT_STRENGTH_LSB 20U
114 #define GPIO_CFG_INT_MASK 0x07000000U
115 #define GPIO_CFG_INT_LSB 24U
116 #define GPIO_CFG_OUT_BIT 19U
117 
118 
119 
125 #define GPIO_CFG_OUTPUT (((uint32_t) 0) << GPIO_CFG_IO_LSB)
126 #define GPIO_CFG_OUT_STD (((uint32_t) 0) << GPIO_CFG_IO_LSB)
127 #define GPIO_CFG_OUT_OD_NOPULL (((uint32_t) 2) << GPIO_CFG_IO_LSB)
128 #define GPIO_CFG_OUT_OD_PU (((uint32_t) 4) << GPIO_CFG_IO_LSB)
129 #define GPIO_CFG_OUT_OD_PD (((uint32_t) 6) << GPIO_CFG_IO_LSB)
131 #define GPIO_CFG_OUT_HIGH (((uint32_t) 1) << GPIO_CFG_OUT_BIT)
132 #define GPIO_CFG_OUT_LOW (((uint32_t) 0) << GPIO_CFG_OUT_BIT)
134 #define GPIO_CFG_OUT_STR_LOW (((uint32_t) 0) << GPIO_CFG_OUT_STRENGTH_LSB)
135 #define GPIO_CFG_OUT_STR_MED (((uint32_t) 1) << GPIO_CFG_OUT_STRENGTH_LSB)
136 #define GPIO_CFG_OUT_STR_HIGH (((uint32_t) 2) << GPIO_CFG_OUT_STRENGTH_LSB)
137 
138 #define GPIO_CFG_INPUT (((uint32_t) 1) << GPIO_CFG_IO_LSB)
139 #define GPIO_CFG_IN_NOPULL (((uint32_t) 1) << GPIO_CFG_IO_LSB)
140 #define GPIO_CFG_IN_PU (((uint32_t) 3) << GPIO_CFG_IO_LSB)
141 #define GPIO_CFG_IN_PD (((uint32_t) 5) << GPIO_CFG_IO_LSB)
147 #define GPIO_CFG_IN_INT_NONE (((uint32_t) 0) << GPIO_CFG_INT_LSB)
148 #define GPIO_CFG_IN_INT_FALLING (((uint32_t) 1) << GPIO_CFG_INT_LSB)
149 #define GPIO_CFG_IN_INT_RISING (((uint32_t) 2) << GPIO_CFG_INT_LSB)
150 #define GPIO_CFG_IN_INT_BOTH_EDGES (((uint32_t) 3) << GPIO_CFG_INT_LSB)
151 #define GPIO_CFG_IN_INT_LOW (((uint32_t) 4) << GPIO_CFG_INT_LSB)
152 #define GPIO_CFG_IN_INT_HIGH (((uint32_t) 5) << GPIO_CFG_INT_LSB)
163 #define GPIO_CFG_IN_INT_ONLY (((uint32_t) 1) << 27)
169 #define GPIO_DO_NOT_CONFIG 0x7fff0001U
176 typedef void (*GPIO_CallbackFxn)(void);
177 
181 typedef void (*GPIO_InitFxn) (void);
182 
186 typedef uint32_t (*GPIO_ReadFxn) (uint32_t idx);
187 
191 typedef void (*GPIO_WriteFxn) (uint32_t idx,
192  uint32_t value);
193 
197 typedef void (*GPIO_clearIntFxn) (uint32_t idx);
198 
202 typedef void (*GPIO_disableIntFxn) (uint32_t idx);
203 
207 typedef void (*GPIO_enableIntFxn) (uint32_t idx);
208 
212 typedef void (*GPIO_setCallbackFxn) (uint32_t idx,
213  GPIO_CallbackFxn callback);
214 
218 typedef void (*GPIO_setConfigFxn) (uint32_t idx,
219  GPIO_PinConfig pinConfig);
225 typedef void (*GPIO_toggleFxn) (uint32_t idx);
226 
232  typedef struct GPIO_FxnTable_s {
251 
252 } GPIO_FxnTable;
253 
254 
256 typedef struct GPIO_Config_s {
259 
261  void *object;
262 
264  void const *hwAttrs;
265 } GPIO_Config;
266 
267 /* Avoid Misra warning "MISRA.DECL.ARRAY_SIZE" by pairing config array type
268  * with its array size to avoid externs with [] (no size) */
269 #define GPIO_MAX_CONFIG_CNT (3U)
271 
282 extern void GPIO_clearInt(uint32_t idx);
283 
291 extern void GPIO_disableInt(uint32_t idx);
292 
306 extern void GPIO_enableInt(uint32_t idx);
307 
318 extern void GPIO_init(void);
319 
330 extern uint32_t GPIO_read(uint32_t idx);
331 
353 extern void GPIO_setCallback(uint32_t idx, GPIO_CallbackFxn callback);
354 
368 extern void GPIO_setConfig(uint32_t idx, GPIO_PinConfig pinConfig);
369 
375 extern void GPIO_toggle(uint32_t idx);
376 
383 extern void GPIO_write(uint32_t idx, uint32_t value);
384 
385 #ifdef __cplusplus
386 }
387 #endif
388 
389 #endif /* _GPIO_H */
390 
391 /* @} */
void * object
Definition: GPIO.h:261
void GPIO_setConfig(uint32_t idx, GPIO_PinConfig pinConfig)
Configure the gpio pin.
void GPIO_init(void)
Initializes the GPIO module.
void GPIO_write(uint32_t idx, uint32_t value)
Writes the value to a GPIO pin.
The definition of a GPIO function table that contains the required set of functions to control a spec...
Definition: GPIO.h:232
GPIO_setConfigFxn setConfigFxn
Definition: GPIO.h:248
GPIO_clearIntFxn clearIntFxn
Definition: GPIO.h:240
void(* GPIO_clearIntFxn)(uint32_t idx)
Clear a GPIO pin interrupt flag.
Definition: GPIO.h:197
GPIO_InitFxn initFxn
Definition: GPIO.h:234
void(* GPIO_setConfigFxn)(uint32_t idx, GPIO_PinConfig pinConfig)
Configure the gpio pin.
Definition: GPIO.h:218
uint32_t(* GPIO_ReadFxn)(uint32_t idx)
Reads the value of a GPIO pin.
Definition: GPIO.h:186
uint32_t value
Definition: tisci_otp_revision.h:199
void(* GPIO_enableIntFxn)(uint32_t idx)
Enable a GPIO pin interrupt.
Definition: GPIO.h:207
GPIO Global configuration.
Definition: GPIO.h:256
void(* GPIO_InitFxn)(void)
Initializes the GPIO module.
Definition: GPIO.h:181
void GPIO_setCallback(uint32_t idx, GPIO_CallbackFxn callback)
Bind a callback function to a GPIO pin interrupt.
GPIO_Config GPIOConfigList[GPIO_MAX_CONFIG_CNT]
Definition: GPIO.h:270
void(* GPIO_CallbackFxn)(void)
GPIO callback function type.
Definition: GPIO.h:176
GPIO_toggleFxn toggleFxn
Definition: GPIO.h:250
GPIO_WriteFxn writeFxn
Definition: GPIO.h:238
void GPIO_toggle(uint32_t idx)
Toggles the current state of a GPIO.
GPIO_FxnTable const * fxnTablePtr
Definition: GPIO.h:258
void(* GPIO_setCallbackFxn)(uint32_t idx, GPIO_CallbackFxn callback)
Bind a callback function to a GPIO pin interrupt.
Definition: GPIO.h:212
uint32_t GPIO_PinConfig
GPIO pin configuration settings.
Definition: GPIO.h:100
GPIO_ReadFxn readFxn
Definition: GPIO.h:236
void GPIO_clearInt(uint32_t idx)
Clear a GPIO pin interrupt flag.
void(* GPIO_WriteFxn)(uint32_t idx, uint32_t value)
Writes the value to a GPIO pin.
Definition: GPIO.h:191
void(* GPIO_disableIntFxn)(uint32_t idx)
Disable a GPIO pin interrupt.
Definition: GPIO.h:202
GPIO_disableIntFxn disableIntFxn
Definition: GPIO.h:242
void const * hwAttrs
Definition: GPIO.h:264
void GPIO_enableInt(uint32_t idx)
Enable a GPIO pin interrupt.
void GPIO_disableInt(uint32_t idx)
Disable a GPIO pin interrupt.
GPIO_enableIntFxn enableIntFxn
Definition: GPIO.h:244
uint32_t GPIO_read(uint32_t idx)
Reads the value of a GPIO pin.
GPIO_setCallbackFxn setCallbackFxn
Definition: GPIO.h:246
#define GPIO_MAX_CONFIG_CNT
Definition: GPIO.h:269
void(* GPIO_toggleFxn)(uint32_t idx)
Toggles the current state of a GPIO.
Definition: GPIO.h:225