trikRuntime
usbMSP430Defines.h
Go to the documentation of this file.
1 /* Copyright 2015 Rostislav Varzar
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  * Created on: Fabruary 17, 2015
15  * Author: Rostislav Varzar
16 */
17 
18 #pragma once
19 
21 #define i2cPWMMOT1 0x0010 // 16 dec
22 #define i2cPWMMOT2 0x0011 // 17 dec
23 #define i2cPWMMOT3 0x0013 // 19 dec
24 #define i2cPWMMOT4 0x0012 // 18 dec
25 #define i2cMOT1 0x0014 // 20 dec
26 #define i2cMOT2 0x0015 // 21 dec
27 #define i2cMOT3 0x0017 // 23 dec
28 #define i2cMOT4 0x0016 // 22 dec
29 #define i2cBATT 0x0026 // 38 dec
30 #define i2cSENS1 0x0025 // 37 dec
31 #define i2cSENS2 0x0024 // 36 dec
32 #define i2cSENS3 0x0023 // 35 dec
33 #define i2cSENS4 0x0022 // 34 dec
34 #define i2cSENS5 0x0021 // 33 dec
35 #define i2cSENS6 0x0020 // 32 dec
36 #define i2cENC1 0x0030 // 48 dec
37 #define i2cENC2 0x0031 // 49 dec
38 #define i2cENC3 0x0032 // 50 dec
39 #define i2cENC4 0x0033 // 51 dec
40 #define i2cSERV1 0x003F // 63 dec
41 #define i2cSERV2 0x0040 // 64 dec
42 #define i2cSERV3 0x0041 // 65 dec
43 #define i2cSERV4 0x0042 // 66 dec
44 #define i2cSERV5 0x0043 // 67 dec
45 #define i2cSERV6 0x0044 // 68 dec
46 #define i2cSERV7 0x0045 // 69 dec
47 #define i2cSERV8 0x0046 // 70 dec
48 #define i2cSERV9 0x0047 // 71 dec
49 #define i2cSERV10 0x0048 // 72 dec
50 #define i2cSERV11 0x0049 // 73 dec
51 #define i2cSERV12 0x004A // 74 dec
52 #define i2cSERV13 0x004B // 75 dec
53 #define i2cSERV14 0x004C // 76 dec
54 #define i2cTEMP1 0x004D // 77 dec
55 #define i2cTEMP2 0x004E // 78 dec
56 #define i2cTEMP3 0x004F // 79 dec
57 #define i2cW1 0x0050 // 80 dec
58 #define i2cW2 0x0051 // 81 dec
59 #define i2cW3 0x0052 // 82 dec
60 #define i2cW4 0x0053 // 83 dec
61 #define i2cU1_0x11 0x0054 // 84 dec
62 #define i2cU1_0x12 0x0055
63 #define i2cU1_0x13 0x0056
64 #define i2cU1_0x14 0x0057
65 #define i2cU1_0x15 0x0058
66 #define i2cU1_0x16 0x0059
67 #define i2cU1_0x17 0x005A
68 #define i2cU1_0x18 0x005B
69 #define i2cU1_0x19 0x005C
70 #define i2cU1_0x1A 0x005D
71 #define i2cU1_0x1B 0x005E
72 #define i2cU1_0x1C 0x005F
73 #define i2cU1_0x1D 0x0060
74 #define i2cU1_0x1E 0x0061
75 #define i2cU1_0x1F 0x0062
76 #define i2cU1_0x20 0x0063
77 #define i2cU2_0x11 0x0064 // 100 dec
78 #define i2cU2_0x12 0x0065
79 #define i2cU2_0x13 0x0066
80 #define i2cU2_0x14 0x0067
81 #define i2cU2_0x15 0x0068
82 #define i2cU2_0x16 0x0069
83 #define i2cU2_0x17 0x006A
84 #define i2cU2_0x18 0x006B
85 #define i2cU2_0x19 0x006C
86 #define i2cU2_0x1A 0x006D
87 #define i2cU2_0x1B 0x006E
88 #define i2cU2_0x1C 0x006F
89 #define i2cU2_0x1D 0x0070
90 #define i2cU2_0x1E 0x0071
91 #define i2cU2_0x1F 0x0072
92 #define i2cU2_0x20 0x0073
93 #define i2cU3_0x11 0x0074 // 116 dec
94 #define i2cU3_0x12 0x0075
95 #define i2cU3_0x13 0x0076
96 #define i2cU3_0x14 0x0077
97 #define i2cU3_0x15 0x0078
98 #define i2cU3_0x16 0x0079
99 #define i2cU3_0x17 0x007A
100 #define i2cU3_0x18 0x007B
101 #define i2cU3_0x19 0x007C
102 #define i2cU3_0x1A 0x007D
103 #define i2cU3_0x1B 0x007E
104 #define i2cU3_0x1C 0x007F
105 #define i2cU3_0x1D 0x0080
106 #define i2cU3_0x1E 0x0081
107 #define i2cU3_0x1F 0x0082
108 #define i2cU3_0x20 0x0083
109 #define i2cU4_0x11 0x0084 // 132 dec
110 #define i2cU4_0x12 0x0085
111 #define i2cU4_0x13 0x0086
112 #define i2cU4_0x14 0x0087
113 #define i2cU4_0x15 0x0088
114 #define i2cU4_0x16 0x0089
115 #define i2cU4_0x17 0x008A
116 #define i2cU4_0x18 0x008B
117 #define i2cU4_0x19 0x008C
118 #define i2cU4_0x1A 0x008D
119 #define i2cU4_0x1B 0x008E
120 #define i2cU4_0x1C 0x008F
121 #define i2cU4_0x1D 0x0090
122 #define i2cU4_0x1E 0x0091
123 #define i2cU4_0x1F 0x0092
124 #define i2cU4_0x20 0x0093
125 #define i2cU5_0x11 0x0094 // 148 dec
126 #define i2cU5_0x12 0x0095
127 #define i2cU5_0x13 0x0096
128 #define i2cU5_0x14 0x0097
129 #define i2cU5_0x15 0x0098
130 #define i2cU5_0x16 0x0099
131 #define i2cU5_0x17 0x009A
132 #define i2cU5_0x18 0x009B
133 #define i2cU5_0x19 0x009C
134 #define i2cU5_0x1A 0x009D
135 #define i2cU5_0x1B 0x009E
136 #define i2cU5_0x1C 0x009F
137 #define i2cU5_0x1D 0x00A0
138 #define i2cU5_0x1E 0x00A1
139 #define i2cU5_0x1F 0x00A2
140 #define i2cU5_0x20 0x00A3
141 #define i2cU6_0x11 0x00A4 // 164 dec
142 #define i2cU6_0x12 0x00A5
143 #define i2cU6_0x13 0x00A6
144 #define i2cU6_0x14 0x00A7
145 #define i2cU6_0x15 0x00A8
146 #define i2cU6_0x16 0x00A9
147 #define i2cU6_0x17 0x00AA
148 #define i2cU6_0x18 0x00AB
149 #define i2cU6_0x19 0x00AC
150 #define i2cU6_0x1A 0x00AD
151 #define i2cU6_0x1B 0x00AE
152 #define i2cU6_0x1C 0x00AF
153 #define i2cU6_0x1D 0x00B0
154 #define i2cU6_0x1E 0x00B1
155 #define i2cU6_0x1F 0x00B2
156 #define i2cU6_0x20 0x00B3
157 #define i2cU7_0x11 0x00B4 // 180 dec
158 #define i2cU7_0x12 0x00B5
159 #define i2cU7_0x13 0x00B6
160 #define i2cU7_0x14 0x00B7
161 #define i2cU7_0x15 0x00B8
162 #define i2cU7_0x16 0x00B9
163 #define i2cU7_0x17 0x00BA
164 #define i2cU7_0x18 0x00BB
165 #define i2cU7_0x19 0x00BC
166 #define i2cU7_0x1A 0x00BD
167 #define i2cU7_0x1B 0x00BE
168 #define i2cU7_0x1C 0x00BF
169 #define i2cU7_0x1D 0x00C0
170 #define i2cU7_0x1E 0x00C1
171 #define i2cU7_0x1F 0x00C2
172 #define i2cU7_0x20 0x00C3 // 195 dec
173 #define TEMP_DHT11_1 0x0100 // 256 dec
174 #define TEMP_DHT11_2 0x0101
175 #define TEMP_DHT11_3 0x0102
176 #define TEMP_DHT11_4 0x0103
177 #define TEMP_DHT11_5 0x0104
178 #define TEMP_DHT11_6 0x0105
179 #define TEMP_DHT11_7 0x0106
180 #define TEMP_DHT11_8 0x0107
181 #define TEMP_DHT11_9 0x0108
182 #define TEMP_DHT11_10 0x0109
183 #define TEMP_DHT11_11 0x010A
184 #define TEMP_DHT11_12 0x010B
185 #define TEMP_DHT11_13 0x010C
186 #define TEMP_DHT11_14 0x010D
187 #define HUM_DHT11_1 0x010E
188 #define HUM_DHT11_2 0x010F
189 #define HUM_DHT11_3 0x0110
190 #define HUM_DHT11_4 0x0111
191 #define HUM_DHT11_5 0x0112
192 #define HUM_DHT11_6 0x0113
193 #define HUM_DHT11_7 0x0114
194 #define HUM_DHT11_8 0x0115
195 #define HUM_DHT11_9 0x0116
196 #define HUM_DHT11_10 0x0117
197 #define HUM_DHT11_11 0x0118
198 #define HUM_DHT11_12 0x0119
199 #define HUM_DHT11_13 0x011A
200 #define HUM_DHT11_14 0x011B
201 #define TEMP_DHT22_1 0x011C
202 #define TEMP_DHT22_2 0x011D
203 #define TEMP_DHT22_3 0x011E
204 #define TEMP_DHT22_4 0x011F
205 #define TEMP_DHT22_5 0x0120
206 #define TEMP_DHT22_6 0x0121
207 #define TEMP_DHT22_7 0x0122
208 #define TEMP_DHT22_8 0x0123
209 #define TEMP_DHT22_9 0x0124
210 #define TEMP_DHT22_10 0x0125
211 #define TEMP_DHT22_11 0x0126
212 #define TEMP_DHT22_12 0x0127
213 #define TEMP_DHT22_13 0x0128
214 #define TEMP_DHT22_14 0x0129
215 #define HUM_DHT22_1 0x012A
216 #define HUM_DHT22_2 0x012B
217 #define HUM_DHT22_3 0x012C
218 #define HUM_DHT22_4 0x012D
219 #define HUM_DHT22_5 0x012E
220 #define HUM_DHT22_6 0x012F
221 #define HUM_DHT22_7 0x0130
222 #define HUM_DHT22_8 0x0131
223 #define HUM_DHT22_9 0x0132
224 #define HUM_DHT22_10 0x0133
225 #define HUM_DHT22_11 0x0134
226 #define HUM_DHT22_12 0x0135
227 #define HUM_DHT22_13 0x0136
228 #define HUM_DHT22_14 0x0137 // 311 dec
229 
231 #define MOTOR1 0x00
232 #define MOTOR2 0x01
233 #define MOTOR3 0x03
234 #define MOTOR4 0x02
235 #define SENSOR1 0x04
236 #define SENSOR2 0x05
237 #define SENSOR3 0x06
238 #define SENSOR4 0x07
239 #define SENSOR5 0x08
240 #define SENSOR6 0x09
241 #define SENSOR7 0x0A
242 #define SENSOR8 0x0B
243 #define SENSOR9 0x0C
244 #define SENSOR10 0x0D
245 #define SENSOR11 0x0E
246 #define SENSOR12 0x0F
247 #define SENSOR13 0x10
248 #define SENSOR14 0x11
249 #define SENSOR15 0x12
250 #define SENSOR16 0x13
251 #define SENSOR17 0x14
252 #define SENSOR18 0x15
253 #define ENCODER1 0x16
254 #define ENCODER2 0x17
255 #define ENCODER3 0x19
256 #define ENCODER4 0x18
257 #define PORT1 0x1A
258 #define PORT2 0x1B
259 #define PORT3 0x1C
260 #define PORT4 0x1D
261 #define PORT5 0x1E
262 #define PORT6 0x1F
263 #define PORTJ 0x20
264 #define PWM1 0x21
265 #define PWM2 0x22
266 #define PWM3 0x23
267 #define PWM4 0x24
268 #define VERSIONCTRL 0x25
269 #define ASYNCTIMER 0x26
270 #define TOUCHDEVICE 0x27
271 #define I2C1 0x28
272 #define I2C2 0x29
273 #define I2C3 0x2A
274 #define I2C4 0x2B
275 #define I2C5 0x2C
276 #define I2C6 0x2D
277 #define I2C7 0x2E
278 #define SPWM1 0x2F
279 #define SPWM2 0x30
280 #define SPWM3 0x31
281 #define SPWM4 0x32
282 #define SPWM5 0x33
283 #define SPWM6 0x34
284 #define SPWM7 0x35
285 #define SPWM8 0x36
286 #define SPWM9 0x37
287 #define SPWM10 0x38
288 #define SPWM11 0x39
289 #define SPWM12 0x3A
290 #define SPWM13 0x3B
291 #define SPWM14 0x3C
292 #define USART1 0x3D
293 #define USART2 0x3E
294 #define USART3 0x3F
295 #define USART4 0x40
296 #define USART5 0x41
297 #define USART6 0x42
298 #define USART7 0x43
299 #define BSL 0xEE
300 #define NNONE 0xFF
301 
303 #define MMCTL 0x00
304 #define MMDUT 0x01
305 #define MMPER 0x02
306 #define MMANG 0x03
307 #define MMTMR 0x04
308 #define MMVAL 0x05
309 #define MMERR 0x06
310 
312 #define MOT_ENABLE 0x8000 // Motor enable
313 #define MOT_AUTO 0x4000 // Autostop mode
314 #define MOT_ANGLE 0x2000 // Angle autostop mode
315 #define MOT_BACK 0x0010 // Backward direction
316 #define MOT_BRAKE 0x0008 // Brake enable
317 #define MOT_POWER 0x0003 // Motor power
318 
320 #define DEF_MOT_PER 0x3000 // Default motor period in uS
321 
323 #define EECTL 0x00
324 #define EEVAL 0x01
325 #define EESTA 0x02
326 
328 #define ENC_ENABLE 0x8000 // Enable bit
329 #define ENC_ASYNC 0x4000 // Async mode
330 #define ENC_2WIRES 0x2000 // 2-wires mode
331 #define ENC_PUPEN 0x1000 // Pull up resistors
332 #define ENC_FALL 0x0800 // Falling edge select
333 
335 #define SSCTL 0x00
336 #define SSIDX 0x01
337 #define SSVAL 0x02
338 #define SSSTA 0x03
339 
341 #define DIGITAL_INP 0x0000
342 #define ANALOG_INP 0x0001
343 #define DHTXX_TEMP 0x0002
344 #define DHTXX_HUM 0x0003
345 
347 #define SENS_ENABLE 0x8000 // Enable bit
348 #define SENS_ASYNC 0x4000 // Async mode
349 #define SENS_PULL 0x2000 // Pull up resistors
350 #define SENS_READ 0x0001 // Sensor read
351 
353 #define IICTL 0x00
354 #define IIDEV 0x01
355 #define IIREG 0x02
356 #define IIDAT 0x03
357 #define IIERR 0x04
358 #define IIIDX 0x05
359 #define IIVAL 0x06
360 #define IIDEL 0x07
361 #define IIVER 0x08
362 #define IIPAR 0x09
363 
365 #define I2C_ENABLE 0x80 // I2C enable
366 #define I2C_READ 0x20 // I2C read
367 #define I2C_WRITE 0x40 // I2C write
368 #define I2C_SENS 0x10 // I2C read sensor
369 #define I2C_PULL 0x08 // I2C pullup resistors
370 
372 #define UUCTL 0x00
373 #define UUSPD 0x01
374 #define UUSTA 0x02
375 #define UUDAT 0x03
376 
378 #define USART_EN 0x80000000 // USART enable
379 #define USART_EVEN 0x40000000 // USART even parity
380 #define USART_ODD 0x20000000 // USART odd parity
381 #define USART_2SB 0x10000000 // USART 1.5 or 2 stop bits
382 #define USART_6BITS 0x04000000 // USART 6 bits word length
383 #define USART_7BITS 0x08000000 // USART 7 bits word length
384 #define USART_8BITS 0x0C000000 // USART 8 bits word length
385 #define USART_IRDA1 0x00800000 // USART IrDA 115.2 kbaud mode
386 #define USART_IRDA2 0x01000000 // USART IrDA 1.152 Mbaud mode
387 #define USART_RS485 0x02000000 // USART RS-485 mode
388 #define USART_INVRTS 0x00400000 // USART RTS inverted mode
389 #define USART_RXEN 0x00200000 // USART receiver enable
390 #define USART_TXEN 0x00100000 // USART transmitter enable
391 #define USART_RTS 0x00080000 // USART RTS high level
392 #define USART_DTR 0x00040000 // USART DTR high level
393 #define USART_RST 0x00000003 // USART software reset
394 
396 #define NXTTEMP 0x0000
397 #define HMC5883L_X 0x0001
398 #define HMC5883L_Y 0x0002
399 #define HMC5883L_Z 0x0003
400 #define MCP3424_CH1 0x0004
401 #define MCP3424_CH2 0x0005
402 #define MCP3424_CH3 0x0006
403 #define MCP3424_CH4 0x0007
404 
406 #define MCP3424_GAIN1 0x0000
407 #define MCP3424_GAIN2 0x0001
408 #define MCP3424_GAIN4 0x0002
409 #define MCP3424_GAIN8 0x0003
410 
412 #define SPPCTL 0x00
413 #define SPPDUT 0x01
414 #define SPPPER 0x02
415 #define SPPVER 0x03
416 
418 #define SPWM_ENABLE 0x8000 // SPWM enable
419 
421 #define DEF_SPWM_PER 0x00C8 // Default software PWM period (for servo motors), 50 Hz (20 ms)
422 
424 #define MIN_SERV_DUTY 0x0007
425 #define MAX_SERV_DUTY 0x0017
426 
427 #define MAX_STRING_LENGTH 0x20
428 
429 #define WRITE_FUNC 0x03
430 #define READ_FUNC 0x05
431 
433 #define NO_ERROR 0x00
434 #define FUNC_CODE_ERROR 0x01
435 #define REG_ADDR_ERROR 0x02
436 #define REG_VAL_ERROR 0x03
437 #define SLAVE_ERROR 0x04
438 #define SLAVE_BUSY 0x06
439 #define DEV_ADDR_ERROR 0x11
440 #define CRC_ERROR 0x12
441 #define START_ERROR 0x13
442 #define LENGTH_ERROR 0x14
443 #define REG_INC_ERROR 0x15
444 #define UNDEF_ERROR 0xFF
445 #define URM04_ERROR 0xFFFFFFFF
446 
448 #define NUM_BYTE 0x02
449 #define NUM_WORD 0x04
450 #define NUM_DWORD 0x08
451 
452 #define RECV_PACK_LEN 0x12
453 
455 #define NO_ERROR 0x00
456 #define DEVICE_ERROR 0x01
457 #define PACKET_ERROR 0x02
458 
459 #define TIME_OUT 0xFFFF
460 
462 #define ALT_NOTHING 0x00
463 #define ALT_ANALOG 0x01
464 #define ALT_I2C 0x02
465 #define ALT_SERVO 0x03
466 #define ALT_ENC 0x04
467 #define ALT_USART 0x05
468 #define ALT_DHTXX 0x06
469 
471 #define USB_DEV_NAME "/dev/ttyACM0"
472