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.adc.ADC10 as ADC10;
34 import ti.catalog.msp430.peripherals.clock.BCSplus as BCSplus;
35
36 /*!
37 * ======== GPIO for MSP430G2x55 ========
38 * MSP430 General Purpose Input Output Ports
39 */
40 metaonly module GPIO_MSP430G2x55 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 ADC10
45 * and BCS+ instances.
46 */
47 create(ADC10.Instance adc10, BCSplus.Instance clock);
48
49 instance:
50 /*! @_nodoc */
51 config ADC10.Instance adc10;
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 * MSP430G2x55 device, there are 4 x 8 = 64 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 : "P1SEL2" , regForceSet : false },
76 { register : "P1DIR" , regForceSet : true },
77 { register : "P1REN" , regForceSet : false },
78 { register : "P1IES" , regForceSet : true },
79 { register : "P1IFG" , regForceSet : true },
80 { register : "P1IE" , regForceSet : false },
81 { register : "P2OUT" , regForceSet : true },
82 { register : "P2SEL" , regForceSet : false },
83 { register : "P2SEL2" , regForceSet : false },
84 { register : "P2DIR" , regForceSet : true },
85 { register : "P2REN" , regForceSet : false },
86 { register : "P2IES" , regForceSet : true },
87 { register : "P2IFG" , regForceSet : true },
88 { register : "P2IE" , regForceSet : false },
89 { register : "P3OUT" , regForceSet : true },
90 { register : "P3SEL" , regForceSet : false },
91 { register : "P3SEL2" , regForceSet : false },
92 { register : "P3DIR" , regForceSet : true },
93 { register : "P3REN" , regForceSet : false },
94 { register : "P4OUT" , regForceSet : true },
95 { register : "P4SEL" , regForceSet : false },
96 { register : "P4SEL2" , regForceSet : false },
97 { register : "P4DIR" , regForceSet : true },
98 { register : "P4REN" , regForceSet : false },
99 ];
100
101 102 103 104 105 106
107
108 /*! Port 1 Output Register */
109 config GpioBits8PxOut_t P1OUT = {
110 Bit0 : BIT0_OFF,
111 Bit1 : BIT1_OFF,
112 Bit2 : BIT2_OFF,
113 Bit3 : BIT3_OFF,
114 Bit4 : BIT4_OFF,
115 Bit5 : BIT5_OFF,
116 Bit6 : BIT6_OFF,
117 Bit7 : BIT7_OFF
118 };
119
120 /*! Port 1 Port Select Register */
121 config GpioBits8PxSel_t P1SEL = {
122 Bit0 : BIT0_OFF,
123 Bit1 : BIT1_OFF,
124 Bit2 : BIT2_OFF,
125 Bit3 : BIT3_OFF,
126 Bit4 : BIT4_OFF,
127 Bit5 : BIT5_OFF,
128 Bit6 : BIT6_OFF,
129 Bit7 : BIT7_OFF
130 };
131
132 /*! Port 1 Direction Register */
133 config GpioBits8PxDir_t P1DIR = {
134 Bit0 : BIT0_OFF,
135 Bit1 : BIT1_OFF,
136 Bit2 : BIT2_OFF,
137 Bit3 : BIT3_OFF,
138 Bit4 : BIT4_OFF,
139 Bit5 : BIT5_OFF,
140 Bit6 : BIT6_OFF,
141 Bit7 : BIT7_OFF
142 };
143
144 /*! Port 1 Resistor Enable Register */
145 config GpioBits8PxRen_t P1REN = {
146 Bit0 : BIT0_OFF,
147 Bit1 : BIT1_OFF,
148 Bit2 : BIT2_OFF,
149 Bit3 : BIT3_OFF,
150 Bit4 : BIT4_OFF,
151 Bit5 : BIT5_OFF,
152 Bit6 : BIT6_OFF,
153 Bit7 : BIT7_OFF
154 };
155
156 /*! Port 2 Output Register */
157 config GpioBits8PxOut_t P2OUT = {
158 Bit0 : BIT0_OFF,
159 Bit1 : BIT1_OFF,
160 Bit2 : BIT2_OFF,
161 Bit3 : BIT3_OFF,
162 Bit4 : BIT4_OFF,
163 Bit5 : BIT5_OFF,
164 Bit6 : BIT6_OFF,
165 Bit7 : BIT7_OFF
166 };
167
168 /*! Port 2 Port Select Register */
169 config GpioBits8PxSel_t P2SEL = {
170 Bit0 : BIT0_OFF,
171 Bit1 : BIT1_OFF,
172 Bit2 : BIT2_OFF,
173 Bit3 : BIT3_OFF,
174 Bit4 : BIT4_OFF,
175 Bit5 : BIT5_OFF,
176 Bit6 : BIT6,
177 Bit7 : BIT7
178 };
179
180 /*! Port 2 Direction Register */
181 config GpioBits8PxDir_t P2DIR = {
182 Bit0 : BIT0_OFF,
183 Bit1 : BIT1_OFF,
184 Bit2 : BIT2_OFF,
185 Bit3 : BIT3_OFF,
186 Bit4 : BIT4_OFF,
187 Bit5 : BIT5_OFF,
188 Bit6 : BIT6_OFF,
189 Bit7 : BIT7_OFF
190 };
191
192 /*! Port 2 Resistor Enable Register */
193 config GpioBits8PxRen_t P2REN = {
194 Bit0 : BIT0_OFF,
195 Bit1 : BIT1_OFF,
196 Bit2 : BIT2_OFF,
197 Bit3 : BIT3_OFF,
198 Bit4 : BIT4_OFF,
199 Bit5 : BIT5_OFF,
200 Bit6 : BIT6_OFF,
201 Bit7 : BIT7_OFF
202 };
203
204 /*! Port 3 Output Register */
205 config GpioBits8PxOut_t P3OUT = {
206 Bit0 : BIT0_OFF,
207 Bit1 : BIT1_OFF,
208 Bit2 : BIT2_OFF,
209 Bit3 : BIT3_OFF,
210 Bit4 : BIT4_OFF,
211 Bit5 : BIT5_OFF,
212 Bit6 : BIT6_OFF,
213 Bit7 : BIT7_OFF
214 };
215
216 /*! Port 3 Port Select Register */
217 config GpioBits8PxSel_t P3SEL = {
218 Bit0 : BIT0_OFF,
219 Bit1 : BIT1_OFF,
220 Bit2 : BIT2_OFF,
221 Bit3 : BIT3_OFF,
222 Bit4 : BIT4_OFF,
223 Bit5 : BIT5_OFF,
224 Bit6 : BIT6_OFF,
225 Bit7 : BIT7_OFF
226 };
227
228 /*! Port 3 Direction Register */
229 config GpioBits8PxDir_t P3DIR = {
230 Bit0 : BIT0_OFF,
231 Bit1 : BIT1_OFF,
232 Bit2 : BIT2_OFF,
233 Bit3 : BIT3_OFF,
234 Bit4 : BIT4_OFF,
235 Bit5 : BIT5_OFF,
236 Bit6 : BIT6_OFF,
237 Bit7 : BIT7_OFF
238 };
239
240 /*! Port 3 Resistor Enable Register */
241 config GpioBits8PxRen_t P3REN = {
242 Bit0 : BIT0_OFF,
243 Bit1 : BIT1_OFF,
244 Bit2 : BIT2_OFF,
245 Bit3 : BIT3_OFF,
246 Bit4 : BIT4_OFF,
247 Bit5 : BIT5_OFF,
248 Bit6 : BIT6_OFF,
249 Bit7 : BIT7_OFF
250 };
251
252 /*! Port 4 Output Register */
253 config GpioBits8PxOut_t P4OUT = {
254 Bit0 : BIT0_OFF,
255 Bit1 : BIT1_OFF,
256 Bit2 : BIT2_OFF,
257 Bit3 : BIT3_OFF,
258 Bit4 : BIT4_OFF,
259 Bit5 : BIT5_OFF,
260 Bit6 : BIT6_OFF,
261 Bit7 : BIT7_OFF
262 };
263
264 /*! Port 4 Port Select Register */
265 config GpioBits8PxSel_t P4SEL = {
266 Bit0 : BIT0_OFF,
267 Bit1 : BIT1_OFF,
268 Bit2 : BIT2_OFF,
269 Bit3 : BIT3_OFF,
270 Bit4 : BIT4_OFF,
271 Bit5 : BIT5_OFF,
272 Bit6 : BIT6_OFF,
273 Bit7 : BIT7_OFF
274 };
275
276 /*! Port 4 Direction Register */
277 config GpioBits8PxDir_t P4DIR = {
278 Bit0 : BIT0_OFF,
279 Bit1 : BIT1_OFF,
280 Bit2 : BIT2_OFF,
281 Bit3 : BIT3_OFF,
282 Bit4 : BIT4_OFF,
283 Bit5 : BIT5_OFF,
284 Bit6 : BIT6_OFF,
285 Bit7 : BIT7_OFF
286 };
287
288 /*! Port 4 Resistor Enable Register */
289 config GpioBits8PxRen_t P4REN = {
290 Bit0 : BIT0_OFF,
291 Bit1 : BIT1_OFF,
292 Bit2 : BIT2_OFF,
293 Bit3 : BIT3_OFF,
294 Bit4 : BIT4_OFF,
295 Bit5 : BIT5_OFF,
296 Bit6 : BIT6_OFF,
297 Bit7 : BIT7_OFF
298 };
299 }