1 /*
2  *  Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/
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  */
33 //*****************************************************************************
34 //
35 //  gpio.h
36 //
37 //  Defines and Macros for GPIO API.
38 //
39 //*****************************************************************************
40 
41 #ifndef __GPIO_H__
42 #define __GPIO_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 ucPins argument to several
58 // 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 ulPinIO 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 
79 //*****************************************************************************
80 //
81 // Values that can be passed to GPIOIntTypeSet as the ulIntType parameter, and
82 // returned from GPIOIntTypeGet.
83 //
84 //*****************************************************************************
85 #define GPIO_FALLING_EDGE       0x00000000  // Interrupt on falling edge
86 #define GPIO_RISING_EDGE        0x00000004  // Interrupt on rising edge
87 #define GPIO_BOTH_EDGES         0x00000001  // Interrupt on both edges
88 #define GPIO_LOW_LEVEL          0x00000002  // Interrupt on low level
89 #define GPIO_HIGH_LEVEL         0x00000006  // Interrupt on high level
90 
91 //*****************************************************************************
92 //
93 // Values that can be passed to GPIOIntEnable() and GPIOIntDisable() functions
94 // in the ulIntFlags parameter.
95 //
96 //*****************************************************************************
97 #define GPIO_INT_DMA            0x00000100
98 #define GPIO_INT_PIN_0          0x00000001
99 #define GPIO_INT_PIN_1          0x00000002
100 #define GPIO_INT_PIN_2          0x00000004
101 #define GPIO_INT_PIN_3          0x00000008
102 #define GPIO_INT_PIN_4          0x00000010
103 #define GPIO_INT_PIN_5          0x00000020
104 #define GPIO_INT_PIN_6          0x00000040
105 #define GPIO_INT_PIN_7          0x00000080
106 
107 //*****************************************************************************
108 //
109 // Prototypes for the APIs.
110 //
111 //*****************************************************************************
112 extern void GPIODirModeSet(unsigned long ulPort, unsigned char ucPins,
113                            unsigned long ulPinIO);
114 extern unsigned long GPIODirModeGet(unsigned long ulPort, unsigned char ucPin);
115 extern void GPIOIntTypeSet(unsigned long ulPort, unsigned char ucPins,
116                            unsigned long ulIntType);
117 extern void GPIODMATriggerEnable(unsigned long ulPort);
118 extern void GPIODMATriggerDisable(unsigned long ulPort);
119 extern unsigned long GPIOIntTypeGet(unsigned long ulPort, unsigned char ucPin);
120 extern void GPIOIntEnable(unsigned long ulPort, unsigned long ulIntFlags);
121 extern void GPIOIntDisable(unsigned long ulPort, unsigned long ulIntFlags);
122 extern long GPIOIntStatus(unsigned long ulPort, tBoolean bMasked);
123 extern void GPIOIntClear(unsigned long ulPort, unsigned long ulIntFlags);
124 extern void GPIOIntRegister(unsigned long ulPort,
125                                 void (*pfnIntHandler)(void));
126 extern void GPIOIntUnregister(unsigned long ulPort);
127 extern long GPIOPinRead(unsigned long ulPort, unsigned char ucPins);
128 extern void GPIOPinWrite(unsigned long ulPort, unsigned char ucPins,
129                          unsigned char ucVal);
130 
131 //*****************************************************************************
132 //
133 // Mark the end of the C bindings section for C++ compilers.
134 //
135 //*****************************************************************************
136 #ifdef __cplusplus
137 }
138 #endif
139 
140 #endif //  __GPIO_H__
141