1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
32
33 import ti.catalog.msp430.peripherals.comparator.IComparator as Comparator;
34 import ti.catalog.msp430.peripherals.clock.BCSplus as BCSplus;
35
36 /*!
37 * ======== GPIO for MSP430F23x0 ========
38 * MSP430 General Purpose Input Output Ports
39 */
40 metaonly module GPIO_MSP430F23x0 inherits IGPIO {
41 /*!
42 * ======== create ========
43 * Create an instance of this peripheral. Use a customized
44 * init function so that we can get access to the Comparator_A
45 * and BCS+ instances.
46 */
47 create(Comparator.Instance comparator, BCSplus.Instance clock);
48
49 instance:
50 /*! @_nodoc */
51 config Comparator.Instance comparator;
52
53 /*! @_nodoc */
54 config BCSplus.Instance clock;
55
56 /*! Define an array to describe all device pins. The 1st dimension
57 * denotes the port, the second the pin on that port. On an
58 * MSP430F23x0 device, there are 4 x 8 = 32 pins total.
59 */
60
61 62
63 64
65 config DevicePin_t devicePins[4][8];
66
67 /*! Implementation of Device Pin Functional Configuration */
68 override config DevicePinFunctionSetting_t devicePinSetting[4][8];
69
70 /*! Determine if each Register needs to be forced set or not */
71 readonly config ForceSetDefaultRegister_t forceSetDefaultRegister[] =
72 [
73 { register : "P1OUT" , regForceSet : true },
74 { register : "P1SEL" , regForceSet : false },
75 { register : "P1DIR" , regForceSet : true },
76 { register : "P1REN" , regForceSet : false },
77 { register : "P1IES" , regForceSet : true },
78 { register : "P1IFG" , regForceSet : true },
79 { register : "P1IE" , regForceSet : false },
80 { register : "P2OUT" , regForceSet : true },
81 { register : "P2SEL" , regForceSet : false },
82 { register : "P2DIR" , regForceSet : true },
83 { register : "P2REN" , regForceSet : false },
84 { register : "P2IES" , regForceSet : true },
85 { register : "P2IFG" , regForceSet : true },
86 { register : "P2IE" , regForceSet : false },
87 { register : "P3OUT" , regForceSet : true },
88 { register : "P3SEL" , regForceSet : false },
89 { register : "P3DIR" , regForceSet : true },
90 { register : "P3REN" , regForceSet : false },
91 { register : "P4OUT" , regForceSet : true },
92 { register : "P4SEL" , regForceSet : false },
93 { register : "P4DIR" , regForceSet : true },
94 { register : "P4REN" , regForceSet : false },
95 ];
96
97 98 99 100 101 102
103
104 /*! Port 1 Output Register */
105 config GpioBits8PxOut_t P1OUT = {
106 Bit0 : BIT0_OFF,
107 Bit1 : BIT1_OFF,
108 Bit2 : BIT2_OFF,
109 Bit3 : BIT3_OFF,
110 Bit4 : BIT4_OFF,
111 Bit5 : BIT5_OFF,
112 Bit6 : BIT6_OFF,
113 Bit7 : BIT7_OFF
114 };
115
116 /*! Port 1 Port Select Register */
117 config GpioBits8PxSel_t P1SEL = {
118 Bit0 : BIT0_OFF,
119 Bit1 : BIT1_OFF,
120 Bit2 : BIT2_OFF,
121 Bit3 : BIT3_OFF,
122 Bit4 : BIT4_OFF,
123 Bit5 : BIT5_OFF,
124 Bit6 : BIT6_OFF,
125 Bit7 : BIT7_OFF
126 };
127
128 /*! Port 1 Direction Register */
129 config GpioBits8PxDir_t P1DIR = {
130 Bit0 : BIT0_OFF,
131 Bit1 : BIT1_OFF,
132 Bit2 : BIT2_OFF,
133 Bit3 : BIT3_OFF,
134 Bit4 : BIT4_OFF,
135 Bit5 : BIT5_OFF,
136 Bit6 : BIT6_OFF,
137 Bit7 : BIT7_OFF
138 };
139
140 /*! Port 1 Resistor Enable Register */
141 config GpioBits8PxRen_t P1REN = {
142 Bit0 : BIT0_OFF,
143 Bit1 : BIT1_OFF,
144 Bit2 : BIT2_OFF,
145 Bit3 : BIT3_OFF,
146 Bit4 : BIT4_OFF,
147 Bit5 : BIT5_OFF,
148 Bit6 : BIT6_OFF,
149 Bit7 : BIT7_OFF
150 };
151
152 /*! Port 2 Output Register */
153 config GpioBits8PxOut_t P2OUT = {
154 Bit0 : BIT0_OFF,
155 Bit1 : BIT1_OFF,
156 Bit2 : BIT2_OFF,
157 Bit3 : BIT3_OFF,
158 Bit4 : BIT4_OFF,
159 Bit5 : BIT5_OFF,
160 Bit6 : BIT6_OFF,
161 Bit7 : BIT7_OFF
162 };
163
164 /*! Port 2 Port Select Register */
165 config GpioBits8PxSel_t P2SEL = {
166 Bit0 : BIT0_OFF,
167 Bit1 : BIT1_OFF,
168 Bit2 : BIT2_OFF,
169 Bit3 : BIT3_OFF,
170 Bit4 : BIT4_OFF,
171 Bit5 : BIT5_OFF,
172 Bit6 : BIT6,
173 Bit7 : BIT7
174 };
175
176 /*! Port 2 Direction Register */
177 config GpioBits8PxDir_t P2DIR = {
178 Bit0 : BIT0_OFF,
179 Bit1 : BIT1_OFF,
180 Bit2 : BIT2_OFF,
181 Bit3 : BIT3_OFF,
182 Bit4 : BIT4_OFF,
183 Bit5 : BIT5_OFF,
184 Bit6 : BIT6_OFF,
185 Bit7 : BIT7_OFF
186 };
187
188 /*! Port 2 Resistor Enable Register */
189 config GpioBits8PxRen_t P2REN = {
190 Bit0 : BIT0_OFF,
191 Bit1 : BIT1_OFF,
192 Bit2 : BIT2_OFF,
193 Bit3 : BIT3_OFF,
194 Bit4 : BIT4_OFF,
195 Bit5 : BIT5_OFF,
196 Bit6 : BIT6_OFF,
197 Bit7 : BIT7_OFF
198 };
199
200 /*! Port 3 Output Register */
201 config GpioBits8PxOut_t P3OUT = {
202 Bit0 : BIT0_OFF,
203 Bit1 : BIT1_OFF,
204 Bit2 : BIT2_OFF,
205 Bit3 : BIT3_OFF,
206 Bit4 : BIT4_OFF,
207 Bit5 : BIT5_OFF,
208 Bit6 : BIT6_OFF,
209 Bit7 : BIT7_OFF
210 };
211
212 /*! Port 3 Port Select Register */
213 config GpioBits8PxSel_t P3SEL = {
214 Bit0 : BIT0_OFF,
215 Bit1 : BIT1_OFF,
216 Bit2 : BIT2_OFF,
217 Bit3 : BIT3_OFF,
218 Bit4 : BIT4_OFF,
219 Bit5 : BIT5_OFF,
220 Bit6 : BIT6_OFF,
221 Bit7 : BIT7_OFF
222 };
223
224 /*! Port 3 Direction Register */
225 config GpioBits8PxDir_t P3DIR = {
226 Bit0 : BIT0_OFF,
227 Bit1 : BIT1_OFF,
228 Bit2 : BIT2_OFF,
229 Bit3 : BIT3_OFF,
230 Bit4 : BIT4_OFF,
231 Bit5 : BIT5_OFF,
232 Bit6 : BIT6_OFF,
233 Bit7 : BIT7_OFF
234 };
235
236 /*! Port 3 Resistor Enable Register */
237 config GpioBits8PxRen_t P3REN = {
238 Bit0 : BIT0_OFF,
239 Bit1 : BIT1_OFF,
240 Bit2 : BIT2_OFF,
241 Bit3 : BIT3_OFF,
242 Bit4 : BIT4_OFF,
243 Bit5 : BIT5_OFF,
244 Bit6 : BIT6_OFF,
245 Bit7 : BIT7_OFF
246 };
247
248 /*! Port 4 Output Register */
249 config GpioBits8PxOut_t P4OUT = {
250 Bit0 : BIT0_OFF,
251 Bit1 : BIT1_OFF,
252 Bit2 : BIT2_OFF,
253 Bit3 : BIT3_OFF,
254 Bit4 : BIT4_OFF,
255 Bit5 : BIT5_OFF,
256 Bit6 : BIT6_OFF,
257 Bit7 : BIT7_OFF
258 };
259
260 /*! Port 4 Port Select Register */
261 config GpioBits8PxSel_t P4SEL = {
262 Bit0 : BIT0_OFF,
263 Bit1 : BIT1_OFF,
264 Bit2 : BIT2_OFF,
265 Bit3 : BIT3_OFF,
266 Bit4 : BIT4_OFF,
267 Bit5 : BIT5_OFF,
268 Bit6 : BIT6_OFF,
269 Bit7 : BIT7_OFF
270 };
271
272 /*! Port 4 Direction Register */
273 config GpioBits8PxDir_t P4DIR = {
274 Bit0 : BIT0_OFF,
275 Bit1 : BIT1_OFF,
276 Bit2 : BIT2_OFF,
277 Bit3 : BIT3_OFF,
278 Bit4 : BIT4_OFF,
279 Bit5 : BIT5_OFF,
280 Bit6 : BIT6_OFF,
281 Bit7 : BIT7_OFF
282 };
283
284 /*! Port 4 Resistor Enable Register */
285 config GpioBits8PxRen_t P4REN = {
286 Bit0 : BIT0_OFF,
287 Bit1 : BIT1_OFF,
288 Bit2 : BIT2_OFF,
289 Bit3 : BIT3_OFF,
290 Bit4 : BIT4_OFF,
291 Bit5 : BIT5_OFF,
292 Bit6 : BIT6_OFF,
293 Bit7 : BIT7_OFF
294 };
295 }