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 //  pin.h
36 //
37 //  Defines and Macros for the pin mux module
38 //
39 //*****************************************************************************
40 
41 #ifndef __PIN_H__
42 #define __PIN_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 // Macros Defining Pins
57 //*****************************************************************************
58 
59 #define PIN_01 	 0x00000000
60 #define PIN_02 	 0x00000001
61 #define PIN_03   0x00000002
62 #define PIN_04 	 0x00000003
63 #define PIN_05   0x00000004
64 #define PIN_06   0x00000005
65 #define PIN_07   0x00000006
66 #define PIN_08   0x00000007
67 #define PIN_11   0x0000000A
68 #define PIN_12   0x0000000B
69 #define PIN_13   0x0000000C
70 #define PIN_14   0x0000000D
71 #define PIN_15   0x0000000E
72 #define PIN_16   0x0000000F
73 #define PIN_17   0x00000010
74 #define PIN_18   0x00000011
75 #define PIN_19 	 0x00000012
76 #define PIN_20   0x00000013
77 #define PIN_21   0x00000014
78 #define PIN_29   0x0000001C
79 #define PIN_30   0x0000001D
80 #define PIN_45   0x0000002C
81 #define PIN_46   0x0000002D
82 #define PIN_47   0x0000002E
83 #define PIN_48   0x0000002F
84 #define PIN_49   0x00000030
85 #define PIN_50   0x00000031
86 #define PIN_52   0x00000033
87 #define PIN_53   0x00000034
88 #define PIN_55   0x00000036
89 #define PIN_56   0x00000037
90 #define PIN_57   0x00000038
91 #define PIN_58   0x00000039
92 #define PIN_59   0x0000003A
93 #define PIN_60   0x0000003B
94 #define PIN_61	 0x0000003C
95 #define PIN_62	 0x0000003D
96 #define PIN_63	 0x0000003E
97 #define PIN_64	 0x0000003F
98 
99 
100 
101 //*****************************************************************************
102 // Macros that can be used with PinConfigSet(), PinTypeGet(), PinStrengthGet()
103 //*****************************************************************************
104 
105 #define PIN_MODE_0	 0x00000000
106 #define PIN_MODE_1	 0x00000001
107 #define PIN_MODE_2	 0x00000002
108 #define PIN_MODE_3	 0x00000003
109 #define PIN_MODE_4	 0x00000004
110 #define PIN_MODE_5	 0x00000005
111 #define PIN_MODE_6	 0x00000006
112 #define PIN_MODE_7	 0x00000007
113 #define PIN_MODE_8	 0x00000008
114 #define PIN_MODE_9	 0x00000009
115 #define PIN_MODE_10	 0x0000000A
116 #define PIN_MODE_11	 0x0000000B
117 #define PIN_MODE_12	 0x0000000C
118 #define PIN_MODE_13	 0x0000000D
119 #define PIN_MODE_14	 0x0000000E
120 #define PIN_MODE_15	 0x0000000F
121 // Note : PIN_MODE_255 is a dummy define for pinmux utility code generation
122 // PIN_MODE_255 should never be used in any user code.
123 #define PIN_MODE_255 0x000000FF
124 
125 //*****************************************************************************
126 // Macros that can be used with PinDirModeSet() and returned from
127 // PinDirModeGet().
128 //*****************************************************************************
129 #define PIN_DIR_MODE_IN  0x00000C00 // Pin is input
130 #define PIN_DIR_MODE_OUT 0x00000800 // Pin is output
131 #define PIN_DIR_MODE_HW  0x00000000 // Pin is peripheral function
132 
133 //*****************************************************************************
134 // Macros that can be used with PinConfigSet()
135 //*****************************************************************************
136 #define PIN_STRENGTH_2MA  0x00000020
137 #define PIN_STRENGTH_4MA  0x00000040
138 #define PIN_STRENGTH_6MA  0x00000060
139 
140 #define PIN_TYPE_STD      0x00000000
141 #define PIN_TYPE_STD_PU   0x00000100
142 #define PIN_TYPE_STD_PD   0x00000200
143 
144 #define PIN_TYPE_OD       0x00000010
145 #define PIN_TYPE_OD_PU    0x00000110
146 #define PIN_TYPE_OD_PD    0x00000210
147 #define PIN_TYPE_ANALOG   0x10000000
148 
149 //*****************************************************************************
150 // Macros that can be used with PinHysteresisSet()
151 //*****************************************************************************
152 #define PIN_HYSTERESIS_OFF      0x00000000
153 #define PIN_HYSTERESIS_10       0x00000004
154 #define PIN_HYSTERESIS_20       0x0000000C
155 #define PIN_HYSTERESIS_30       0x00000014
156 #define PIN_HYSTERESIS_40       0x0000001C
157 
158 
159 //*****************************************************************************
160 //
161 // API Function prototypes
162 //
163 //*****************************************************************************
164 extern void PinModeSet(unsigned long ulPin, unsigned long ulPinMode);
165 extern void PinDirModeSet(unsigned long ulPin, unsigned long ulPinIO);
166 extern unsigned long PinDirModeGet(unsigned long ulPin);
167 extern unsigned long PinModeGet(unsigned long ulPin);
168 extern void PinConfigGet(unsigned long ulPin,unsigned long  *pulPinStrength,
169 	       					unsigned long *pulPinType);
170 extern void PinConfigSet(unsigned long ulPin,unsigned long  ulPinStrength,
171 						unsigned long ulPinType);
172 extern void PinTypeUART(unsigned long ulPin,unsigned long ulPinMode);
173 extern void PinTypeI2C(unsigned long ulPin,unsigned long ulPinMode);
174 extern void PinTypeSPI(unsigned long ulPin,unsigned long ulPinMode);
175 extern void PinTypeI2S(unsigned long ulPin,unsigned long ulPinMode);
176 extern void PinTypeTimer(unsigned long ulPin,unsigned long ulPinMode);
177 extern void PinTypeCamera(unsigned long ulPin,unsigned long ulPinMode);
178 extern void PinTypeGPIO(unsigned long ulPin,unsigned long ulPinMode,
179                         tBoolean bOpenDrain);
180 extern void PinTypeADC(unsigned long ulPin,unsigned long ulPinMode);
181 extern void PinTypeSDHost(unsigned long ulPin,unsigned long ulPinMode);
182 extern void PinHysteresisSet(unsigned long ulHysteresis);
183 extern void PinLockLevelSet(unsigned long ulPin, unsigned char ucLevel);
184 extern void PinLock(unsigned long ulOutEnable);
185 extern void PinUnlock(void);
186 extern unsigned long PinToPadGet(unsigned long ulPin);
187 extern unsigned long PinFromPadGet(unsigned long ulPad);
188 
189 #ifdef __cplusplus
190 }
191 #endif
192 
193 #endif //__PIN_H__
194