-
Notifications
You must be signed in to change notification settings - Fork 10
/
Robotell_USB-CAN.txt
497 lines (440 loc) · 11.2 KB
/
Robotell_USB-CAN.txt
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
STM32 Flash Memory MAP
--- CAN_ADDR_START ---
[0] = 0xaaaaaaaa
--- CAN_ADDR_BAUD ---
[1] = 500,000 // Baudrate
--- CAN_ADDR_FILTER 0 ---
[2] = 0x01 : CAN_FILTER_EN | CAN_FORMAT_STD
[3] = 0 : Id
[4] = 0 : Mask
--- CAN_ADDR_FILTER 1 ---
[5] = 0x03 : CAN_FILTER_EN | CAN_FORMAT_EXT
[6] = 0 : Id
[7] = 0 : Mask
--- CAN_ADDR_FILTER 2 ---
[8] = 0x02 : CAN_FILTER_DIS | CAN_FORMAT_EXT
[9] = 0x1FFFFFFF
[10] = 0x1FFFFFFF
--- CAN_ADDR_FILTER 3 ---
[11]-[13] = Same as Mask2
--- CAN_ADDR_FILTER 4 ---
[14]-[16] = Same as Mask2
--- CAN_ADDR_FILTER 5 ---
[17]-[19] = Same as Mask2
--- CAN_ADDR_FILTER 6 ---
[20]-[22] = Same as Mask2
--- CAN_ADDR_FILTER 7 ---
[23]-[25] = Same as Mask2
--- CAN_ADDR_FILTER 8 ---
[26]-[28] = Same as Mask2
--- CAN_ADDR_FILTER 9 ---
[29]-[31] = Same as Mask2
--- CAN_ADDR_FILTER 10 ---
[32]-[34] = Same as Mask2
--- CAN_ADDR_FILTER 11 ---
[35]-[37] = Same as Mask2
--- CAN_ADDR_FILTER 12 ---
[38]-[40] = Same as Mask2
--- CAN_ADDR_FILTER 13 ---
[41]-[43] = Same as Mask2
--- CAN_ADDR_ABOM ---
[44] = False
--- CAN_ADDR_ART ---
[45] = False
--- CAN_ADDR_VER ---
[46] = 1
USB CAN Adapter Communication Format
* Inquiry about MCU side information
Inquire using the following CAN-ID.
#define CAN_BAUDRATE_ID 0x01fffed0
#define CAN_CPU_INFO0_ID 0x01fffff0
#define CAN_CPU_INFO1_ID (CAN_CPU_INFO0_ID + 1)
#define CAN_VERSION_ID 0x01ffffe0
#define CAN_INIT_ID 0x01fffeff // Clean Flash(500,000 bps/mask 0x0000)
#define CAN_FILTER_BASE_ID 0x01fffeeX // X=0-F(Mask Index)
#define CAN_ABOM_ID 0x01fffeb0
#define CAN_ART_ID 0x01fffea0
#define CAN_RESET_ID 0x01fffec0 // Reset
c=0xAA
c=0xAA
c=0xD0 : (Inquire-ID >> 0) & 0xFF
c=0xFE : (Inquire-ID >> 8) & 0xFF
c=0xFF : (Inquire-ID >> 16) & 0xFF
c=0x01 : (Inquire-ID >> 24) & 0xFF
c=0x00 : Not use
c=0x00 : Not use
c=0x00 : Not use
c=0x00 : Not use
c=0x00 : Not use
c=0x00 : Not use
c=0x00 : Not use
c=0x00 : Not use
c=0x00 : Not use
c=0xFF : Must be 0xFF
c=0x01 : Must be 0x01
c=0x00 : Request Type(0:Set/1:Inquiry)
c=0x66 : CRC
c=0x55
c=0x55
** Inquiry VERSION
[AA AA E0 FF FF 01 00 00 00 00 00 00 00 00 00 FF 01 00 DF 55 55]
** Inquiry CPU_INFO0
[AA AA F0 FF FF 01 00 00 00 00 00 00 00 00 00 FF 01 00 EF 55 55]
** Inquiry CPU_INFO1
[AA AA F1 FF FF 01 00 00 00 00 00 00 00 00 00 FF 01 00 F0 55 55]
** Inquiry ABOM
[AA AA B0 FE FF 01 00 00 00 00 00 00 00 00 00 FF 01 00 AE 55 55]
** Inquiry ART
[AA AA A0 FE FF 01 00 00 00 00 00 00 00 00 00 FF 01 00 97 55 55]
** Inquiry BAUDRATE
[AA AA D0 FE FF 01 00 00 00 00 00 00 00 00 00 FF 01 01 CE 55 55]
** Inquiry MASK
[AA AA E0 FE FF 01 00 00 00 80 00 00 00 00 08 FF 01 00 66 55 55]
[AA AA E1 FE FF 01 00 00 00 C0 00 00 00 00 08 FF 01 00 A7 55 55]
[AA AA E2 FE FF 01 FF FF FF 5F FF FF FF 1F 08 FF 01 00 60 55 55]
[AA AA E3 FE FF 01 FF FF FF 5F FF FF FF 1F 08 FF 01 00 61 55 55]
[AA AA E4 FE FF 01 FF FF FF 5F FF FF FF 1F 08 FF 01 00 62 55 55]
[AA AA E5 FE FF 01 FF FF FF 5F FF FF FF 1F 08 FF 01 00 63 55 55]
[AA AA E6 FE FF 01 FF FF FF 5F FF FF FF 1F 08 FF 01 00 64 55 55]
[AA AA E7 FE FF 01 FF FF FF 5F FF FF FF 1F 08 FF 01 00 65 55 55]
[AA AA E8 FE FF 01 FF FF FF 5F FF FF FF 1F 08 FF 01 00 66 55 55]
[AA AA E9 FE FF 01 FF FF FF 5F FF FF FF 1F 08 FF 01 00 67 55 55]
[AA AA EA FE FF 01 FF FF FF 5F FF FF FF 1F 08 FF 01 00 68 55 55]
[AA AA EB FE FF 01 FF FF FF 5F FF FF FF 1F 08 FF 01 00 69 55 55]
[AA AA EC FE FF 01 FF FF FF 5F FF FF FF 1F 08 FF 01 00 6A 55 55]
[AA AA ED FE FF 01 FF FF FF 5F FF FF FF 1F 08 FF 01 00 6B 55 55]
[AA AA EE FE FF 01 00 00 00 00 01 00 00 00 08 FF 01 00 F5 55 55]
[AA AA EF FE FF 01 FF FF FF FF FF FF FF FF 08 FF 01 00 ED 55 55]
* Set BAUDRATE(1,000,000bps)
c=0xAA
c=0xAA
c=0xD0 : CAN_BAUDRATE_ID
c=0xFE : CAN_BAUDRATE_ID
c=0xFF : CAN_BAUDRATE_ID
c=0x01 : CAN_BAUDRATE_ID
c=0x40 : Speed
c=0x42 : Speed
c=0x0F : Speed
c=0x00 : Speed(0x000f4240=1,000,000)
c=0x01 : Not use
c=0x02 : Not use
c=0x00 : Not use
c=0x00 : Not use
c=0x04 : Frame Data Length
c=0xFF : System Message(Must be 0xFF)
c=0x01 : Must be Extended Frame
c=0x00 : Request Type(0:Set/1:Read)
c=0x66 : CRC
c=0x55
c=0x55
* Set BAUDRATE(800,000bps)
c=0xAA
c=0xAA
c=0xD0 : CAN_BAUDRATE_ID
c=0xFE : CAN_BAUDRATE_ID
c=0xFF : CAN_BAUDRATE_ID
c=0x01 : CAN_BAUDRATE_ID
c=0x00 : Speed
c=0x35 : Speed
c=0x0C : Speed
c=0x00 : Speed(0x000c3500=800,000)
c=0x01 : Not use
c=0x02 : Not use
c=0x00 : Not use
c=0x00 : Not use
c=0x04 : Frame Data Length
c=0xFF : System Message(Must be 0xFF)
c=0x01 : Must be Extended Frame
c=0x00 : Request Type(0:Set/1:Read)
c=0x16 : CRC
c=0x55
c=0x55
* Set BAUDRATE(500,000bps)
c=0xAA
c=0xAA
c=0xD0 :
c=0xFE :
c=0xFF :
c=0x01 :
c=0x20 : speed
c=0xA1 : speed
c=0x07 : speed
c=0x00 : speed(0x0007a120=500,000)
c=0x01
c=0x02
c=0x00
c=0x00
c=0x04
c=0xFF
c=0x01
c=0x00
c=0x9D
c=0x55
c=0x55
* Return
[AA AA D0 FE FF 01 20 A1 07 00 01 02 00 00 04 FF 01 01 9E 55 55 ]
* Set BAUDRATE(400,000bps)
c=0xAA
c=0xAA
c=0xD0
c=0xFE
c=0xFF
c=0x01
c=0x80 : speed
c=0x1A : speed
c=0x06 : speed
c=0x00 : speed(0x00061A80=400,000)
c=0x01
c=0x02
c=0x00
c=0x00
c=0x04
c=0xFF
c=0x01
c=0x00
c=0x75
c=0x55
c=0x55
* Set BAUDRATE(250,000bps)
c=0xAA
c=0xAA
c=0xD0
c=0xFE
c=0xFF
c=0x01
c=0x90 : speed
c=0xD0 : speed
c=0x03 : speed
c=0x00 : speed(0x0003D090=250,000)
c=0x01
c=0x02
c=0x00
c=0x00
c=0x04
c=0xFF
c=0x01
c=0x00
c=0x38
c=0x55
c=0x55
* Set BAUDRATE(125,000bps)
c=0xAA
c=0xAA
c=0xD0
c=0xFE
c=0xFF
c=0x01
c=0x48 : speed
c=0xE8 : speed
c=0x01 : speed
c=0x00 : speed(0x0001E848=125,000)
c=0x01
c=0x02
c=0x00
c=0x00
c=0x04
c=0xFF
c=0x01
c=0x00
c=0x06
c=0x55
c=0x55
* Set BAUDRATE(100,000bps)
c=0xAA
c=0xAA
c=0xD0
c=0xFE
c=0xFF
c=0x01
c=0xA0 : speed
c=0x86 : speed
c=0x01 : speed
c=0x00 : speed(0x000186A0=100,000)
c=0x01
c=0x02
c=0x00
c=0x00
c=0x04
c=0xFF
c=0x01
c=0x00
c=0xFC
c=0x55
c=0x55
* Set Receive Filter (Std format)
[00] 0xAA : Start Mark[1]
[01] 0xAA : Start mark[2]
---- Start of CRC Calculate ----
[02] 0xEn : Mask Number(0-15)
[03] 0x00
[04] 0x00
[05] 0x00
[06] 0x0F : (Id >> 0) & 0xFF
[07] 0x01 : (Id >> 8) & 0xFF
[08] 0x00 : (Id >> 16) & 0xFF
[09] 0x80 : (Id >> 24) & 0xFF + Enable(0x80)
[10] 0x10 : (Mask >> 0) & 0xFF
[11] 0x0F : (Mask >> 8) & 0xFF
[12] 0x00 : (Mask >> 16) & 0xFF
[13] 0x00 : (Mask >> 24) & 0xFF
[14] 0x08 : Frame Data jLength
[15] 0xFF : System Message(Must be 0xFF)
[16] 0x01 : Must be Extended Frame
[17] 0x00 : Must be 0(0:Set/1:Read)
---- End of CRC Calculate ----
[18] 0xA2 : CRC(8 bits)
[19] 0x55 : End Mark[0]
[20] 0x55 : End mark[1]
* Set Receive Filter (Ext format)
[00] 0xAA : Start Mark[1]
[01] 0xAA : Start mark[2]
---- Start of CRC Calculate ----
[02] 0x0x : Mask Number(0-15)
[03] 0x00
[04] 0x00
[05] 0x00
[06] 0x78 : (Id >> 0) & 0xFF
[07] 0x56 : (Id >> 8) & 0xFF
[08] 0x34 : (Id >> 16) & 0xFF
[09] 0x12 : (Id >> 24) & 0xFF + Enable(0x80)
[10] 0x78 : (Mask >> 0) & 0xFF
[11] 0x56 : (Mask >> 8) & 0xFF
[12] 0x34 : (Mask >> 16) & 0xFF
[13] 0x12 : (Mask >> 24) & 0xFF + Extende(0x40)
[14] 0x08 : Frame Data Length
[15] 0xFF : System Message(Must be 0xFF)
[16] 0x01 : Must be Extended Frame
[17] 0x00 : Must be 0(0:Set/1:Read)
---- End of CRC Calculate ----
[18] 0xA2 : CRC(8 bits)
[19] 0x55 : End Mark[0]
[20] 0x55 : End mark[1]
* CAN Frame Receive Format
[00] 0xAA : Start Mark[1]
[01] 0xAA : Start mark[2]
[02] 0x78 : (Frame ID & 0xFF) >> 0
[03] 0x56 : (Frame ID & 0xFF00) >> 8
[04] 0x34 : (Frame ID & 0xFF0000) >> 16
[05] 0x12 : (Frame ID & 0xFF000000) >> 24(0x12345678)
[06] 0x11 : Frame Data[0]
[07] 0x22 : Frame Data[1]
[08] 0x33 : Frame Data[2]
[09] 0x44 : Frame Data[3]
[10] 0x00 : Frame Data[4]
[11] 0x00 : Frame Data[5]
[12] 0x00 : Frame Data[6]
[13] 0x00 : Frame Data[70]
[14] c=04 : Frame Data Length
[15] c=00 : Message Type (00:Can Message/FF:System Message like BAUDRATE set)
[16] 0x01 : CAN Frame Type (0:Standard/1:Extended)
[17] 0x01 : CAN Request Type (0:Data frame/1:Remote frame)
[18] 0x3F : CRC
[19] 0x55 :
[20] 0x55 :
* Receive example
[AA AA 02 01 00 00 01 02 00 00 00 00 00 00 02 00 00 00 FF 55 55]
ID = 0x00000102
Data = 01 02 00 00 00 00 00 00
Length = 02
Type = Standard Data Frame
[AA AA 02 01 00 00 00 00 00 00 00 00 00 00 00 00 00 01 FF 55 55]
ID = 0x00000102
Data = 00 00 00 00 00 00 00 00
Length = 00
Type = Standard Remote Frame
[AA AA 61 00 00 10 10 11 12 13 14 15 00 00 06 00 01 00 E7 55 55]
ID = 0x10000061
Data = 10 11 12 13 14 15 00 00
Length = 06
Type = Extended Data Frame
[AA AA 61 00 00 10 00 00 00 00 00 00 00 00 00 00 01 01 E7 55 55]
ID = 0x10000061
Data = 00 00 00 00 00 00 00 00
Length = 00
Type = Extended Remote Frame
* Insert Frame Control Code
** There is neither 0xA5 / 0xAA / 0x55
** Packet is 21 Bytes
[00] 0xAA : Start Mark[1]
[01] 0xAA : Start mark[2]
---- Start of CRC Calculate ----
[02] 0x0B : Frame ID[3]
[03] 0x00 : Frame ID[2]
[04] 0x00 : Frame ID[1]
[05] 0x10 : Frame ID[0]
[06] 0x10 : Frame Data[0]
[07] 0x11 : Frame Data[1]
[08] 0x12 : Frame Data[2]
[09] 0x13 : Frame Data[3]
[10] 0x14 : Frame Data[4]
[11] 0x15 : Frame Data[5]
[12] 0x16 : Frame Data[6]
[13] 0x00 : Frame Data[7]
[14] 0x00 : Frame Data Length
[15] 0x00 : Message Type (00:Can Message)
[16] 0x01 : CAN Frame type (0:Standard/1:Extended)
[17] 0x01 : CAN Request Type (0:Data frame/1:Remote request frame)
---- End of CRC Calculate ----
[18] 0xA2 : CRC(8 bits)
[19] 0x55 : End Mark[0]
[20] 0x55 : End mark[1]
** CRC calcurate
Simple addition
|----------------------------------------------------| Range of CRC
[170, 170, 7, 1, 0, 0, 16, 17, 18, 19, 20, 21, 22, 23, 8, 0, 0, 0, 172, 85, 85]
** If there is 0xA5 / 0xAA / 0x55 in the CRC calculation range, insert FrameCtrl(0xA5)
FrameCtrl is not included in crc calculation.
[00] 0xAA : Start Mark[1]
[01] 0xAA : Start mark[2]
---- Start of CRC Calculate ----
[02] 0x0B : Frame ID[3]
[03] 0x00 : Frame ID[2]
[04] 0x00 : Frame ID[1]
[05] 0x10 : Frame ID[0]
[06] 0xA5 : FrameCtrl ---> Inserted (not included in crc calculation)
[07] 0x55 : Frame Data[0] ---> Ctrl Code
[08] 0x11 : Frame Data[1]
[09] 0x12 : Frame Data[2]
[10] 0xA5 : FrameCtrl ---> Inserted (not included in crc calculation)
[11] 0xAA : Frame Data[3] ---> Ctrl Code
[12] 0x14 : Frame Data[4]
[13] 0x15 : Frame Data[5]
[14] 0x16 : Frame Data[6]
[15] 0x00 : Frame Data[7]
[16] 0x00 : Frame Data Length
[17] 0x00 : Message Type (00:Can Message)
[18] 0x01 : CAN Frame type (0:Standard/1:Extended)
[19] 0x01 : CAN Request Type (0:Data frame/1:Remote request frame)
---- End of CRC Calculate ----
[20] 0xA2 : CRC(8 bits)
[21] 0x55 : End Mark[0]
[22] 0x55 : End mark[1]
Example
|---------------------------------------------------| Range of CRC
[AA AA 02 01 00 00 A5 A5 A5 55 00 00 00 00 00 00 02 00 00 00 FF 55 55]
CRC = 0x02+0x01+0xA5+0x55+0x02 = 0xFF
** If CRC is 0xA5 / 0xAA / 0x55, insert FrameCtrl(0xA5)
[00] 0xAA : Start Mark[1]
[01] 0xAA : Start mark[2]
---- Start of CRC Calculate ----
[02] 0x0B : Frame ID[3]
[03] 0x00 : Frame ID[2]
[04] 0x00 : Frame ID[1]
[05] 0x10 : Frame ID[0]
[06] 0x10 : Frame Data[0]
[07] 0x11 : Frame Data[1]
[08] 0x12 : Frame Data[2]
[09] 0x13 : Frame Data[3]
[10] 0x14 : Frame Data[4]
[11] 0x15 : Frame Data[5]
[12] 0x16 : Frame Data[6]
[13] 0x00 : Frame Data[7]
[14] 0x00 : Frame Data Length
[15] 0x00 : Message Type (00:Can Message)
[16] 0x01 : CAN Frame type (0:Standard/1:Extended)
[17] 0x01 : CAN Request Type (0:Data frame/1:Remote request frame)
---- End of CRC Calculate ----
[18] 0xA5 : FrameCtrl ---> Inserted
[19] 0xA5 : CRC(8 bits) ---> Real CRC
[20] 0x55 : End Mark[0]
[21] 0x55 : End mark[1]