bsp.txt
13.1 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
; 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.o --asm_dir=.\Flash\List\ --list_dir=.\Flash\List\ --depend=.\flash\obj\bsp.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.crf ..\..\User\bsp\bsp.c]
THUMB
AREA ||i.BSP_CPU_ClkFreq||, CODE, READONLY, ALIGN=1
BSP_CPU_ClkFreq PROC
;;;167 */
;;;168 CPU_INT32U BSP_CPU_ClkFreq (void)
000000 b51f PUSH {r0-r4,lr}
;;;169 {
;;;170 RCC_ClocksTypeDef rcc_clocks;
;;;171
;;;172 RCC_GetClocksFreq(&rcc_clocks);
000002 4668 MOV r0,sp
000004 f7fffffe BL RCC_GetClocksFreq
;;;173 return ((CPU_INT32U)rcc_clocks.HCLK_Frequency);
000008 9801 LDR r0,[sp,#4]
;;;174 }
00000a b004 ADD sp,sp,#0x10
00000c bd10 POP {r4,pc}
;;;175
ENDP
AREA ||i.BSP_Tick_Init||, CODE, READONLY, ALIGN=2
BSP_Tick_Init PROC
;;;183 */
;;;184 void BSP_Tick_Init (void)
000000 b510 PUSH {r4,lr}
;;;185 {
;;;186 CPU_INT32U cpu_clk_freq;
;;;187 CPU_INT32U cnts;
;;;188
;;;189 cpu_clk_freq = BSP_CPU_ClkFreq(); /* 获取系统时钟 */
000002 f7fffffe BL BSP_CPU_ClkFreq
;;;190
;;;191 #if (OS_VERSION >= 30000u)
;;;192 cnts = cpu_clk_freq / (CPU_INT32U)OSCfg_TickRate_Hz;
000006 4909 LDR r1,|L2.44|
000008 6809 LDR r1,[r1,#0] ; OSCfg_TickRate_Hz
00000a fbb0f0f1 UDIV r0,r0,r1
00000e 1e40 SUBS r0,r0,#1
000010 f1b07f80 CMP r0,#0x1000000
000014 d209 BCS |L2.42|
000016 f04f21e0 MOV r1,#0xe000e000
00001a 6148 STR r0,[r1,#0x14]
00001c 4a04 LDR r2,|L2.48|
00001e 20f0 MOVS r0,#0xf0
000020 7010 STRB r0,[r2,#0]
000022 2000 MOVS r0,#0
000024 6188 STR r0,[r1,#0x18]
000026 2007 MOVS r0,#7
000028 6108 STR r0,[r1,#0x10]
|L2.42|
;;;193 #else
;;;194 cnts = cpu_clk_freq / (CPU_INT32U)OS_TICKS_PER_SEC; /* 获得滴答定时器的参数 */
;;;195 #endif
;;;196 SysTick_Config(cnts); /* 这里默认的是最低优先级 */
;;;197 }
00002a bd10 POP {r4,pc}
;;;198
ENDP
|L2.44|
DCD OSCfg_TickRate_Hz
|L2.48|
DCD 0xe000ed23
AREA ||i.Get_ChipID||, CODE, READONLY, ALIGN=2
Get_ChipID PROC
;;;22 /*应用端程序校验bootloader*/
;;;23 void Get_ChipID(void)
000000 b57f PUSH {r0-r6,lr}
;;;24 {
;;;25 u32 Sum = 0;
000002 2100 MOVS r1,#0
;;;26 u32 idsum = 0;
;;;27 u8 *pFlash;
;;;28 uint32_t id[3];
;;;29
;;;30 pFlash = (u8*)ADDR_FLASH_SECTOR_0;/*指向bootloader区域*/
000004 f04f6200 MOV r2,#0x8000000
;;;31 for(u32 i = 0; i < 0x4000; i++)
000008 2000 MOVS r0,#0
00000a 1354 ASRS r4,r2,#13
|L3.12|
;;;32 {
;;;33 Sum += pFlash[i];/*以BYTE型将第一个扇区数据全部加起来*/
00000c 5c13 LDRB r3,[r2,r0]
00000e 4419 ADD r1,r1,r3
000010 1c40 ADDS r0,r0,#1 ;31
000012 42a0 CMP r0,r4 ;31
000014 d3fa BCC |L3.12|
;;;34 }
;;;35 /*获取到ID号*/
;;;36 id[0] = *(__I uint32_t *)(0x1FFF7A10 + 0x00);
000016 4a14 LDR r2,|L3.104|
000018 6810 LDR r0,[r2,#0]
00001a 9001 STR r0,[sp,#4]
;;;37 id[1] = *(__I uint32_t *)(0x1FFF7A10 + 0x04);
00001c 1d13 ADDS r3,r2,#4
00001e 6818 LDR r0,[r3,#0]
000020 9002 STR r0,[sp,#8]
;;;38 id[2] = *(__I uint32_t *)(0x1FFF7A10 + 0x08);
000022 1d1c ADDS r4,r3,#4
000024 6820 LDR r0,[r4,#0]
000026 9003 STR r0,[sp,#0xc]
;;;39 /*将ID号加起来*/
;;;40 id[0] = id[0] + id[1] + id[2];
000028 e9dd0501 LDRD r0,r5,[sp,#4]
00002c 4428 ADD r0,r0,r5
00002e 9d03 LDR r5,[sp,#0xc]
000030 4428 ADD r0,r0,r5
000032 9001 STR r0,[sp,#4]
;;;41
;;;42 /*再将ID号按BYTE加起来*/
;;;43 idsum = ((id[0] & 0xff000000) >> 24) + ((id[0] & 0x00ff0000) >> 16) + ((id[0] & 0x0000ff00) >> 8) + ((id[0] & 0x000000ff) >> 0);
000034 9801 LDR r0,[sp,#4]
000036 9d01 LDR r5,[sp,#4]
000038 f3c04007 UBFX r0,r0,#16,#8
00003c eb006015 ADD r0,r0,r5,LSR #24
000040 f3c52507 UBFX r5,r5,#8,#8
000044 4428 ADD r0,r0,r5
000046 9d01 LDR r5,[sp,#4]
000048 b2ed UXTB r5,r5
00004a 4428 ADD r0,r0,r5
;;;44
;;;45 /*扇区校验和减去ID号按BYTE加起来的数据如果不是一个固定值证明BOOTLOADER被改了*/
;;;46 // if(Sum - idsum != 2482572)
;;;47 // Uart_Printf(COM1,"DATA=%d\r\n",Sum - idsum);
;;;48 if(Sum - idsum != 2486081)
00004c 1a08 SUBS r0,r1,r0
00004e 4907 LDR r1,|L3.108|
000050 4288 CMP r0,r1
000052 d008 BEQ |L3.102|
;;;49 {
;;;50 Uart_Printf(COM1, "ID未注册 %08X %08X %08X\r\n",*(__I uint32_t *)(0x1FFF7A10 + 0x00),*(__I uint32_t *)(0x1FFF7A10 + 0x04),*(__I uint32_t *)(0x1FFF7A10 + 0x08));//串口打印ID号
000054 6820 LDR r0,[r4,#0]
000056 9000 STR r0,[sp,#0]
000058 681b LDR r3,[r3,#0]
00005a 6812 LDR r2,[r2,#0]
00005c a104 ADR r1,|L3.112|
00005e 2001 MOVS r0,#1
000060 f7fffffe BL Uart_Printf
|L3.100|
;;;51 while(1)
000064 e7fe B |L3.100|
|L3.102|
;;;52 {
;;;53
;;;54 }
;;;55 }
;;;56 }
000066 bd7f POP {r0-r6,pc}
;;;57
ENDP
|L3.104|
DCD 0x1fff7a10
|L3.108|
DCD 0x0025ef41
|L3.112|
000070 4944ceb4 DCB "ID",206,180,215,162,178,225," %08X %08X %08X\r\n",0
000074 d7a2b2e1
000078 20253038
00007c 58202530
000080 38582025
000084 3038580d
000088 0a00
00008a 00 DCB 0
00008b 00 DCB 0
AREA ||i.bsp_DelayMS||, CODE, READONLY, ALIGN=1
bsp_DelayMS PROC
;;;102 */
;;;103 void bsp_DelayMS(uint32_t _ulDelayTime)
000000 f44f717a MOV r1,#0x3e8
;;;104 {
;;;105 bsp_DelayUS(1000*_ulDelayTime);
000004 4348 MULS r0,r1,r0
000006 f7ffbffe B.W bsp_DelayUS
;;;106 }
;;;107
ENDP
AREA ||i.bsp_DelayUS||, CODE, READONLY, ALIGN=2
bsp_DelayUS PROC
;;;144 */
;;;145 void bsp_DelayUS(uint32_t _ulDelayTime)
000000 b570 PUSH {r4-r6,lr}
;;;146 {
000002 4606 MOV r6,r0
;;;147 uint32_t tCnt, tDelayCnt;
;;;148 uint32_t tStart;
;;;149
;;;150 tStart = (uint32_t)CPU_TS_TmrRd(); /* 刚进入时的计数器值 */
000004 f7fffffe BL CPU_TS_TmrRd
000008 4605 MOV r5,r0
;;;151 tCnt = 0;
00000a 2000 MOVS r0,#0
;;;152 tDelayCnt = _ulDelayTime * (SystemCoreClock / 1000000); /* 需要的节拍数 */
00000c 4906 LDR r1,|L5.40|
00000e 4a07 LDR r2,|L5.44|
000010 6809 LDR r1,[r1,#0] ; SystemCoreClock
000012 fbb1f4f2 UDIV r4,r1,r2
000016 4374 MULS r4,r6,r4
;;;153
;;;154 while(tCnt < tDelayCnt)
000018 e002 B |L5.32|
|L5.26|
;;;155 {
;;;156 tCnt = (uint32_t)CPU_TS_TmrRd() - tStart; /* 求减过程中,如果发生第一次32位计数器重新计数,依然可以正确计算 */
00001a f7fffffe BL CPU_TS_TmrRd
00001e 1b40 SUBS r0,r0,r5
|L5.32|
000020 42a0 CMP r0,r4 ;154
000022 d3fa BCC |L5.26|
;;;157 }
;;;158 }
000024 bd70 POP {r4-r6,pc}
;;;159
ENDP
000026 0000 DCW 0x0000
|L5.40|
DCD SystemCoreClock
|L5.44|
DCD 0x000f4240
AREA ||i.bsp_Init||, CODE, READONLY, ALIGN=2
bsp_Init PROC
;;;70 int InitFlag = 0;
;;;71 void bsp_Init(void)
000000 b538 PUSH {r3-r5,lr}
;;;72 {
;;;73 InitFlag = 1;
000002 4915 LDR r1,|L6.88|
000004 2001 MOVS r0,#1
000006 6008 STR r0,[r1,#0] ; InitFlag
;;;74 //系统数据初始化
;;;75 NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
000008 f44f7040 MOV r0,#0x300
00000c f7fffffe BL NVIC_PriorityGroupConfig
;;;76 bsp_InitUart();
000010 f7fffffe BL bsp_InitUart
;;;77
;;;78 vBkpSramInit();
000014 f7fffffe BL vBkpSramInit
;;;79 EXTIX_Init();
000018 f7fffffe BL EXTIX_Init
;;;80
;;;81 CAN1_Init(12);
00001c 200c MOVS r0,#0xc
00001e f7fffffe BL CAN1_Init
;;;82
;;;83 CAN2_Init(12);
000022 200c MOVS r0,#0xc
000024 f7fffffe BL CAN2_Init
;;;84
;;;85
;;;86 TIM3_Int_Init(65535,42000-1);//除以2000.0f得到时间单位为秒
000028 f24a440f MOV r4,#0xa40f
00002c f64f75ff MOV r5,#0xffff
000030 4621 MOV r1,r4
000032 4628 MOV r0,r5
000034 f7fffffe BL TIM3_Int_Init
;;;87 TIM7_Int_Init(65535,42000-1);
000038 4621 MOV r1,r4
00003a 4628 MOV r0,r5
00003c f7fffffe BL TIM7_Int_Init
;;;88
;;;89 eMBInit(MB_RTU, 0x01, 1, 115200, MB_PAR_NONE);
000040 2000 MOVS r0,#0
000042 2201 MOVS r2,#1
000044 f44f33e1 MOV r3,#0x1c200
000048 4611 MOV r1,r2
00004a 9000 STR r0,[sp,#0]
00004c f7fffffe BL eMBInit
;;;90 eMBEnable();
000050 e8bd4038 POP {r3-r5,lr}
000054 f7ffbffe B.W eMBEnable
;;;91
;;;92 }
;;;93
ENDP
|L6.88|
DCD ||.data||
AREA ||.data||, DATA, ALIGN=2
InitFlag
DCD 0x00000000
;*** Start embedded assembler ***
#line 1 "..\\..\\User\\bsp\\bsp.c"
AREA ||.rev16_text||, CODE
THUMB
EXPORT |__asm___5_bsp_c_16c45322____REV16|
#line 129 "..\\..\\Libraries\\CMSIS\\Include\\core_cmInstr.h"
|__asm___5_bsp_c_16c45322____REV16| PROC
#line 130
rev16 r0, r0
bx lr
ENDP
AREA ||.revsh_text||, CODE
THUMB
EXPORT |__asm___5_bsp_c_16c45322____REVSH|
#line 144
|__asm___5_bsp_c_16c45322____REVSH| PROC
#line 145
revsh r0, r0
bx lr
ENDP
AREA ||.rrx_text||, CODE
THUMB
EXPORT |__asm___5_bsp_c_16c45322____RRX|
#line 300
|__asm___5_bsp_c_16c45322____RRX| PROC
#line 301
rrx r0, r0
bx lr
ENDP
;*** End embedded assembler ***