bsp_can.txt
54.3 KB
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
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
; generated by Component: ARM Compiler 5.06 update 6 (build 750) Tool: ArmCC [4d3637]
; commandline ArmCC [--c99 --list --split_sections --debug -c --asm --interleave -o.\flash\obj\bsp_can.o --asm_dir=.\Flash\List\ --list_dir=.\Flash\List\ --depend=.\flash\obj\bsp_can.d --cpu=Cortex-M4.fp --apcs=interwork -O1 --diag_suppress=9931,870 -I..\..\Libraries\CMSIS\Include -I..\..\Libraries\CMSIS\Device\ST\STM32F4xx\Include -I..\..\Libraries\STM32F4xx_StdPeriph_Driver\inc -I..\..\uCOS-III\uC-CPU -I..\..\uCOS-III\uC-LIB -I..\..\uCOS-III\uCOS-III\Ports -I..\..\uCOS-III\uCOS-III\Source -I..\..\uCOS-III\uC-CPU\ARM-Cortex-M4\RealView -I..\..\uCOS-III\uC-LIB\Ports\ARM-Cortex-M4\RealView -I..\..\uCOS-III\uCOS-III\Ports\ARM-Cortex-M4\Generic\RealView -I..\..\User -I..\..\User\bsp -I..\..\User\bsp\inc -I..\..\User\libapp -I..\..\RL-ARM\Config -I..\..\RL-ARM\Driver -I..\..\RL-ARM\RL-RTX\inc -I..\..\User\bsp\BSP -I..\..\RL-ARM\RL-CAN -I..\..\Libraries\DSP_LIB\Include -I..\..\MODBUS\modbus\rtu -I..\..\MODBUS\BARE\port -I..\..\MODBUS\modbus\include -I..\..\User\bsp\BSP -I..\..\PLC -I..\..\Avoid -I..\..\User\parameter -I..\..\User\LaserMotionCtr -I..\..\User\W5100S -I..\..\User\bsp -I..\..\User\CHASSIS -I..\..\User\CONTROLFUNCTION -I..\..\User\DATAUPDATE -I..\..\User\HARAWARE -I..\..\User\MOTORDRIVER -I..\..\User\NAVAGATION -I..\..\User\PLATFORM -I..\..\User\SENSOR -I.\RTE\_Flash -IC:\Users\YDJ\AppData\Local\Arm\Packs\ARM\CMSIS\5.5.1\CMSIS\Core\Include -IC:\Users\YDJ\AppData\Local\Arm\Packs\Keil\STM32F4xx_DFP\2.13.0\Drivers\CMSIS\Device\ST\STM32F4xx\Include -D__UVISION_VERSION=527 -D_RTE_ -DSTM32F407xx -DUSE_STDPERIPH_DRIVER -DSTM32F40_41xxx -D__RTX -D__FPU_USED=1 --omf_browse=.\flash\obj\bsp_can.crf ..\..\User\bsp\BSP\bsp_can.c]
THUMB
AREA ||i.CAN1_Init||, CODE, READONLY, ALIGN=2
CAN1_Init PROC
;;;24 */
;;;25 void CAN1_Init(u16 Fdiv)
000000 b5f0 PUSH {r4-r7,lr}
;;;26 {
000002 b08b SUB sp,sp,#0x2c
000004 4606 MOV r6,r0
;;;27 GPIO_InitTypeDef GPIO_InitStructure;
;;;28 CAN_InitTypeDef CAN_InitStructure;
;;;29 CAN_FilterInitTypeDef CAN_FilterInitStructure;
;;;30 NVIC_InitTypeDef NVIC_InitStructure;
;;;31
;;;32 //使能相关时钟
;;;33 RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);//使能PORTA时钟
000006 2101 MOVS r1,#1
000008 4608 MOV r0,r1
00000a f7fffffe BL RCC_AHB1PeriphClockCmd
;;;34 RCC_APB1PeriphClockCmd(RCC_APB1Periph_CAN1, ENABLE);//使能CAN1时钟
00000e 2101 MOVS r1,#1
000010 0648 LSLS r0,r1,#25
000012 f7fffffe BL RCC_APB1PeriphClockCmd
;;;35
;;;36 //初始化GPIO
;;;37 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11| GPIO_Pin_12;
000016 f44f50c0 MOV r0,#0x1800
00001a 9009 STR r0,[sp,#0x24]
;;;38 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;//复用功能
00001c 2002 MOVS r0,#2
00001e f88d0028 STRB r0,[sp,#0x28]
;;;39 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//推挽输出
000022 2400 MOVS r4,#0
000024 f88d402a STRB r4,[sp,#0x2a]
;;;40 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;//100MHz
000028 2003 MOVS r0,#3
00002a f88d0029 STRB r0,[sp,#0x29]
;;;41 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//上拉
00002e 2501 MOVS r5,#1
000030 f88d502b STRB r5,[sp,#0x2b]
;;;42 GPIO_Init(GPIOA, &GPIO_InitStructure);//初始化PA11,PA12
000034 4f2c LDR r7,|L1.232|
000036 a909 ADD r1,sp,#0x24
000038 4638 MOV r0,r7
00003a f7fffffe BL GPIO_Init
;;;43
;;;44 //引脚复用映射配置
;;;45 GPIO_PinAFConfig(GPIOA,GPIO_PinSource11,GPIO_AF_CAN1); //GPIOA11复用为CAN1
00003e 2209 MOVS r2,#9
000040 210b MOVS r1,#0xb
000042 4638 MOV r0,r7
000044 f7fffffe BL GPIO_PinAFConfig
;;;46 GPIO_PinAFConfig(GPIOA,GPIO_PinSource12,GPIO_AF_CAN1); //GPIOA12复用为CAN1
000048 2209 MOVS r2,#9
00004a 210c MOVS r1,#0xc
00004c 4638 MOV r0,r7
00004e f7fffffe BL GPIO_PinAFConfig
;;;47
;;;48 //CAN单元设置
;;;49 CAN_InitStructure.CAN_TTCM = DISABLE; //非时间触发通信模式
000052 f88d401e STRB r4,[sp,#0x1e]
;;;50 CAN_InitStructure.CAN_ABOM = DISABLE; //软件自动离线管理
000056 f88d401f STRB r4,[sp,#0x1f]
;;;51 CAN_InitStructure.CAN_AWUM = DISABLE; //睡眠模式通过软件唤醒(清除CAN->MCR的SLEEP位)
00005a f88d4020 STRB r4,[sp,#0x20]
;;;52 CAN_InitStructure.CAN_NART = ENABLE; //禁止报文自动传送
00005e f88d5021 STRB r5,[sp,#0x21]
;;;53 CAN_InitStructure.CAN_RFLM = DISABLE; //报文不锁定,新的覆盖旧的
000062 f88d4022 STRB r4,[sp,#0x22]
;;;54 CAN_InitStructure.CAN_TXFP = DISABLE; //优先级由报文标识符决定
000066 f88d4023 STRB r4,[sp,#0x23]
;;;55 CAN_InitStructure.CAN_Mode = CAN_Mode_Normal; //模式设置
00006a f88d401a STRB r4,[sp,#0x1a]
;;;56 CAN_InitStructure.CAN_SJW = CAN_SJW_1tq; //重新同步跳跃宽度(Tsjw)为tsjw+1个时间单位 CAN_SJW_1tq~CAN_SJW_4tq
00006e f88d401b STRB r4,[sp,#0x1b]
;;;57 CAN_InitStructure.CAN_BS1 = CAN_BS1_7tq; //Tbs1范围CAN_BS1_1tq ~CAN_BS1_16tq
000072 2006 MOVS r0,#6
000074 f88d001c STRB r0,[sp,#0x1c]
;;;58 CAN_InitStructure.CAN_BS2 = CAN_BS2_6tq; //Tbs2范围CAN_BS2_1tq ~ CAN_BS2_8tq
000078 2005 MOVS r0,#5
00007a f88d001d STRB r0,[sp,#0x1d]
;;;59 CAN_InitStructure.CAN_Prescaler = Fdiv; //分频系数(Fdiv)为brp+1
00007e f8ad6018 STRH r6,[sp,#0x18]
;;;60 CAN_Init(CAN1, &CAN_InitStructure); //初始化CAN1
000082 4e1a LDR r6,|L1.236|
000084 a906 ADD r1,sp,#0x18
000086 4630 MOV r0,r6
000088 f7fffffe BL CAN_Init
;;;61
;;;62 //配置过滤器
;;;63 CAN_FilterInitStructure.CAN_FilterNumber = 0; //过滤器0
00008c f88d4012 STRB r4,[sp,#0x12]
;;;64 CAN_FilterInitStructure.CAN_FilterMode = CAN_FilterMode_IdMask;
000090 f88d4013 STRB r4,[sp,#0x13]
;;;65 CAN_FilterInitStructure.CAN_FilterScale = CAN_FilterScale_32bit; //32位
000094 f88d5014 STRB r5,[sp,#0x14]
;;;66 CAN_FilterInitStructure.CAN_FilterIdHigh = 0x0000; //32位ID
000098 f8ad4008 STRH r4,[sp,#8]
;;;67 CAN_FilterInitStructure.CAN_FilterIdLow = 0x0000;
00009c f8ad400a STRH r4,[sp,#0xa]
;;;68 CAN_FilterInitStructure.CAN_FilterMaskIdHigh = 0x0000;//32位MASK
0000a0 f8ad400c STRH r4,[sp,#0xc]
;;;69 CAN_FilterInitStructure.CAN_FilterMaskIdLow = 0x0000;
0000a4 f8ad400e STRH r4,[sp,#0xe]
;;;70 CAN_FilterInitStructure.CAN_FilterFIFOAssignment = CAN_Filter_FIFO0;//过滤器0关联到FIFO0
0000a8 f8ad4010 STRH r4,[sp,#0x10]
;;;71 CAN_FilterInitStructure.CAN_FilterActivation = ENABLE; //激活过滤器0
0000ac f88d5015 STRB r5,[sp,#0x15]
;;;72 CAN_FilterInit(&CAN_FilterInitStructure);//滤波器初始化
0000b0 a802 ADD r0,sp,#8
0000b2 f7fffffe BL CAN_FilterInit
;;;73
;;;74 CAN_ITConfig(CAN1,CAN_IT_FMP0,ENABLE);//FIFO0消息挂号中断允许.
0000b6 2201 MOVS r2,#1
0000b8 2102 MOVS r1,#2
0000ba 4630 MOV r0,r6
0000bc f7fffffe BL CAN_ITConfig
;;;75
;;;76 NVIC_InitStructure.NVIC_IRQChannel = CAN1_RX0_IRQn;
0000c0 2014 MOVS r0,#0x14
0000c2 f88d0004 STRB r0,[sp,#4]
;;;77 /*优先级设置较高*/
;;;78 NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 8; // 主优先级为1
0000c6 2008 MOVS r0,#8
0000c8 f88d0005 STRB r0,[sp,#5]
;;;79 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; // 次优先级为1
0000cc f88d4006 STRB r4,[sp,#6]
;;;80 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
0000d0 f88d5007 STRB r5,[sp,#7]
;;;81 NVIC_Init(&NVIC_InitStructure);
0000d4 a801 ADD r0,sp,#4
0000d6 f7fffffe BL NVIC_Init
;;;82
;;;83 can1Struct.RxBuf_In = 0;
0000da 4805 LDR r0,|L1.240|
0000dc 8004 STRH r4,[r0,#0]
;;;84 can1Struct.RxBuf_Out = 0;
0000de 8044 STRH r4,[r0,#2]
;;;85 can1Struct.TxBuf_In = 0;
0000e0 8084 STRH r4,[r0,#4]
;;;86 can1Struct.TxBuf_Out = 0;
0000e2 80c4 STRH r4,[r0,#6]
;;;87 }
0000e4 b00b ADD sp,sp,#0x2c
0000e6 bdf0 POP {r4-r7,pc}
;;;88
ENDP
|L1.232|
DCD 0x40020000
|L1.236|
DCD 0x40006400
|L1.240|
DCD ||.bss||+0x48
AREA ||i.CAN1_RX0_IRQHandler||, CODE, READONLY, ALIGN=2
CAN1_RX0_IRQHandler PROC
;;;243
;;;244 void CAN1_RX0_IRQHandler(void)
000000 b510 PUSH {r4,lr}
;;;245 {
000002 b086 SUB sp,sp,#0x18
;;;246 int i = 0;
;;;247 /*接收中断*/
;;;248 CPU_SR_ALLOC();
;;;249 CPU_CRITICAL_ENTER();
000004 f7fffffe BL CPU_SR_Save
000008 4604 MOV r4,r0
;;;250 OSIntEnter();
00000a f7fffffe BL OSIntEnter
;;;251 CPU_CRITICAL_EXIT();
00000e 4620 MOV r0,r4
000010 f7fffffe BL CPU_SR_Restore
;;;252 CanRxMsg g_tCanRxMsg; /* 用于接收 */
;;;253
;;;254 if(CAN_GetITStatus(CAN1,CAN_IT_FMP0) != RESET)
000014 4c08 LDR r4,|L2.56|
000016 2102 MOVS r1,#2
000018 4620 MOV r0,r4
00001a f7fffffe BL CAN_GetITStatus
00001e b120 CBZ r0,|L2.42|
;;;255 {
;;;256 CAN_Receive(CAN1, CAN_FIFO0, &g_tCanRxMsg);
000020 aa01 ADD r2,sp,#4
000022 2100 MOVS r1,#0
000024 4620 MOV r0,r4
000026 f7fffffe BL CAN_Receive
|L2.42|
;;;257
;;;258 }
;;;259 g_tCanRxMsg.StdId = 0;
00002a 2000 MOVS r0,#0
00002c 9001 STR r0,[sp,#4]
;;;260 g_tCanRxMsg.ExtId = 0;
00002e 9002 STR r0,[sp,#8]
;;;261 OSIntExit();
000030 f7fffffe BL OSIntExit
;;;262 }
000034 b006 ADD sp,sp,#0x18
000036 bd10 POP {r4,pc}
;;;263
ENDP
|L2.56|
DCD 0x40006400
AREA ||i.CAN1_Send_Msg||, CODE, READONLY, ALIGN=2
CAN1_Send_Msg PROC
;;;310 //CAN数据发送
;;;311 u8 CAN1_Send_Msg(unsigned short int StdID,unsigned char *msg, unsigned char len,u16 time)
000000 b5f0 PUSH {r4-r7,lr}
;;;312 {
000002 b087 SUB sp,sp,#0x1c
000004 4606 MOV r6,r0
000006 461d MOV r5,r3
;;;313 OS_ERR err;
;;;314 u8 j = 20;
000008 2414 MOVS r4,#0x14
;;;315 unsigned char mbox;
;;;316 unsigned int i = 0;
00000a 2000 MOVS r0,#0
;;;317 CanTxMsg TxMessage;
;;;318
;;;319 TxMessage.StdId = StdID; // 标准标识符为0
00000c 9601 STR r6,[sp,#4]
;;;320 TxMessage.ExtId = 0x12; // 设置扩展标示符(29位)
00000e 2312 MOVS r3,#0x12
000010 9302 STR r3,[sp,#8]
;;;321 TxMessage.IDE = 0; // 使用扩展标识符
000012 2300 MOVS r3,#0
000014 f88d300c STRB r3,[sp,#0xc]
;;;322 TxMessage.RTR = 0; // 消息类型为数据帧,一帧8位
000018 f88d300d STRB r3,[sp,#0xd]
;;;323 TxMessage.DLC = len;
00001c f88d200e STRB r2,[sp,#0xe]
000020 ab01 ADD r3,sp,#4 ;317
000022 e003 B |L3.44|
|L3.36|
;;;324
;;;325 for(i = 0; i < len; i++)
;;;326 {
;;;327 TxMessage.Data[i] = msg[i];
000024 181f ADDS r7,r3,r0
000026 5c0e LDRB r6,[r1,r0]
000028 72fe STRB r6,[r7,#0xb]
00002a 1c40 ADDS r0,r0,#1 ;325
|L3.44|
00002c 4290 CMP r0,r2 ;325
00002e d3f9 BCC |L3.36|
;;;328 }
;;;329 while(1)
;;;330 {
;;;331 {
;;;332 mbox = CAN_Transmit(CAN1, &TxMessage); //向CAN总线传输数据
;;;333 }
;;;334 // printf("发送完毕\r\n");
;;;335 if(mbox != CAN_TxStatus_NoMailBox)
;;;336 {
;;;337 while(CAN_TransmitStatus(CAN1, mbox) == CAN_TxStatus_Failed)
000030 4f0f LDR r7,|L3.112|
000032 e00c B |L3.78|
|L3.52|
;;;338 {
;;;339 if(j-- < 1)
000034 1e64 SUBS r4,r4,#1
000036 b2e4 UXTB r4,r4
000038 d311 BCC |L3.94|
|L3.58|
00003a 4631 MOV r1,r6 ;337
00003c 4638 MOV r0,r7 ;337
00003e f7fffffe BL CAN_TransmitStatus
000042 2800 CMP r0,#0 ;337
000044 d0f6 BEQ |L3.52|
000046 e00a B |L3.94|
|L3.72|
;;;340 {
;;;341 break;
;;;342 }
;;;343 }
;;;344 break;
;;;345 }
;;;346
;;;347 if(j-- < 1)
000048 1e64 SUBS r4,r4,#1
00004a b2e4 UXTB r4,r4
00004c d307 BCC |L3.94|
|L3.78|
00004e a901 ADD r1,sp,#4 ;332
000050 4638 MOV r0,r7 ;332
000052 f7fffffe BL CAN_Transmit
000056 4606 MOV r6,r0 ;332
000058 2e04 CMP r6,#4 ;335
00005a d0f5 BEQ |L3.72|
00005c e7ed B |L3.58|
|L3.94|
;;;348 {
;;;349 break;
;;;350 }
;;;351 }
;;;352 OSTimeDly(time, OS_OPT_TIME_PERIODIC, &err);
00005e aa06 ADD r2,sp,#0x18
000060 2108 MOVS r1,#8
000062 4628 MOV r0,r5
000064 f7fffffe BL OSTimeDly
;;;353 return 0;
;;;354 }
000068 b007 ADD sp,sp,#0x1c
00006a 2000 MOVS r0,#0 ;353
00006c bdf0 POP {r4-r7,pc}
;;;355
ENDP
00006e 0000 DCW 0x0000
|L3.112|
DCD 0x40006400
AREA ||i.CAN1_Send_Msg_Extend||, CODE, READONLY, ALIGN=2
CAN1_Send_Msg_Extend PROC
;;;356 //CAN数据发送 标准帧
;;;357 u8 CAN1_Send_Msg_Extend(unsigned int StdID,unsigned char *msg, unsigned char len,u16 time)
000000 b5f0 PUSH {r4-r7,lr}
;;;358 {
000002 b087 SUB sp,sp,#0x1c
000004 4606 MOV r6,r0
000006 461d MOV r5,r3
;;;359 OS_ERR err;
;;;360 u8 j = 20;
000008 2414 MOVS r4,#0x14
;;;361 unsigned char mbox;
;;;362 unsigned int i = 0;
00000a 2000 MOVS r0,#0
;;;363 CanTxMsg TxMessage;
;;;364
;;;365 // TxMessage.StdId = CYLINDER_FEEDBACK; // 标准标识符为0
;;;366 TxMessage.ExtId = StdID; // 设置扩展标示符(29位)
00000c 9602 STR r6,[sp,#8]
;;;367 TxMessage.IDE = CAN_ID_EXT; // 使用扩展标识符
00000e 2304 MOVS r3,#4
000010 f88d300c STRB r3,[sp,#0xc]
;;;368 TxMessage.RTR = CAN_RTR_DATA; // 消息类型为数据帧,一帧8位
000014 2300 MOVS r3,#0
000016 f88d300d STRB r3,[sp,#0xd]
;;;369 TxMessage.DLC = len;
00001a f88d200e STRB r2,[sp,#0xe]
00001e ab01 ADD r3,sp,#4 ;363
000020 e003 B |L4.42|
|L4.34|
;;;370
;;;371 for(i = 0; i < len; i++)
;;;372 {
;;;373 TxMessage.Data[i] = msg[i];
000022 181f ADDS r7,r3,r0
000024 5c0e LDRB r6,[r1,r0]
000026 72fe STRB r6,[r7,#0xb]
000028 1c40 ADDS r0,r0,#1 ;371
|L4.42|
00002a 4290 CMP r0,r2 ;371
00002c d3f9 BCC |L4.34|
;;;374 }
;;;375 while(1)
;;;376 {
;;;377 {
;;;378 mbox = CAN_Transmit(CAN1, &TxMessage); //向CAN总线传输数据
;;;379 }
;;;380 if(mbox != CAN_TxStatus_NoMailBox)
;;;381 {
;;;382 while(CAN_TransmitStatus(CAN1, mbox) == CAN_TxStatus_Failed)
00002e 4f0f LDR r7,|L4.108|
000030 e00c B |L4.76|
|L4.50|
;;;383 {
;;;384 if(j-- < 1)
000032 1e64 SUBS r4,r4,#1
000034 b2e4 UXTB r4,r4
000036 d311 BCC |L4.92|
|L4.56|
000038 4631 MOV r1,r6 ;382
00003a 4638 MOV r0,r7 ;382
00003c f7fffffe BL CAN_TransmitStatus
000040 2800 CMP r0,#0 ;382
000042 d0f6 BEQ |L4.50|
000044 e00a B |L4.92|
|L4.70|
;;;385 {
;;;386 break;
;;;387 }
;;;388 }
;;;389 break;
;;;390 }
;;;391
;;;392 if(j-- < 1)
000046 1e64 SUBS r4,r4,#1
000048 b2e4 UXTB r4,r4
00004a d307 BCC |L4.92|
|L4.76|
00004c a901 ADD r1,sp,#4 ;378
00004e 4638 MOV r0,r7 ;378
000050 f7fffffe BL CAN_Transmit
000054 4606 MOV r6,r0 ;378
000056 2e04 CMP r6,#4 ;380
000058 d0f5 BEQ |L4.70|
00005a e7ed B |L4.56|
|L4.92|
;;;393 {
;;;394 break;
;;;395 }
;;;396 }
;;;397 OSTimeDly(time, OS_OPT_TIME_PERIODIC, &err);
00005c aa06 ADD r2,sp,#0x18
00005e 2108 MOVS r1,#8
000060 4628 MOV r0,r5
000062 f7fffffe BL OSTimeDly
;;;398 return 0;
;;;399 }
000066 b007 ADD sp,sp,#0x1c
000068 2000 MOVS r0,#0 ;398
00006a bdf0 POP {r4-r7,pc}
;;;400
ENDP
|L4.108|
DCD 0x40006400
AREA ||i.CAN1_TX_IRQHandler||, CODE, READONLY, ALIGN=2
CAN1_TX_IRQHandler PROC
;;;286
;;;287 void CAN1_TX_IRQHandler(void)
000000 b510 PUSH {r4,lr}
;;;288 {
;;;289 CPU_SR_ALLOC();
;;;290 CPU_CRITICAL_ENTER();
000002 f7fffffe BL CPU_SR_Save
000006 4604 MOV r4,r0
;;;291 OSIntEnter();
000008 f7fffffe BL OSIntEnter
;;;292 CPU_CRITICAL_EXIT();
00000c 4620 MOV r0,r4
00000e f7fffffe BL CPU_SR_Restore
;;;293
;;;294 CAN_ClearITPendingBit(CAN1,CAN_IT_TME);
000012 4c17 LDR r4,|L5.112|
000014 2101 MOVS r1,#1
000016 4620 MOV r0,r4
000018 f7fffffe BL CAN_ClearITPendingBit
;;;295 if(CAN_GetITStatus(CAN1,CAN_IT_RQCP0) == SET)
00001c 2101 MOVS r1,#1
00001e 4620 MOV r0,r4
000020 f7fffffe BL CAN_GetITStatus
000024 2801 CMP r0,#1
000026 d00c BEQ |L5.66|
;;;296 {
;;;297 CAN_ClearITPendingBit(CAN1,CAN_IT_RQCP0);
;;;298 }
;;;299 else if(CAN_GetITStatus(CAN1,CAN_IT_RQCP1) == SET)
000028 2101 MOVS r1,#1
00002a 4620 MOV r0,r4
00002c f7fffffe BL CAN_GetITStatus
000030 2801 CMP r0,#1
000032 d00b BEQ |L5.76|
;;;300 {
;;;301 CAN_ClearITPendingBit(CAN1,CAN_IT_RQCP1);
;;;302 }
;;;303 else if(CAN_GetITStatus(CAN1,CAN_IT_RQCP2) == SET)
000034 2101 MOVS r1,#1
000036 4620 MOV r0,r4
000038 f7fffffe BL CAN_GetITStatus
00003c 2801 CMP r0,#1
00003e d00a BEQ |L5.86|
000040 e00d B |L5.94|
|L5.66|
000042 2101 MOVS r1,#1 ;297
000044 4620 MOV r0,r4 ;297
000046 f7fffffe BL CAN_ClearITPendingBit
00004a e008 B |L5.94|
|L5.76|
00004c 2101 MOVS r1,#1 ;301
00004e 4620 MOV r0,r4 ;301
000050 f7fffffe BL CAN_ClearITPendingBit
000054 e003 B |L5.94|
|L5.86|
;;;304 {
;;;305 CAN_ClearITPendingBit(CAN1,CAN_IT_RQCP2);
000056 2101 MOVS r1,#1
000058 4620 MOV r0,r4
00005a f7fffffe BL CAN_ClearITPendingBit
|L5.94|
;;;306 }
;;;307 CAN_ITConfig(CAN1, CAN_IT_TME, DISABLE);
00005e 2200 MOVS r2,#0
000060 2101 MOVS r1,#1
000062 4620 MOV r0,r4
000064 f7fffffe BL CAN_ITConfig
;;;308 OSIntExit();
000068 e8bd4010 POP {r4,lr}
00006c f7ffbffe B.W OSIntExit
;;;309 }
;;;310 //CAN数据发送
ENDP
|L5.112|
DCD 0x40006400
AREA ||i.CAN2_Init||, CODE, READONLY, ALIGN=2
CAN2_Init PROC
;;;88
;;;89 void CAN2_Init(u16 Fdiv)
000000 b5f0 PUSH {r4-r7,lr}
;;;90 {
000002 b08b SUB sp,sp,#0x2c
000004 4606 MOV r6,r0
;;;91 GPIO_InitTypeDef GPIO_InitStructure;
;;;92 CAN_InitTypeDef CAN_InitStructure;
;;;93 CAN_FilterInitTypeDef CAN_FilterInitStructure;
;;;94
;;;95 NVIC_InitTypeDef NVIC_InitStructure;
;;;96
;;;97 RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
000006 2101 MOVS r1,#1
000008 2002 MOVS r0,#2
00000a f7fffffe BL RCC_AHB1PeriphClockCmd
;;;98
;;;99 RCC_APB1PeriphClockCmd(RCC_APB1Periph_CAN1|RCC_APB1Periph_CAN2, ENABLE);//使能CAN2时钟,CAN1时钟必须开启
00000e 2101 MOVS r1,#1
000010 f04f60c0 MOV r0,#0x6000000
000014 f7fffffe BL RCC_APB1PeriphClockCmd
;;;100
;;;101 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5| GPIO_Pin_6;
000018 2060 MOVS r0,#0x60
00001a 9009 STR r0,[sp,#0x24]
;;;102 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
00001c 2002 MOVS r0,#2
00001e f88d0028 STRB r0,[sp,#0x28]
;;;103 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
000022 2400 MOVS r4,#0
000024 f88d402a STRB r4,[sp,#0x2a]
;;;104 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
000028 2003 MOVS r0,#3
00002a f88d0029 STRB r0,[sp,#0x29]
;;;105 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
00002e 2501 MOVS r5,#1
000030 f88d502b STRB r5,[sp,#0x2b]
;;;106 GPIO_Init(GPIOB, &GPIO_InitStructure);
000034 4f2d LDR r7,|L6.236|
000036 a909 ADD r1,sp,#0x24
000038 4638 MOV r0,r7
00003a f7fffffe BL GPIO_Init
;;;107
;;;108 GPIO_PinAFConfig(GPIOB,GPIO_PinSource5,GPIO_AF_CAN2);
00003e 2209 MOVS r2,#9
000040 2105 MOVS r1,#5
000042 4638 MOV r0,r7
000044 f7fffffe BL GPIO_PinAFConfig
;;;109 GPIO_PinAFConfig(GPIOB,GPIO_PinSource6,GPIO_AF_CAN2);
000048 2209 MOVS r2,#9
00004a 2106 MOVS r1,#6
00004c 4638 MOV r0,r7
00004e f7fffffe BL GPIO_PinAFConfig
;;;110
;;;111 CAN_InitStructure.CAN_TTCM=DISABLE;
000052 f88d401e STRB r4,[sp,#0x1e]
;;;112 CAN_InitStructure.CAN_ABOM=DISABLE;
000056 f88d401f STRB r4,[sp,#0x1f]
;;;113 CAN_InitStructure.CAN_AWUM=DISABLE;
00005a f88d4020 STRB r4,[sp,#0x20]
;;;114 CAN_InitStructure.CAN_NART=ENABLE;
00005e f88d5021 STRB r5,[sp,#0x21]
;;;115 CAN_InitStructure.CAN_RFLM=DISABLE;
000062 f88d4022 STRB r4,[sp,#0x22]
;;;116 CAN_InitStructure.CAN_TXFP=DISABLE;
000066 f88d4023 STRB r4,[sp,#0x23]
;;;117 CAN_InitStructure.CAN_Mode= CAN_Mode_Normal;
00006a f88d401a STRB r4,[sp,#0x1a]
;;;118
;;;119 CAN_InitStructure.CAN_SJW = CAN_SJW_1tq;
00006e f88d401b STRB r4,[sp,#0x1b]
;;;120 CAN_InitStructure.CAN_BS1 = CAN_BS1_7tq;
000072 2006 MOVS r0,#6
000074 f88d001c STRB r0,[sp,#0x1c]
;;;121 CAN_InitStructure.CAN_BS2 = CAN_BS2_6tq;
000078 2005 MOVS r0,#5
00007a f88d001d STRB r0,[sp,#0x1d]
;;;122 CAN_InitStructure.CAN_Prescaler = Fdiv;
00007e f8ad6018 STRH r6,[sp,#0x18]
;;;123
;;;124 CAN_Init(CAN2, &CAN_InitStructure);
000082 4e1b LDR r6,|L6.240|
000084 a906 ADD r1,sp,#0x18
000086 4630 MOV r0,r6
000088 f7fffffe BL CAN_Init
;;;125
;;;126 CAN_FilterInitStructure.CAN_FilterNumber=14;
00008c 200e MOVS r0,#0xe
00008e f88d0012 STRB r0,[sp,#0x12]
;;;127 CAN_FilterInitStructure.CAN_FilterMode=CAN_FilterMode_IdMask;
000092 f88d4013 STRB r4,[sp,#0x13]
;;;128 CAN_FilterInitStructure.CAN_FilterScale=CAN_FilterScale_32bit;
000096 f88d5014 STRB r5,[sp,#0x14]
;;;129 CAN_FilterInitStructure.CAN_FilterIdHigh=0x0000;
00009a f8ad4008 STRH r4,[sp,#8]
;;;130 CAN_FilterInitStructure.CAN_FilterIdLow=0x0000;
00009e f8ad400a STRH r4,[sp,#0xa]
;;;131 CAN_FilterInitStructure.CAN_FilterMaskIdHigh=0x0000;
0000a2 f8ad400c STRH r4,[sp,#0xc]
;;;132 CAN_FilterInitStructure.CAN_FilterMaskIdLow=0x0000;
0000a6 f8ad400e STRH r4,[sp,#0xe]
;;;133 CAN_FilterInitStructure.CAN_FilterFIFOAssignment=CAN_Filter_FIFO0;
0000aa f8ad4010 STRH r4,[sp,#0x10]
;;;134 CAN_FilterInitStructure.CAN_FilterActivation=ENABLE;
0000ae f88d5015 STRB r5,[sp,#0x15]
;;;135 CAN_FilterInit(&CAN_FilterInitStructure);
0000b2 a802 ADD r0,sp,#8
0000b4 f7fffffe BL CAN_FilterInit
;;;136
;;;137 CAN_ITConfig(CAN2,CAN_IT_FMP0,ENABLE);
0000b8 2201 MOVS r2,#1
0000ba 2102 MOVS r1,#2
0000bc 4630 MOV r0,r6
0000be f7fffffe BL CAN_ITConfig
;;;138
;;;139 NVIC_InitStructure.NVIC_IRQChannel = CAN2_RX0_IRQn;
0000c2 2040 MOVS r0,#0x40
0000c4 f88d0004 STRB r0,[sp,#4]
;;;140 NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 7;
0000c8 2007 MOVS r0,#7
0000ca f88d0005 STRB r0,[sp,#5]
;;;141 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
0000ce f88d4006 STRB r4,[sp,#6]
;;;142 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
0000d2 f88d5007 STRB r5,[sp,#7]
;;;143 NVIC_Init(&NVIC_InitStructure);
0000d6 a801 ADD r0,sp,#4
0000d8 f7fffffe BL NVIC_Init
;;;144 can2Struct.RxBuf_In = 0;
0000dc 4805 LDR r0,|L6.244|
0000de 8004 STRH r4,[r0,#0]
;;;145 can2Struct.RxBuf_Out = 0;
0000e0 8044 STRH r4,[r0,#2]
;;;146 can2Struct.TxBuf_In = 0;
0000e2 8084 STRH r4,[r0,#4]
;;;147 can2Struct.TxBuf_Out = 0;
0000e4 80c4 STRH r4,[r0,#6]
;;;148 }
0000e6 b00b ADD sp,sp,#0x2c
0000e8 bdf0 POP {r4-r7,pc}
;;;149
ENDP
0000ea 0000 DCW 0x0000
|L6.236|
DCD 0x40020400
|L6.240|
DCD 0x40006800
|L6.244|
DCD ||.bss||+0x98
AREA ||i.CAN2_RX0_IRQHandler||, CODE, READONLY, ALIGN=2
CAN2_RX0_IRQHandler PROC
;;;264
;;;265 void CAN2_RX0_IRQHandler(void)
000000 b510 PUSH {r4,lr}
;;;266 {
000002 b086 SUB sp,sp,#0x18
;;;267 /*接收中断*/
;;;268 int i = 0;
;;;269 CPU_SR_ALLOC();
;;;270 CPU_CRITICAL_ENTER();
000004 f7fffffe BL CPU_SR_Save
000008 4604 MOV r4,r0
;;;271 OSIntEnter();
00000a f7fffffe BL OSIntEnter
;;;272 CPU_CRITICAL_EXIT();
00000e 4620 MOV r0,r4
000010 f7fffffe BL CPU_SR_Restore
;;;273 CanRxMsg g_tCanRxMsg; /* 用于接收 */
;;;274
;;;275 if(CAN_GetITStatus(CAN2,CAN_IT_FMP0) != RESET)
000014 4c08 LDR r4,|L7.56|
000016 2102 MOVS r1,#2
000018 4620 MOV r0,r4
00001a f7fffffe BL CAN_GetITStatus
00001e b120 CBZ r0,|L7.42|
;;;276 {
;;;277 CAN_Receive(CAN2, CAN_FIFO0, &g_tCanRxMsg);
000020 aa01 ADD r2,sp,#4
000022 2100 MOVS r1,#0
000024 4620 MOV r0,r4
000026 f7fffffe BL CAN_Receive
|L7.42|
;;;278
;;;279
;;;280 }
;;;281
;;;282 g_tCanRxMsg.StdId = 0;
00002a 2000 MOVS r0,#0
00002c 9001 STR r0,[sp,#4]
;;;283 g_tCanRxMsg.ExtId = 0;
00002e 9002 STR r0,[sp,#8]
;;;284 OSIntExit();
000030 f7fffffe BL OSIntExit
;;;285 }
000034 b006 ADD sp,sp,#0x18
000036 bd10 POP {r4,pc}
;;;286
ENDP
|L7.56|
DCD 0x40006800
AREA ||i.CAN2_Send_Msg||, CODE, READONLY, ALIGN=2
CAN2_Send_Msg PROC
;;;183 //CAN数据发送
;;;184 u8 CAN2_Send_Msg(unsigned short int StdID,unsigned char *msg, unsigned char len,u16 time)
000000 b5f0 PUSH {r4-r7,lr}
;;;185 {
000002 b087 SUB sp,sp,#0x1c
000004 4606 MOV r6,r0
000006 461d MOV r5,r3
;;;186 OS_ERR err;
;;;187 u8 j = 20;
000008 2414 MOVS r4,#0x14
;;;188 unsigned char mbox;
;;;189 unsigned int i = 0;
00000a 2000 MOVS r0,#0
;;;190 CanTxMsg TxMessage;
;;;191
;;;192 TxMessage.StdId = StdID; // 标准标识符为0
00000c 9601 STR r6,[sp,#4]
;;;193 TxMessage.ExtId = 0x12; // 设置扩展标示符(29位)
00000e 2312 MOVS r3,#0x12
000010 9302 STR r3,[sp,#8]
;;;194 TxMessage.IDE = 0; // 使用扩展标识符
000012 2300 MOVS r3,#0
000014 f88d300c STRB r3,[sp,#0xc]
;;;195 TxMessage.RTR = 0; // 消息类型为数据帧,一帧8位
000018 f88d300d STRB r3,[sp,#0xd]
;;;196 TxMessage.DLC = len;
00001c f88d200e STRB r2,[sp,#0xe]
000020 ab01 ADD r3,sp,#4 ;190
000022 e003 B |L8.44|
|L8.36|
;;;197
;;;198 for(i = 0; i < len; i++)
;;;199 {
;;;200 TxMessage.Data[i] = msg[i];
000024 181f ADDS r7,r3,r0
000026 5c0e LDRB r6,[r1,r0]
000028 72fe STRB r6,[r7,#0xb]
00002a 1c40 ADDS r0,r0,#1 ;198
|L8.44|
00002c 4290 CMP r0,r2 ;198
00002e d3f9 BCC |L8.36|
;;;201 }
;;;202 while(1)
;;;203 {
;;;204 {
;;;205 mbox = CAN_Transmit(CAN2, &TxMessage); //向CAN总线传输数据
;;;206 }
;;;207 if(mbox != CAN_TxStatus_NoMailBox)
;;;208 {
;;;209 while(CAN_TransmitStatus(CAN2, mbox) == CAN_TxStatus_Failed)
000030 4f0f LDR r7,|L8.112|
000032 e00c B |L8.78|
|L8.52|
;;;210 {
;;;211 if(j-- < 1)
000034 1e64 SUBS r4,r4,#1
000036 b2e4 UXTB r4,r4
000038 d311 BCC |L8.94|
|L8.58|
00003a 4631 MOV r1,r6 ;209
00003c 4638 MOV r0,r7 ;209
00003e f7fffffe BL CAN_TransmitStatus
000042 2800 CMP r0,#0 ;209
000044 d0f6 BEQ |L8.52|
000046 e00a B |L8.94|
|L8.72|
;;;212 {
;;;213 break;
;;;214 }
;;;215 }
;;;216 break;
;;;217 }
;;;218
;;;219 if(j-- < 1)
000048 1e64 SUBS r4,r4,#1
00004a b2e4 UXTB r4,r4
00004c d307 BCC |L8.94|
|L8.78|
00004e a901 ADD r1,sp,#4 ;205
000050 4638 MOV r0,r7 ;205
000052 f7fffffe BL CAN_Transmit
000056 4606 MOV r6,r0 ;205
000058 2e04 CMP r6,#4 ;207
00005a d0f5 BEQ |L8.72|
00005c e7ed B |L8.58|
|L8.94|
;;;220 {
;;;221 break;
;;;222 }
;;;223 }
;;;224 OSTimeDly(time, OS_OPT_TIME_PERIODIC, &err);
00005e aa06 ADD r2,sp,#0x18
000060 2108 MOVS r1,#8
000062 4628 MOV r0,r5
000064 f7fffffe BL OSTimeDly
;;;225 return 0;
;;;226 }
000068 b007 ADD sp,sp,#0x1c
00006a 2000 MOVS r0,#0 ;225
00006c bdf0 POP {r4-r7,pc}
;;;227
ENDP
00006e 0000 DCW 0x0000
|L8.112|
DCD 0x40006800
AREA ||i.CAN2_Send_Msg_Extend||, CODE, READONLY, ALIGN=2
CAN2_Send_Msg_Extend PROC
;;;401
;;;402 u8 CAN2_Send_Msg_Extend(unsigned int StdID,unsigned char *msg, unsigned char len,u16 time)
000000 b5f0 PUSH {r4-r7,lr}
;;;403 {
000002 b087 SUB sp,sp,#0x1c
000004 4606 MOV r6,r0
000006 461d MOV r5,r3
;;;404 OS_ERR err;
;;;405 u8 j = 20;
000008 2414 MOVS r4,#0x14
;;;406 unsigned char mbox;
;;;407 unsigned int i = 0;
00000a 2000 MOVS r0,#0
;;;408 CanTxMsg TxMessage;
;;;409
;;;410 // TxMessage.StdId = CYLINDER_FEEDBACK; // 标准标识符为0
;;;411 TxMessage.ExtId = StdID; // 设置扩展标示符(29位)
00000c 9602 STR r6,[sp,#8]
;;;412 TxMessage.IDE = CAN_ID_EXT; // 使用扩展标识符
00000e 2304 MOVS r3,#4
000010 f88d300c STRB r3,[sp,#0xc]
;;;413 TxMessage.RTR = CAN_RTR_DATA; // 消息类型为数据帧,一帧8位
000014 2300 MOVS r3,#0
000016 f88d300d STRB r3,[sp,#0xd]
;;;414 TxMessage.DLC = len;
00001a f88d200e STRB r2,[sp,#0xe]
00001e ab01 ADD r3,sp,#4 ;408
000020 e003 B |L9.42|
|L9.34|
;;;415
;;;416 for(i = 0; i < len; i++)
;;;417 {
;;;418 TxMessage.Data[i] = msg[i];
000022 181f ADDS r7,r3,r0
000024 5c0e LDRB r6,[r1,r0]
000026 72fe STRB r6,[r7,#0xb]
000028 1c40 ADDS r0,r0,#1 ;416
|L9.42|
00002a 4290 CMP r0,r2 ;416
00002c d3f9 BCC |L9.34|
;;;419 }
;;;420 while(1)
;;;421 {
;;;422 {
;;;423 mbox = CAN_Transmit(CAN2, &TxMessage); //向CAN总线传输数据
;;;424 }
;;;425 if(mbox != CAN_TxStatus_NoMailBox)
;;;426 {
;;;427 while(CAN_TransmitStatus(CAN2, mbox) == CAN_TxStatus_Failed)
00002e 4f0f LDR r7,|L9.108|
000030 e00c B |L9.76|
|L9.50|
;;;428 {
;;;429 if(j-- < 1)
000032 1e64 SUBS r4,r4,#1
000034 b2e4 UXTB r4,r4
000036 d311 BCC |L9.92|
|L9.56|
000038 4631 MOV r1,r6 ;427
00003a 4638 MOV r0,r7 ;427
00003c f7fffffe BL CAN_TransmitStatus
000040 2800 CMP r0,#0 ;427
000042 d0f6 BEQ |L9.50|
000044 e00a B |L9.92|
|L9.70|
;;;430 {
;;;431 break;
;;;432 }
;;;433 }
;;;434 break;
;;;435 }
;;;436
;;;437 if(j-- < 1)
000046 1e64 SUBS r4,r4,#1
000048 b2e4 UXTB r4,r4
00004a d307 BCC |L9.92|
|L9.76|
00004c a901 ADD r1,sp,#4 ;423
00004e 4638 MOV r0,r7 ;423
000050 f7fffffe BL CAN_Transmit
000054 4606 MOV r6,r0 ;423
000056 2e04 CMP r6,#4 ;425
000058 d0f5 BEQ |L9.70|
00005a e7ed B |L9.56|
|L9.92|
;;;438 {
;;;439 break;
;;;440 }
;;;441 }
;;;442 OSTimeDly(time, OS_OPT_TIME_PERIODIC, &err);
00005c aa06 ADD r2,sp,#0x18
00005e 2108 MOVS r1,#8
000060 4628 MOV r0,r5
000062 f7fffffe BL OSTimeDly
;;;443 return 0;
;;;444 }
000066 b007 ADD sp,sp,#0x1c
000068 2000 MOVS r0,#0 ;443
00006a bdf0 POP {r4-r7,pc}
;;;445
ENDP
|L9.108|
DCD 0x40006800
AREA ||i.CAN2_TX_IRQHandler||, CODE, READONLY, ALIGN=2
CAN2_TX_IRQHandler PROC
;;;159
;;;160 void CAN2_TX_IRQHandler(void)
000000 b510 PUSH {r4,lr}
;;;161 {
;;;162 CPU_SR_ALLOC();
;;;163 CPU_CRITICAL_ENTER();
000002 f7fffffe BL CPU_SR_Save
000006 4604 MOV r4,r0
;;;164 OSIntEnter();
000008 f7fffffe BL OSIntEnter
;;;165 CPU_CRITICAL_EXIT();
00000c 4620 MOV r0,r4
00000e f7fffffe BL CPU_SR_Restore
;;;166
;;;167 CAN_ClearITPendingBit(CAN2,CAN_IT_TME);
000012 4c17 LDR r4,|L10.112|
000014 2101 MOVS r1,#1
000016 4620 MOV r0,r4
000018 f7fffffe BL CAN_ClearITPendingBit
;;;168 if(CAN_GetITStatus(CAN2,CAN_IT_RQCP0) == SET)
00001c 2101 MOVS r1,#1
00001e 4620 MOV r0,r4
000020 f7fffffe BL CAN_GetITStatus
000024 2801 CMP r0,#1
000026 d00c BEQ |L10.66|
;;;169 {
;;;170 CAN_ClearITPendingBit(CAN2,CAN_IT_RQCP0);
;;;171 }
;;;172 else if(CAN_GetITStatus(CAN2,CAN_IT_RQCP1) == SET)
000028 2101 MOVS r1,#1
00002a 4620 MOV r0,r4
00002c f7fffffe BL CAN_GetITStatus
000030 2801 CMP r0,#1
000032 d00b BEQ |L10.76|
;;;173 {
;;;174 CAN_ClearITPendingBit(CAN2,CAN_IT_RQCP1);
;;;175 }
;;;176 else if(CAN_GetITStatus(CAN2,CAN_IT_RQCP2) == SET)
000034 2101 MOVS r1,#1
000036 4620 MOV r0,r4
000038 f7fffffe BL CAN_GetITStatus
00003c 2801 CMP r0,#1
00003e d00a BEQ |L10.86|
000040 e00d B |L10.94|
|L10.66|
000042 2101 MOVS r1,#1 ;170
000044 4620 MOV r0,r4 ;170
000046 f7fffffe BL CAN_ClearITPendingBit
00004a e008 B |L10.94|
|L10.76|
00004c 2101 MOVS r1,#1 ;174
00004e 4620 MOV r0,r4 ;174
000050 f7fffffe BL CAN_ClearITPendingBit
000054 e003 B |L10.94|
|L10.86|
;;;177 {
;;;178 CAN_ClearITPendingBit(CAN2,CAN_IT_RQCP2);
000056 2101 MOVS r1,#1
000058 4620 MOV r0,r4
00005a f7fffffe BL CAN_ClearITPendingBit
|L10.94|
;;;179 }
;;;180 CAN_ITConfig(CAN2, CAN_IT_TME, DISABLE);
00005e 2200 MOVS r2,#0
000060 2101 MOVS r1,#1
000062 4620 MOV r0,r4
000064 f7fffffe BL CAN_ITConfig
;;;181 OSIntExit();
000068 e8bd4010 POP {r4,lr}
00006c f7ffbffe B.W OSIntExit
;;;182 }
;;;183 //CAN数据发送
ENDP
|L10.112|
DCD 0x40006800
AREA ||i.CAN_Send_Msg||, CODE, READONLY, ALIGN=2
CAN_Send_Msg PROC
;;;446 //CAN数据发送
;;;447 u8 CAN_Send_Msg(unsigned short int StdID,unsigned char *msg, unsigned char len,u16 time,u8 CanSelect)
000000 e92d43f0 PUSH {r4-r9,lr}
;;;448 {
000004 b087 SUB sp,sp,#0x1c
000006 461f MOV r7,r3
000008 9e0e LDR r6,[sp,#0x38]
;;;449 OS_ERR err;
;;;450 u8 j = 20;
00000a 2414 MOVS r4,#0x14
;;;451 unsigned char mbox;
;;;452 CanTxMsg TxMessage;
;;;453
;;;454 TxMessage.StdId = StdID; // 标准标识符为0
00000c 9001 STR r0,[sp,#4]
;;;455 TxMessage.ExtId = 0x12; // 设置扩展标示符(29位)
00000e 2012 MOVS r0,#0x12
000010 9002 STR r0,[sp,#8]
;;;456 TxMessage.IDE = 0; // 使用扩展标识符
000012 2000 MOVS r0,#0
000014 f88d000c STRB r0,[sp,#0xc]
;;;457 TxMessage.RTR = 0; // 消息类型为数据帧,一帧8位
000018 f88d000d STRB r0,[sp,#0xd]
;;;458 TxMessage.DLC = len;
00001c f88d200e STRB r2,[sp,#0xe]
000020 ab01 ADD r3,sp,#4 ;452
000022 e005 B |L11.48|
|L11.36|
;;;459
;;;460 for(unsigned int i = 0; i < len; i++)
;;;461 {
;;;462 TxMessage.Data[i] = msg[i];
000024 eb030c00 ADD r12,r3,r0
000028 5c0d LDRB r5,[r1,r0]
00002a f88c500b STRB r5,[r12,#0xb]
00002e 1c40 ADDS r0,r0,#1 ;460
|L11.48|
000030 4290 CMP r0,r2 ;460
000032 d3f7 BCC |L11.36|
;;;463 }
;;;464
;;;465 while(1)
;;;466 {
;;;467 if(CanSelect == 1)
;;;468 {
;;;469 mbox = CAN_Transmit(CAN1, &TxMessage); //向CAN总线传输数据
000034 f8df8074 LDR r8,|L11.172|
;;;470 if(mbox != CAN_TxStatus_NoMailBox)
;;;471 {
;;;472 while(CAN_TransmitStatus(CAN1, mbox) == CAN_TxStatus_Failed)
;;;473 {
;;;474 if(j-- < 1)
;;;475 {
;;;476 break;
;;;477 }
;;;478 }
;;;479 break;
;;;480 }
;;;481
;;;482 if(j-- < 1)
;;;483 {
;;;484 break;
;;;485 }
;;;486 }
;;;487 else
;;;488 {
;;;489 mbox = CAN_Transmit(CAN2, &TxMessage); //向CAN总线传输数据
000038 f8df9074 LDR r9,|L11.176|
00003c e02a B |L11.148|
|L11.62|
00003e a901 ADD r1,sp,#4 ;469
000040 4640 MOV r0,r8 ;469
000042 f7fffffe BL CAN_Transmit
000046 4605 MOV r5,r0 ;469
000048 2d04 CMP r5,#4 ;470
00004a d103 BNE |L11.84|
00004c e009 B |L11.98|
|L11.78|
00004e 1e64 SUBS r4,r4,#1 ;474
000050 b2e4 UXTB r4,r4 ;474
000052 d322 BCC |L11.154|
|L11.84|
000054 4629 MOV r1,r5 ;472
000056 4640 MOV r0,r8 ;472
000058 f7fffffe BL CAN_TransmitStatus
00005c 2800 CMP r0,#0 ;472
00005e d0f6 BEQ |L11.78|
000060 e01b B |L11.154|
|L11.98|
000062 1e64 SUBS r4,r4,#1 ;482
000064 b2e4 UXTB r4,r4 ;482
000066 d215 BCS |L11.148|
000068 e017 B |L11.154|
|L11.106|
00006a a901 ADD r1,sp,#4
00006c 4648 MOV r0,r9
00006e f7fffffe BL CAN_Transmit
000072 4605 MOV r5,r0
;;;490 if(mbox != CAN_TxStatus_NoMailBox)
000074 2d04 CMP r5,#4
000076 d103 BNE |L11.128|
000078 e009 B |L11.142|
|L11.122|
;;;491 {
;;;492 while(CAN_TransmitStatus(CAN2, mbox) == CAN_TxStatus_Failed)
;;;493 {
;;;494 if(j-- < 1)
00007a 1e64 SUBS r4,r4,#1
00007c b2e4 UXTB r4,r4
00007e d30c BCC |L11.154|
|L11.128|
000080 4629 MOV r1,r5 ;492
000082 4648 MOV r0,r9 ;492
000084 f7fffffe BL CAN_TransmitStatus
000088 2800 CMP r0,#0 ;492
00008a d0f6 BEQ |L11.122|
00008c e005 B |L11.154|
|L11.142|
;;;495 {
;;;496 break;
;;;497 }
;;;498 }
;;;499 break;
;;;500 }
;;;501
;;;502 if(j-- < 1)
00008e 1e64 SUBS r4,r4,#1
000090 b2e4 UXTB r4,r4
000092 d302 BCC |L11.154|
|L11.148|
000094 2e01 CMP r6,#1 ;467
000096 d1e8 BNE |L11.106|
000098 e7d1 B |L11.62|
|L11.154|
;;;503 {
;;;504 break;
;;;505 }
;;;506 }
;;;507 }
;;;508 OSTimeDly(time, OS_OPT_TIME_PERIODIC, &err);
00009a aa06 ADD r2,sp,#0x18
00009c 2108 MOVS r1,#8
00009e 4638 MOV r0,r7
0000a0 f7fffffe BL OSTimeDly
;;;509 return 0;
;;;510 }
0000a4 b007 ADD sp,sp,#0x1c
0000a6 2000 MOVS r0,#0 ;509
0000a8 e8bd83f0 POP {r4-r9,pc}
ENDP
|L11.172|
DCD 0x40006400
|L11.176|
DCD 0x40006800
AREA ||.bss||, DATA, NOINIT, ALIGN=2
can1Struct
% 80
can2Struct
% 80
AREA ||area_number.14||, DATA, NOINIT, ALIGN=1
EXPORTAS ||area_number.14||, ||.bss||
BMSmsg
% 128
AREA ||.data||, DATA, ALIGN=2
OneLeftState
DCD 0x00000000
AREA ||area_number.17||, DATA, ALIGN=2
EXPORTAS ||area_number.17||, ||.data||
OneRightState
DCD 0x00000000
AREA ||area_number.18||, DATA, ALIGN=2
EXPORTAS ||area_number.18||, ||.data||
TwoLeftState
DCD 0x00000000
AREA ||area_number.19||, DATA, ALIGN=2
EXPORTAS ||area_number.19||, ||.data||
TwoRightState
DCD 0x00000000
AREA ||area_number.20||, DATA, ALIGN=2
EXPORTAS ||area_number.20||, ||.data||
ThreeLeftState
DCD 0x00000000
AREA ||area_number.21||, DATA, ALIGN=2
EXPORTAS ||area_number.21||, ||.data||
ThreeRightState
DCD 0x00000000
AREA ||area_number.22||, DATA, ALIGN=2
EXPORTAS ||area_number.22||, ||.data||
FourLeftState
DCD 0x00000000
AREA ||area_number.23||, DATA, ALIGN=2
EXPORTAS ||area_number.23||, ||.data||
FourRightState
DCD 0x00000000
AREA ||area_number.24||, DATA, ALIGN=2
EXPORTAS ||area_number.24||, ||.data||
OneLeftData
DCD 0x00000000
AREA ||area_number.25||, DATA, ALIGN=2
EXPORTAS ||area_number.25||, ||.data||
OneRightData
DCD 0x00000000
AREA ||area_number.26||, DATA, ALIGN=2
EXPORTAS ||area_number.26||, ||.data||
TwoLeftData
DCD 0x00000000
AREA ||area_number.27||, DATA, ALIGN=2
EXPORTAS ||area_number.27||, ||.data||
TwoRightData
DCD 0x00000000
AREA ||area_number.28||, DATA, ALIGN=2
EXPORTAS ||area_number.28||, ||.data||
ThreeLeftData
DCD 0x00000000
AREA ||area_number.29||, DATA, ALIGN=2
EXPORTAS ||area_number.29||, ||.data||
ThreeRightData
DCD 0x00000000
AREA ||area_number.30||, DATA, ALIGN=2
EXPORTAS ||area_number.30||, ||.data||
FourLeftData
DCD 0x00000000
AREA ||area_number.31||, DATA, ALIGN=2
EXPORTAS ||area_number.31||, ||.data||
FourRightData
DCD 0x00000000
AREA ||area_number.32||, DATA, ALIGN=2
EXPORTAS ||area_number.32||, ||.data||
OneLeftMagBias
DCD 0x00000000
AREA ||area_number.33||, DATA, ALIGN=2
EXPORTAS ||area_number.33||, ||.data||
OneRightMagBias
DCD 0x00000000
AREA ||area_number.34||, DATA, ALIGN=2
EXPORTAS ||area_number.34||, ||.data||
TwoLeftMagBias
DCD 0x00000000
AREA ||area_number.35||, DATA, ALIGN=2
EXPORTAS ||area_number.35||, ||.data||
TwoRightMagBias
DCD 0x00000000
AREA ||area_number.36||, DATA, ALIGN=2
EXPORTAS ||area_number.36||, ||.data||
ThreeLeftMagBias
DCD 0x00000000
AREA ||area_number.37||, DATA, ALIGN=2
EXPORTAS ||area_number.37||, ||.data||
ThreeRightMagBias
DCD 0x00000000
AREA ||area_number.38||, DATA, ALIGN=2
EXPORTAS ||area_number.38||, ||.data||
FourLeftMagBias
DCD 0x00000000
AREA ||area_number.39||, DATA, ALIGN=2
EXPORTAS ||area_number.39||, ||.data||
FourRightMagBias
DCD 0x00000000
;*** Start embedded assembler ***
#line 1 "..\\..\\User\\bsp\\BSP\\bsp_can.c"
AREA ||.rev16_text||, CODE
THUMB
EXPORT |__asm___9_bsp_can_c_c272ff7f____REV16|
#line 129 "..\\..\\Libraries\\CMSIS\\Include\\core_cmInstr.h"
|__asm___9_bsp_can_c_c272ff7f____REV16| PROC
#line 130
rev16 r0, r0
bx lr
ENDP
AREA ||.revsh_text||, CODE
THUMB
EXPORT |__asm___9_bsp_can_c_c272ff7f____REVSH|
#line 144
|__asm___9_bsp_can_c_c272ff7f____REVSH| PROC
#line 145
revsh r0, r0
bx lr
ENDP
AREA ||.rrx_text||, CODE
THUMB
EXPORT |__asm___9_bsp_can_c_c272ff7f____RRX|
#line 300
|__asm___9_bsp_can_c_c272ff7f____RRX| PROC
#line 301
rrx r0, r0
bx lr
ENDP
;*** End embedded assembler ***