AM273x MCU+ SDK  09.02.00
gpio/v1/gpio.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 Texas Instruments Incorporated
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * 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
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
53 #ifndef GPIO_H_
54 #define GPIO_H_
55 
56 /* ========================================================================== */
57 /* Include Files */
58 /* ========================================================================== */
59 
60 #include <drivers/hw_include/cslr.h>
61 #include <drivers/hw_include/cslr_gpio.h>
62 #include <kernel/dpl/SystemP.h>
63 
64 #ifdef __cplusplus
65 extern "C" {
66 #endif
67 
68 /* ========================================================================== */
69 /* Macros & Typedefs */
70 /* ========================================================================== */
71 
78 #define GPIO_PIN_LOW (0U)
79 
80 #define GPIO_PIN_HIGH (1U)
81 
89 #define GPIO_DIRECTION_OUTPUT (1U)
90 
91 #define GPIO_DIRECTION_INPUT (0U)
92 
100 #define GPIO_OPEN_DRAIN_ENABLE (1U)
101 
102 #define GPIO_OPEN_DRAIN_DISABLE (0U)
103 
111 #define GPIO_TRIG_TYPE_NONE (0U)
112 
113 #define GPIO_TRIG_TYPE_RISE_EDGE (1U)
114 
115 #define GPIO_TRIG_TYPE_FALL_EDGE (2U)
116 
117 #define GPIO_TRIG_TYPE_BOTH_EDGE (3U)
118 
126 #define GPIO_INTR_LEVEL_LOW (0U)
127 
128 #define GPIO_INTR_LEVEL_HIGH (1U)
129 
132 #define GPIO_MAX_PORT (8U)
133 
139 #define GPIO_MAX_INTERRUPT_PORT (4U)
140 
146 #define GPIO_MAX_PINS_PER_PORT (8U)
147 
149 #define GPIO_MAX_PINS (GPIO_MAX_PORT * GPIO_MAX_PINS_PER_PORT)
150 
158 #define GPIO_MAX_INTERRUPT (GPIO_MAX_INTERRUPT_PORT * GPIO_MAX_PINS_PER_PORT)
159 
161 #define GPIO_GET_PIN_OFFSET(pinNum) (((uint32_t)pinNum) % (GPIO_MAX_PORT * GPIO_MAX_PINS_PER_PORT))
162 
163 #define GPIO_GET_PORT_NUM(pinNum) ((GPIO_GET_PIN_OFFSET(pinNum)) / GPIO_MAX_PINS_PER_PORT)
164 
165 #define GPIO_GET_PIN_INDEX(pinNum) ((GPIO_GET_PIN_OFFSET(pinNum)) % GPIO_MAX_PINS_PER_PORT)
166 
167 /* ========================================================================== */
168 /* Structure Declarations */
169 /* ========================================================================== */
170 
171 /* None */
172 
173 /* ========================================================================== */
174 /* Function Declarations */
175 /* ========================================================================== */
176 
183 void GPIO_moduleEnable(uint32_t baseAddr);
184 
199 int32_t GPIO_ignoreOrHonorPolarity(uint32_t baseAddr, uint32_t pinNum, uint32_t polLevel);
200 
215 int32_t GPIO_setTrigType(uint32_t baseAddr, uint32_t pinNum, uint32_t polLevel);
216 
227 int32_t GPIO_enableInterrupt(uint32_t baseAddr, uint32_t pinNum);
228 
239 int32_t GPIO_disableInterrupt(uint32_t baseAddr, uint32_t pinNum);
240 
241 
252 int32_t GPIO_clearInterrupt(uint32_t baseAddr, uint32_t pinNum);
253 
268 int32_t GPIO_markHighLowLevelInterrupt(uint32_t baseAddr, uint32_t pinNum, uint32_t interruptLevel);
269 
284 uint32_t GPIO_getHighLowLevelPendingInterrupt(uint32_t baseAddr, uint32_t interruptLevel);
285 
299 void GPIO_setDirMode(uint32_t baseAddr, uint32_t pinNum, uint32_t pinDir);
300 
312 uint32_t GPIO_pinRead(uint32_t baseAddr, uint32_t pinNum);
313 
323 void GPIO_pinWriteHigh(uint32_t baseAddr, uint32_t pinNum);
324 
325 
335 void GPIO_pinWriteLow(uint32_t baseAddr, uint32_t pinNum);
336 
337 
352 void GPIO_setOpenDrainStatus(uint32_t baseAddr, uint32_t pinNum, uint32_t openDrainStatus);
353 
354 #ifdef __cplusplus
355 }
356 #endif
357 
358 #endif /* #ifndef GPIO_H_ */
359 
SystemP.h
GPIO_pinWriteLow
void GPIO_pinWriteLow(uint32_t baseAddr, uint32_t pinNum)
The function is used to write logic LOW state to a specific GPIO Port/Pin.
GPIO_disableInterrupt
int32_t GPIO_disableInterrupt(uint32_t baseAddr, uint32_t pinNum)
The function is used to disable the interrupt on the GPIO Pin.
GPIO_clearInterrupt
int32_t GPIO_clearInterrupt(uint32_t baseAddr, uint32_t pinNum)
The function is used to clear the interrupt on the GPIO Pin.
GPIO_pinWriteHigh
void GPIO_pinWriteHigh(uint32_t baseAddr, uint32_t pinNum)
The function is used to write logic HIGH state to a to a specific GPIO Pin.
GPIO_setDirMode
void GPIO_setDirMode(uint32_t baseAddr, uint32_t pinNum, uint32_t pinDir)
The function is used to set the output data direction associated with a GPIO Pin.
GPIO_enableInterrupt
int32_t GPIO_enableInterrupt(uint32_t baseAddr, uint32_t pinNum)
The function is used to enable the interrupt on the GPIO Pin.
GPIO_setTrigType
int32_t GPIO_setTrigType(uint32_t baseAddr, uint32_t pinNum, uint32_t polLevel)
The function is used to configure the GPIO Pin to control the interrupt polarity.
GPIO_ignoreOrHonorPolarity
int32_t GPIO_ignoreOrHonorPolarity(uint32_t baseAddr, uint32_t pinNum, uint32_t polLevel)
The function is used to configure the GPIO Pin to ignore or honor polarity.
GPIO_markHighLowLevelInterrupt
int32_t GPIO_markHighLowLevelInterrupt(uint32_t baseAddr, uint32_t pinNum, uint32_t interruptLevel)
The function is used to mark the interrupt as high level or low level for the specific GPIO Pin.
GPIO_moduleEnable
void GPIO_moduleEnable(uint32_t baseAddr)
This API performs the module enable of the GPIO module.
GPIO_setOpenDrainStatus
void GPIO_setOpenDrainStatus(uint32_t baseAddr, uint32_t pinNum, uint32_t openDrainStatus)
The function is used to enable/disable open drain functionality for a specific GPIO Port/Pin....
GPIO_getHighLowLevelPendingInterrupt
uint32_t GPIO_getHighLowLevelPendingInterrupt(uint32_t baseAddr, uint32_t interruptLevel)
The function is used to get the high level or low level interrupt pending. The driver will need to cy...
GPIO_pinRead
uint32_t GPIO_pinRead(uint32_t baseAddr, uint32_t pinNum)
The function is used to get the data input for a specific GPIO Port/Pin.