bsp_flash.txt
13.9 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
; 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_flash.o --asm_dir=.\Flash\List\ --list_dir=.\Flash\List\ --depend=.\flash\obj\bsp_flash.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_flash.crf ..\..\User\bsp\BSP\bsp_flash.c]
THUMB
AREA ||i.GetSector||, CODE, READONLY, ALIGN=2
GetSector PROC
;;;43 */
;;;44 uint32_t GetSector(uint32_t Address)
000000 4601 MOV r1,r0
;;;45 {
;;;46 uint32_t sector = 0;
000002 2000 MOVS r0,#0
;;;47
;;;48 if((Address < ADDR_FLASH_SECTOR_1) && (Address >= ADDR_FLASH_SECTOR_0))
000004 f1a16200 SUB r2,r1,#0x8000000
000008 f44f4380 MOV r3,#0x4000
00000c 429a CMP r2,r3
00000e d304 BCC |L1.26|
;;;49 {
;;;50 sector = FLASH_Sector_0;
;;;51 }
;;;52 else if((Address < ADDR_FLASH_SECTOR_2) && (Address >= ADDR_FLASH_SECTOR_1))
000010 4820 LDR r0,|L1.148|
000012 4408 ADD r0,r0,r1
000014 4298 CMP r0,r3
000016 d201 BCS |L1.28|
;;;53 {
;;;54 sector = FLASH_Sector_1;
000018 2008 MOVS r0,#8
|L1.26|
;;;55 }
;;;56 else if((Address < ADDR_FLASH_SECTOR_3) && (Address >= ADDR_FLASH_SECTOR_2))
;;;57 {
;;;58 sector = FLASH_Sector_2;
;;;59 }
;;;60 else if((Address < ADDR_FLASH_SECTOR_4) && (Address >= ADDR_FLASH_SECTOR_3))
;;;61 {
;;;62 sector = FLASH_Sector_3;
;;;63 }
;;;64 else if((Address < ADDR_FLASH_SECTOR_5) && (Address >= ADDR_FLASH_SECTOR_4))
;;;65 {
;;;66 sector = FLASH_Sector_4;
;;;67 }
;;;68 else if((Address < ADDR_FLASH_SECTOR_6) && (Address >= ADDR_FLASH_SECTOR_5))
;;;69 {
;;;70 sector = FLASH_Sector_5;
;;;71 }
;;;72 else if((Address < ADDR_FLASH_SECTOR_7) && (Address >= ADDR_FLASH_SECTOR_6))
;;;73 {
;;;74 sector = FLASH_Sector_6;
;;;75 }
;;;76 else if((Address < ADDR_FLASH_SECTOR_8) && (Address >= ADDR_FLASH_SECTOR_7))
;;;77 {
;;;78 sector = FLASH_Sector_7;
;;;79 }
;;;80 else if((Address < ADDR_FLASH_SECTOR_9) && (Address >= ADDR_FLASH_SECTOR_8))
;;;81 {
;;;82 sector = FLASH_Sector_8;
;;;83 }
;;;84 else if((Address < ADDR_FLASH_SECTOR_10) && (Address >= ADDR_FLASH_SECTOR_9))
;;;85 {
;;;86 sector = FLASH_Sector_9;
;;;87 }
;;;88 else if((Address < ADDR_FLASH_SECTOR_11) && (Address >= ADDR_FLASH_SECTOR_10))
;;;89 {
;;;90 sector = FLASH_Sector_10;
;;;91 }
;;;92 else/*(Address < FLASH_END_ADDR) && (Address >= ADDR_FLASH_SECTOR_11))*/
;;;93 {
;;;94 sector = FLASH_Sector_11;
;;;95 }
;;;96
;;;97 return sector;
;;;98 }
00001a 4770 BX lr
|L1.28|
00001c 481e LDR r0,|L1.152|
00001e 4408 ADD r0,r0,r1 ;56
000020 4298 CMP r0,r3 ;56
000022 d201 BCS |L1.40|
000024 2010 MOVS r0,#0x10 ;58
000026 4770 BX lr
|L1.40|
000028 481c LDR r0,|L1.156|
00002a 4408 ADD r0,r0,r1 ;60
00002c 4298 CMP r0,r3 ;60
00002e d201 BCS |L1.52|
000030 2018 MOVS r0,#0x18 ;62
000032 4770 BX lr
|L1.52|
000034 481a LDR r0,|L1.160|
000036 4408 ADD r0,r0,r1 ;64
000038 f5b03f80 CMP r0,#0x10000 ;64
00003c d201 BCS |L1.66|
00003e 2020 MOVS r0,#0x20 ;66
000040 4770 BX lr
|L1.66|
000042 4818 LDR r0,|L1.164|
000044 f44f3200 MOV r2,#0x20000 ;68
000048 4408 ADD r0,r0,r1 ;68
00004a 4290 CMP r0,r2 ;68
00004c d201 BCS |L1.82|
00004e 2028 MOVS r0,#0x28 ;70
000050 4770 BX lr
|L1.82|
000052 4815 LDR r0,|L1.168|
000054 4408 ADD r0,r0,r1 ;72
000056 4290 CMP r0,r2 ;72
000058 d201 BCS |L1.94|
00005a 2030 MOVS r0,#0x30 ;74
00005c 4770 BX lr
|L1.94|
00005e 4813 LDR r0,|L1.172|
000060 4408 ADD r0,r0,r1 ;76
000062 4290 CMP r0,r2 ;76
000064 d201 BCS |L1.106|
000066 2038 MOVS r0,#0x38 ;78
000068 4770 BX lr
|L1.106|
00006a 4811 LDR r0,|L1.176|
00006c 4408 ADD r0,r0,r1 ;80
00006e 4290 CMP r0,r2 ;80
000070 d201 BCS |L1.118|
000072 2040 MOVS r0,#0x40 ;82
000074 4770 BX lr
|L1.118|
000076 480f LDR r0,|L1.180|
000078 4408 ADD r0,r0,r1 ;84
00007a 4290 CMP r0,r2 ;84
00007c d201 BCS |L1.130|
00007e 2048 MOVS r0,#0x48 ;86
000080 4770 BX lr
|L1.130|
000082 480d LDR r0,|L1.184|
000084 4408 ADD r0,r0,r1 ;88
000086 4290 CMP r0,r2 ;88
000088 d201 BCS |L1.142|
00008a 2050 MOVS r0,#0x50 ;90
00008c 4770 BX lr
|L1.142|
00008e 2058 MOVS r0,#0x58 ;94
000090 4770 BX lr
;;;99
ENDP
000092 0000 DCW 0x0000
|L1.148|
DCD 0xf7ffc000
|L1.152|
DCD 0xf7ff8000
|L1.156|
DCD 0xf7ff4000
|L1.160|
DCD 0xf7ff0000
|L1.164|
DCD 0xf7fe0000
|L1.168|
DCD 0xf7fc0000
|L1.172|
DCD 0xf7fa0000
|L1.176|
DCD 0xf7f80000
|L1.180|
DCD 0xf7f60000
|L1.184|
DCD 0xf7f40000
AREA ||i.ReadFlashNBtye||, CODE, READONLY, ALIGN=2
ReadFlashNBtye PROC
;;;154 //////////////////////////////////////////////////////////////////////////////////
;;;155 int ReadFlashNBtye(uint32_t ReadAddress, uint8_t *ReadBuf, int32_t ReadNum)
000000 b510 PUSH {r4,lr}
;;;156 {
000002 4603 MOV r3,r0
;;;157 int DataNum = 0;
000004 2000 MOVS r0,#0
;;;158
;;;159 ReadAddress = (uint32_t)STARTADDR + ReadAddress;
000006 4c05 LDR r4,|L2.28|
000008 4423 ADD r3,r3,r4
00000a e003 B |L2.20|
|L2.12|
;;;160 while(DataNum < ReadNum)
;;;161 {
;;;162 *(ReadBuf + DataNum) = *(__IO uint16_t*) ReadAddress++;
00000c f8334b02 LDRH r4,[r3],#2
000010 540c STRB r4,[r1,r0]
;;;163 DataNum++;
000012 1c40 ADDS r0,r0,#1
|L2.20|
000014 4290 CMP r0,r2 ;160
000016 dbf9 BLT |L2.12|
;;;164 ReadAddress++;
;;;165 }
;;;166
;;;167 return DataNum;
;;;168 }
000018 bd10 POP {r4,pc}
;;;169
ENDP
00001a 0000 DCW 0x0000
|L2.28|
DCD 0x0807f800
AREA ||i.WriteFlashData||, CODE, READONLY, ALIGN=2
WriteFlashData PROC
;;;108 //////////////////////////////////////////////////////////////////////////////////
;;;109 void WriteFlashData(uint32_t WriteAddress, uint8_t data[], uint32_t num)
000000 e92d47f0 PUSH {r4-r10,lr}
;;;110 {
000004 4605 MOV r5,r0
000006 460e MOV r6,r1
000008 4617 MOV r7,r2
;;;111 uint32_t i = 0;
00000a 2400 MOVS r4,#0
;;;112 uint16_t temp = 0;
;;;113
;;;114 uint32_t StartSector = 0;
;;;115 // FLASH_UnlockBank1(); //解锁flash
;;;116 FLASH_Unlock();
00000c f7fffffe BL FLASH_Unlock
;;;117
;;;118 // FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR);
;;;119 // FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR);
;;;120 FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR |
000010 20f3 MOVS r0,#0xf3
000012 f7fffffe BL FLASH_ClearFlag
;;;121 FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR|FLASH_FLAG_PGSERR);
;;;122
;;;123
;;;124
;;;125 // FLASHStatus = FLASH_BUSY; //清空状态指示标志位
;;;126 // FLASHStatus = FLASH_ErasePage(STARTADDR);//擦除整页
;;;127 StartSector = GetSector(STARTADDR);
000016 f8df9044 LDR r9,|L3.92|
00001a 4648 MOV r0,r9
00001c f7fffffe BL GetSector
;;;128 if (FLASH_EraseSector(StartSector, VoltageRange_3) == FLASH_COMPLETE)
000020 2102 MOVS r1,#2
000022 f7fffffe BL FLASH_EraseSector
;;;129 // if(FLASHStatus == FLASH_COMPLETE) //flash操作完成
;;;130 {
;;;131 FLASHStatus = FLASH_BUSY; //清空状态指示标志位
000026 f8df8038 LDR r8,|L3.96|
00002a f04f0a01 MOV r10,#1
00002e 2809 CMP r0,#9 ;128
000030 d10d BNE |L3.78|
000032 f888a000 STRB r10,[r8,#0]
;;;132 for(i=0; i<num; i++)
000036 e008 B |L3.74|
|L3.56|
;;;133 {
;;;134 temp = (uint16_t)data[i];
000038 5d31 LDRB r1,[r6,r4]
;;;135 FLASHStatus = FLASH_ProgramHalfWord(STARTADDR+WriteAddress+i*2, temp);//写入数据
00003a eb050044 ADD r0,r5,r4,LSL #1
00003e 4448 ADD r0,r0,r9
000040 f7fffffe BL FLASH_ProgramHalfWord
000044 f8880000 STRB r0,[r8,#0]
000048 1c64 ADDS r4,r4,#1 ;132
|L3.74|
00004a 42bc CMP r4,r7 ;132
00004c d3f4 BCC |L3.56|
|L3.78|
;;;136 }
;;;137 }
;;;138 FLASHStatus = FLASH_BUSY; //清空状态指示标志位
00004e f888a000 STRB r10,[r8,#0]
;;;139
;;;140 // FLASH_LockBank1(); //锁定flash
;;;141 FLASH_Lock();
000052 e8bd47f0 POP {r4-r10,lr}
000056 f7ffbffe B.W FLASH_Lock
;;;142 }
;;;143
ENDP
00005a 0000 DCW 0x0000
|L3.92|
DCD 0x0807f800
|L3.96|
DCD ||.data||
AREA ||.data||, DATA, ALIGN=0
FLASHStatus
000000 01 DCB 0x01
;*** Start embedded assembler ***
#line 1 "..\\..\\User\\bsp\\BSP\\bsp_flash.c"
AREA ||.rev16_text||, CODE
THUMB
EXPORT |__asm___11_bsp_flash_c_79369c98____REV16|
#line 129 "..\\..\\Libraries\\CMSIS\\Include\\core_cmInstr.h"
|__asm___11_bsp_flash_c_79369c98____REV16| PROC
#line 130
rev16 r0, r0
bx lr
ENDP
AREA ||.revsh_text||, CODE
THUMB
EXPORT |__asm___11_bsp_flash_c_79369c98____REVSH|
#line 144
|__asm___11_bsp_flash_c_79369c98____REVSH| PROC
#line 145
revsh r0, r0
bx lr
ENDP
AREA ||.rrx_text||, CODE
THUMB
EXPORT |__asm___11_bsp_flash_c_79369c98____RRX|
#line 300
|__asm___11_bsp_flash_c_79369c98____RRX| PROC
#line 301
rrx r0, r0
bx lr
ENDP
;*** End embedded assembler ***