优化了flash初始化

This commit is contained in:
小马_666 2024-09-04 13:03:51 +08:00
parent fb914e8ed7
commit 9913303669
13 changed files with 5000 additions and 5013 deletions

Binary file not shown.

View File

@ -39,7 +39,7 @@ compiling ulog.c...
compiling bsp_flash.c...
compiling ipc.c...
linking...
Program Size: Code=29366 RO-data=5834 RW-data=128 ZI-data=9192
Program Size: Code=28974 RO-data=5834 RW-data=128 ZI-data=9192
FromELF: creating hex file...
After Build - User command #1: "D:\SXDT\Official_information\HDDZ\demo\CIU32_L051_PROJECT\USART1_Interrupt - RT-Thread\keil5_disp_size_bar\keil5_disp_size_bar.exe"
ram:
@ -47,7 +47,7 @@ ram:
16.00 KB :|¡ö¡ö¡ö¡ö¡ö¡ö¡ö¡ö¡ö¡ö¡ö_________| 56.88 % ( 9.10 KB / 16.00 KB) [7064 B]
flash:
ER_IROM1 :0x8000000
64.00 KB :|¡ö¡ö¡ö¡ö¡ö¡ö¡ö¡ö¡ö¡ö__________| 53.71 % ( 34.38 KB / 64.00 KB) [30336 B]
64.00 KB :|¡ö¡ö¡ö¡ö¡ö¡ö¡ö¡ö¡ö¡ö__________| 53.11 % ( 33.99 KB / 64.00 KB) [30728 B]
".\CIU32_L051_M307R.axf" - 0 Error(s), 1 Warning(s).
<h2>Software Packages used:</h2>
@ -61,7 +61,7 @@ Package Vendor: HED
C:/Users/16005/AppData/Local/Arm/Packs/HED/CIU32L0xx_DFP/1.2.5/Drivers/CMSIS/Device/CIU32L051/Include
<h2>Collection of Component Files used:</h2>
Build Time Elapsed: 00:00:01
Build Time Elapsed: 00:00:02
</pre>
</body>
</html>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -142,7 +142,7 @@ I (..\LIB\RTT\SEGGER_RTT.he.\LIB\RTT\SEGGER_RTT_Conf.h)(0x00000000)
I (C:\Keil_v5\ARM\ARMCLANG\include\stdlib.h)(0x6569B012)
I (..\RTOS\components\utilities\ulog\ulog.h)(0x666E44C6)
I (..\RTOS\components\utilities\ulog\ulog_def.h)(0x666E44C6)
F (..\bsp\src\bsp_flash.c)(0x66D7E1CF)(-xc -std=c99 --target=arm-arm-none-eabi -mcpu=cortex-m0plus -c -fno-rtti -funsigned-char -fshort-enums -fshort-wchar -D__MICROLIB -gdwarf-4 -Oz -ffunction-sections -Wno-packed -Wno-missing-variable-declarations -Wno-missing-prototypes -Wno-missing-noreturn -Wno-sign-conversion -Wno-nonportable-include-path -Wno-reserved-id-macro -Wno-unused-macros -Wno-documentation-unknown-command -Wno-documentation -Wno-license-management -Wno-parentheses-equality -Wno-reserved-identifier -I ../RTOS/inc -I ../RTOS/components/finsh -I ../drivers/inc -I ../Peripheral/CIU32L051_Lib/Include -I ../Peripheral/CMSIS/Core -I ../Peripheral/CMSIS/Device -I ../startup -I ../user/Include -I ../RTOS -I ../RTOS/components/utilities/ulog -I ../RTOS/components/utilities/ulog/backend -I ../RTOS/components/drivers/inc -I ../LIB/lwrb -I ../LIB/RTT -I ../bsp/inc -I ../LIB/LwUtil -I ../LIB/perf_counter -D__UVISION_VERSION="539" -DCIU32L051 -DCIU32L051 -o ./bsp_flash.o -MD)
F (..\bsp\src\bsp_flash.c)(0x66D7E8D7)(-xc -std=c99 --target=arm-arm-none-eabi -mcpu=cortex-m0plus -c -fno-rtti -funsigned-char -fshort-enums -fshort-wchar -D__MICROLIB -gdwarf-4 -Oz -ffunction-sections -Wno-packed -Wno-missing-variable-declarations -Wno-missing-prototypes -Wno-missing-noreturn -Wno-sign-conversion -Wno-nonportable-include-path -Wno-reserved-id-macro -Wno-unused-macros -Wno-documentation-unknown-command -Wno-documentation -Wno-license-management -Wno-parentheses-equality -Wno-reserved-identifier -I ../RTOS/inc -I ../RTOS/components/finsh -I ../drivers/inc -I ../Peripheral/CIU32L051_Lib/Include -I ../Peripheral/CMSIS/Core -I ../Peripheral/CMSIS/Device -I ../startup -I ../user/Include -I ../RTOS -I ../RTOS/components/utilities/ulog -I ../RTOS/components/utilities/ulog/backend -I ../RTOS/components/drivers/inc -I ../LIB/lwrb -I ../LIB/RTT -I ../bsp/inc -I ../LIB/LwUtil -I ../LIB/perf_counter -D__UVISION_VERSION="539" -DCIU32L051 -DCIU32L051 -o ./bsp_flash.o -MD)
I (..\RTOS\inc\rtthread.hl.\RTOS\rtconfig.h)(0x00000000)
I (..\RTOS\components\finsh\finsh_config.hh.\RTOS\inc\rtdebug.h)(0x00000000)
I (..\RTOS\inc\rtdef.hf.\RTOS\inc\stdarg.hh.\RTOS\inc\rtservice.h)(0x00000000)

View File

@ -6,7 +6,7 @@
[Found keyword]: ----------Execution Region----------
[name]: ER_IROM1
[Exec base]: 0x8000000
[Size]: 0x8980
[Size]: 0x87f8
[Max]: 0x10000
[Found keyword]: ----------Execution Region----------
[name]: RW_IRAM1
@ -17,7 +17,7 @@
RW_IRAM1 :0x20000000
16.00 KB :|¡ö¡ö¡ö¡ö¡ö¡ö¡ö¡ö¡ö¡ö¡ö_________| 56.88 % ( 9.10 KB / 16.00 KB) [7064 B]
ER_IROM1 :0x8000000
64.00 KB :|ĄöĄöĄöĄöĄöĄöĄöĄöĄöĄö__________| 53.71 % ( 34.38 KB / 64.00 KB) [30336 B]
64.00 KB :|ĄöĄöĄöĄöĄöĄöĄöĄöĄöĄö__________| 53.11 % ( 33.99 KB / 64.00 KB) [30728 B]
[export csv]: ./USART1_Interrupt_sort_by_flash.csv
[export csv]: ./USART1_Interrupt_sort_by_ram.csv
[export xlsx]: USART1_Interrupt_analysis.xlsx

Binary file not shown.

View File

@ -1,65 +1,65 @@
File_name,flash percent,flash,ram,Code,RO_data,RW_data,ZI_data
bsp_flash.o,13.508520%,4899,4,3420,1479,0,4
cmd.o,9.896321%,3589,0,2592,997,0,0
ipc.o,6.722550%,2438,0,1424,1014,0,0
ulog.o,5.936690%,2153,589,1950,203,0,589
thread.o,5.911873%,2144,12,1902,242,0,12
kservice.o,5.498263%,1994,260,1738,256,0,260
mem.o,5.183919%,1880,72,1512,368,0,72
drv_uart.o,4.927480%,1787,3180,1708,79,0,3180
bsp_history.o,4.171952%,1513,1684,1404,109,0,1684
shell.o,3.978933%,1443,281,1412,31,0,281
timer.o,3.190316%,1157,20,1002,155,0,20
mc_p.l,2.815309%,1021,4,884,133,4,0
segger_rtt_printf.o,2.751889%,998,0,998,0,0,0
msh.o,2.605747%,945,0,784,161,0,0
object.o,2.556113%,927,132,708,107,112,20
bsp_rtc.o,1.927425%,699,6,600,99,0,6
segger_rtt.o,1.753709%,636,1208,610,26,0,1208
lwrb.o,1.494513%,542,0,542,0,0,0
scheduler.o,1.384217%,502,280,484,18,0,280
ciu32l051_std_lpuart.o,0.915458%,332,0,332,0,0,0
perf_counter.o,0.854795%,310,56,298,4,8,48
cpuport.o,0.849280%,308,12,308,0,0,12
idle.o,0.744499%,270,416,248,22,0,416
components.o,0.672807%,244,0,228,16,0,0
ciu32l051_std_rtc.o,0.650747%,236,0,236,0,0,0
startup_ciu32l051.o,0.606629%,220,1024,28,192,0,1024
context_rvds.o,0.595599%,216,0,216,0,0,0
ciu32l051_std_rcc.o,0.595599%,216,0,216,0,0,0
drv_common.o,0.562510%,204,0,204,0,0,0
system_ciu32l051.o,0.551481%,200,4,164,32,4,0
ciu32l051_std_flash.o,0.518392%,188,0,188,0,0,0
ciu32l051_std_usart.o,0.512877%,186,0,186,0,0,0
_strtoul.o,0.457729%,166,0,166,0,0,0
perf_os_patch_rt_thread.o,0.435670%,158,0,154,4,0,0
ciu32l051_std_gpio.o,0.424640%,154,0,154,0,0,0
ctype_o.o,0.388794%,141,0,8,133,0,0
board.o,0.358462%,130,0,130,0,0,0
strtol.o,0.308829%,112,0,112,0,0,0
ciu32l051_std_dma.o,0.275740%,100,0,100,0,0,0
uldiv.o,0.264711%,96,0,96,0,0,0
irq.o,0.242652%,88,12,88,0,0,12
main.o,0.237137%,86,0,40,46,0,0
uidiv_div0.o,0.170959%,62,0,62,0,0,0
console_be.o,0.148900%,54,48,50,4,0,48
clock.o,0.148900%,54,4,54,0,0,4
init.o,0.132355%,48,0,48,0,0,0
cpp_init.o,0.110296%,40,0,40,0,0,0
memseta.o,0.099267%,36,0,36,0,0,0
memcpya.o,0.099267%,36,0,36,0,0,0
llushr.o,0.093752%,34,0,34,0,0,0
llshl.o,0.088237%,32,0,32,0,0,0
strncmp.o,0.082722%,30,0,30,0,0,0
handlers.o,0.082722%,30,0,30,0,0,0
_chval.o,0.082722%,30,0,30,0,0,0
strncpy.o,0.071692%,26,0,26,0,0,0
memcmp.o,0.071692%,26,0,26,0,0,0
atoi.o,0.071692%,26,0,26,0,0,0
ciu32l051_std.o,0.066178%,24,0,24,0,0,0
strlen.o,0.038604%,14,0,14,0,0,0
errno.o,0.033089%,12,4,8,0,4,0
entry9a.o,0.022059%,8,0,8,0,0,0
entry2.o,0.022059%,8,0,8,0,0,0
entry8a.o,0.011030%,4,0,4,0,0,0
entry5.o,0.011030%,4,0,4,0,0,0
bsp_flash.o,12.563416%,4507,4,3028,1479,0,4
cmd.o,10.004460%,3589,0,2592,997,0,0
ipc.o,6.796008%,2438,0,1424,1014,0,0
ulog.o,6.001561%,2153,589,1950,203,0,589
thread.o,5.976473%,2144,12,1902,242,0,12
kservice.o,5.558343%,1994,260,1738,256,0,260
mem.o,5.240564%,1880,72,1512,368,0,72
drv_uart.o,4.981324%,1787,3180,1708,79,0,3180
bsp_history.o,4.217539%,1513,1684,1404,109,0,1684
shell.o,4.022412%,1443,281,1412,31,0,281
timer.o,3.225177%,1157,20,1002,155,0,20
mc_p.l,2.846072%,1021,4,884,133,4,0
segger_rtt_printf.o,2.781959%,998,0,998,0,0,0
msh.o,2.634220%,945,0,784,161,0,0
object.o,2.584044%,927,132,708,107,112,20
bsp_rtc.o,1.948486%,699,6,600,99,0,6
segger_rtt.o,1.772872%,636,1208,610,26,0,1208
lwrb.o,1.510844%,542,0,542,0,0,0
scheduler.o,1.399342%,502,280,484,18,0,280
ciu32l051_std_lpuart.o,0.925461%,332,0,332,0,0,0
perf_counter.o,0.864136%,310,56,298,4,8,48
cpuport.o,0.858561%,308,12,308,0,0,12
idle.o,0.752634%,270,416,248,22,0,416
components.o,0.680158%,244,0,228,16,0,0
ciu32l051_std_rtc.o,0.657858%,236,0,236,0,0,0
startup_ciu32l051.o,0.613258%,220,1024,28,192,0,1024
context_rvds.o,0.602107%,216,0,216,0,0,0
ciu32l051_std_rcc.o,0.602107%,216,0,216,0,0,0
drv_common.o,0.568657%,204,0,204,0,0,0
system_ciu32l051.o,0.557507%,200,4,164,32,4,0
ciu32l051_std_flash.o,0.524056%,188,0,188,0,0,0
ciu32l051_std_usart.o,0.518481%,186,0,186,0,0,0
_strtoul.o,0.462731%,166,0,166,0,0,0
perf_os_patch_rt_thread.o,0.440430%,158,0,154,4,0,0
ciu32l051_std_gpio.o,0.429280%,154,0,154,0,0,0
ctype_o.o,0.393042%,141,0,8,133,0,0
board.o,0.362379%,130,0,130,0,0,0
strtol.o,0.312204%,112,0,112,0,0,0
ciu32l051_std_dma.o,0.278753%,100,0,100,0,0,0
uldiv.o,0.267603%,96,0,96,0,0,0
irq.o,0.245303%,88,12,88,0,0,12
main.o,0.239728%,86,0,40,46,0,0
uidiv_div0.o,0.172827%,62,0,62,0,0,0
console_be.o,0.150527%,54,48,50,4,0,48
clock.o,0.150527%,54,4,54,0,0,4
init.o,0.133802%,48,0,48,0,0,0
cpp_init.o,0.111501%,40,0,40,0,0,0
memseta.o,0.100351%,36,0,36,0,0,0
memcpya.o,0.100351%,36,0,36,0,0,0
llushr.o,0.094776%,34,0,34,0,0,0
llshl.o,0.089201%,32,0,32,0,0,0
strncmp.o,0.083626%,30,0,30,0,0,0
handlers.o,0.083626%,30,0,30,0,0,0
_chval.o,0.083626%,30,0,30,0,0,0
strncpy.o,0.072476%,26,0,26,0,0,0
memcmp.o,0.072476%,26,0,26,0,0,0
atoi.o,0.072476%,26,0,26,0,0,0
ciu32l051_std.o,0.066901%,24,0,24,0,0,0
strlen.o,0.039025%,14,0,14,0,0,0
errno.o,0.033450%,12,4,8,0,4,0
entry9a.o,0.022300%,8,0,8,0,0,0
entry2.o,0.022300%,8,0,8,0,0,0
entry8a.o,0.011150%,4,0,4,0,0,0
entry5.o,0.011150%,4,0,4,0,0,0

1 File_name flash percent flash ram Code RO_data RW_data ZI_data
2 bsp_flash.o 13.508520% 12.563416% 4899 4507 4 3420 3028 1479 0 4
3 cmd.o 9.896321% 10.004460% 3589 0 2592 997 0 0
4 ipc.o 6.722550% 6.796008% 2438 0 1424 1014 0 0
5 ulog.o 5.936690% 6.001561% 2153 589 1950 203 0 589
6 thread.o 5.911873% 5.976473% 2144 12 1902 242 0 12
7 kservice.o 5.498263% 5.558343% 1994 260 1738 256 0 260
8 mem.o 5.183919% 5.240564% 1880 72 1512 368 0 72
9 drv_uart.o 4.927480% 4.981324% 1787 3180 1708 79 0 3180
10 bsp_history.o 4.171952% 4.217539% 1513 1684 1404 109 0 1684
11 shell.o 3.978933% 4.022412% 1443 281 1412 31 0 281
12 timer.o 3.190316% 3.225177% 1157 20 1002 155 0 20
13 mc_p.l 2.815309% 2.846072% 1021 4 884 133 4 0
14 segger_rtt_printf.o 2.751889% 2.781959% 998 0 998 0 0 0
15 msh.o 2.605747% 2.634220% 945 0 784 161 0 0
16 object.o 2.556113% 2.584044% 927 132 708 107 112 20
17 bsp_rtc.o 1.927425% 1.948486% 699 6 600 99 0 6
18 segger_rtt.o 1.753709% 1.772872% 636 1208 610 26 0 1208
19 lwrb.o 1.494513% 1.510844% 542 0 542 0 0 0
20 scheduler.o 1.384217% 1.399342% 502 280 484 18 0 280
21 ciu32l051_std_lpuart.o 0.915458% 0.925461% 332 0 332 0 0 0
22 perf_counter.o 0.854795% 0.864136% 310 56 298 4 8 48
23 cpuport.o 0.849280% 0.858561% 308 12 308 0 0 12
24 idle.o 0.744499% 0.752634% 270 416 248 22 0 416
25 components.o 0.672807% 0.680158% 244 0 228 16 0 0
26 ciu32l051_std_rtc.o 0.650747% 0.657858% 236 0 236 0 0 0
27 startup_ciu32l051.o 0.606629% 0.613258% 220 1024 28 192 0 1024
28 context_rvds.o 0.595599% 0.602107% 216 0 216 0 0 0
29 ciu32l051_std_rcc.o 0.595599% 0.602107% 216 0 216 0 0 0
30 drv_common.o 0.562510% 0.568657% 204 0 204 0 0 0
31 system_ciu32l051.o 0.551481% 0.557507% 200 4 164 32 4 0
32 ciu32l051_std_flash.o 0.518392% 0.524056% 188 0 188 0 0 0
33 ciu32l051_std_usart.o 0.512877% 0.518481% 186 0 186 0 0 0
34 _strtoul.o 0.457729% 0.462731% 166 0 166 0 0 0
35 perf_os_patch_rt_thread.o 0.435670% 0.440430% 158 0 154 4 0 0
36 ciu32l051_std_gpio.o 0.424640% 0.429280% 154 0 154 0 0 0
37 ctype_o.o 0.388794% 0.393042% 141 0 8 133 0 0
38 board.o 0.358462% 0.362379% 130 0 130 0 0 0
39 strtol.o 0.308829% 0.312204% 112 0 112 0 0 0
40 ciu32l051_std_dma.o 0.275740% 0.278753% 100 0 100 0 0 0
41 uldiv.o 0.264711% 0.267603% 96 0 96 0 0 0
42 irq.o 0.242652% 0.245303% 88 12 88 0 0 12
43 main.o 0.237137% 0.239728% 86 0 40 46 0 0
44 uidiv_div0.o 0.170959% 0.172827% 62 0 62 0 0 0
45 console_be.o 0.148900% 0.150527% 54 48 50 4 0 48
46 clock.o 0.148900% 0.150527% 54 4 54 0 0 4
47 init.o 0.132355% 0.133802% 48 0 48 0 0 0
48 cpp_init.o 0.110296% 0.111501% 40 0 40 0 0 0
49 memseta.o 0.099267% 0.100351% 36 0 36 0 0 0
50 memcpya.o 0.099267% 0.100351% 36 0 36 0 0 0
51 llushr.o 0.093752% 0.094776% 34 0 34 0 0 0
52 llshl.o 0.088237% 0.089201% 32 0 32 0 0 0
53 strncmp.o 0.082722% 0.083626% 30 0 30 0 0 0
54 handlers.o 0.082722% 0.083626% 30 0 30 0 0 0
55 _chval.o 0.082722% 0.083626% 30 0 30 0 0 0
56 strncpy.o 0.071692% 0.072476% 26 0 26 0 0 0
57 memcmp.o 0.071692% 0.072476% 26 0 26 0 0 0
58 atoi.o 0.071692% 0.072476% 26 0 26 0 0 0
59 ciu32l051_std.o 0.066178% 0.066901% 24 0 24 0 0 0
60 strlen.o 0.038604% 0.039025% 14 0 14 0 0 0
61 errno.o 0.033089% 0.033450% 12 4 8 0 4 0
62 entry9a.o 0.022059% 0.022300% 8 0 8 0 0 0
63 entry2.o 0.022059% 0.022300% 8 0 8 0 0 0
64 entry8a.o 0.011030% 0.011150% 4 0 4 0 0 0
65 entry5.o 0.011030% 0.011150% 4 0 4 0 0 0

View File

@ -21,4 +21,4 @@ mc_p.l,0.042955%,4,1021,884,133,4,0
errno.o,0.042955%,4,12,8,0,4,0
system_ciu32l051.o,0.042955%,4,200,164,32,4,0
clock.o,0.042955%,4,54,54,0,0,4
bsp_flash.o,0.042955%,4,4899,3420,1479,0,4
bsp_flash.o,0.042955%,4,4507,3028,1479,0,4

1 File_name ram_percent ram flash Code RO_data RW_data ZI_data
21 errno.o 0.042955% 4 12 8 0 4 0
22 system_ciu32l051.o 0.042955% 4 200 164 32 4 0
23 clock.o 0.042955% 4 54 54 0 0 4
24 bsp_flash.o 0.042955% 4 4899 4507 3420 3028 1479 0 4

Binary file not shown.

View File

@ -2,7 +2,7 @@
* @Author: mbw
* @Date: 2024-08-22 16:15:08
* @LastEditors: mbw && 1600520629@qq.com
* @LastEditTime: 2024-09-04 11:52:14
* @LastEditTime: 2024-09-04 13:02:13
* @FilePath: \USART1_Interrupt - RT-Thread\bsp\src\bsp_flash.c
* @Description:
*
@ -114,14 +114,13 @@ static size_t Flash_ReadWord(uint32_t addr, uint32_t *buf, size_t len)
}
for (size_t i = 0; i < len; i++, read_len++)
{
buf[i] = ((uint32_t *)addr)[i];
buf[i] = ((uint32_t *)addr)[i]; //
if (buf[i] != ((uint32_t *)addr)[i])
{
RTT_LOG_E("Flash_Read Data Mismatch at addr %#X, expected %d got %d", addr, *(uint32_t *)buf, *(uint32_t *)addr);
return ERROR;
}
}
return read_len;
}
/**
@ -346,9 +345,9 @@ std_status_t Flash_ErasePage(uint32_t index)
{
std_flash_unlock();
RTT_LOG_D("ErasePage %d", index);
// Flash_Interrupt_Disable();
Flash_Interrupt_Disable();
std_status_t status = std_flash_erase(FLASH_ERASE_PAGE, index);
// Flash_Interrupt_Enable();
Flash_Interrupt_Enable();
std_flash_lock();
return status;
}
@ -369,7 +368,6 @@ ErrorStatus BSP_Flash_Program_InfoPage(uint32_t address, uint32_t *data_buf)
{
ErrorStatus ret = ERROR;
Flash_ErasePage_ConfigInfo();
for (uint32_t i = 0; i < FLASH_PAGE_RECORD_WORD_NUM; i++)
{
ret = Flash_WriteWord(address + i * 4, data_buf[i]);
@ -379,12 +377,9 @@ ErrorStatus BSP_Flash_Program_InfoPage(uint32_t address, uint32_t *data_buf)
return ERROR;
}
}
rt_thread_mdelay(2);
return ret;
}
/**
* @description:
* @param {uint8_t*} frame
@ -456,7 +451,6 @@ ErrorStatus BSP_Flash_EraseRecodrs(void)
return ERROR;
}
}
}
return SUCCESS;
@ -538,9 +532,10 @@ void Flash_SetProductTimeLimit(uint16_t year, uint8_t mon, uint8_t day, uint8_t
TuFlashHrRecordFrame ReadLimitTime;
uint32_t page_buf[FLASH_PAGE_RECORD_WORD_NUM] = {0}; // 暂存最后一页的值
Flash_ErasePage_ReadConfigInfo(page_buf);
// page_buf[kFlashInitFlag] = FLASH_FIRST_INIT_VALUE;
LimitTime.time.year = year - BASE_YEAR;
LimitTime.time.month = mon;
LimitTime.time.day = day;
@ -562,6 +557,21 @@ void Flash_SetProductTimeLimit(uint16_t year, uint8_t mon, uint8_t day, uint8_t
}
#endif
uint32_t ProductTimeLimit(uint16_t year, uint8_t mon, uint8_t day, uint8_t hour, uint8_t min)
{
TuFlashHrRecordFrame LimitTime;
LimitTime.time.year = year - BASE_YEAR;
LimitTime.time.month = mon;
LimitTime.time.day = day;
LimitTime.time.hour = hour;
LimitTime.time.minute = min;
LimitTime.time.check_sum = Sum_Check(LimitTime);
return (uint32_t)LimitTime.hr_data;
}
/**
* @description:
* @return {*}
@ -573,22 +583,31 @@ int BSP_Flash_Init(void)
{
uint32_t info_page_buf[FLASH_PAGE_RECORD_WORD_NUM] = {0};
BSP_Flash_EraseRecodrs(); // 擦除历史数据区
// TODO: 此处需要完善,比如写入初始化标志位,写入产品信息,写入出厂时间,写入到期时间
// info_page_buf[kFlashInitFlag] = FLASH_FIRST_INIT_VALUE;
// if (Flash_Write_ConfigInfo(info_page_buf) != STD_OK)
// {
// RTT_LOG_E("Flash_Write_ConfigInfo failed\r\n");
// return RT_ERROR;
// }
Flash_SetProductTimeLimit(2024, 1, 2, 3, 4, kFactoryTimeId);
Flash_SetProductTimeLimit(2024 + 10, 1, 2, 3, 4, kExpirationTimeId);
info_page_buf[kFlashInitFlag] = FLASH_FIRST_INIT_VALUE;
info_page_buf[kFlashFactoryTime] = ProductTimeLimit(2024, 1, 2, 3, 4);
info_page_buf[kFlashExpirationTime] = ProductTimeLimit(2024 + 10, 1, 2, 3, 4);
info_page_buf[kFlashLowAlarmValue] = 0x0A;
info_page_buf[kFlashHighAlarmValue] = 0x32;
// info_page_buf[kFlashSoftwareVersion] = XXX;
// info_page_buf[kFlashHardwareVersion] = XXX;
// info_page_buf[kFlashCompanyName] = XXX;
// info_page_buf[kFlashUpdateTime] = XXX;
BSP_Flash_EraseRecodrs(); // 擦除历史数据区
Flash_ErasePage_ConfigInfo(); // 擦除配置信息
if (Flash_Write_ConfigInfo(info_page_buf) != STD_OK)
{
RTT_LOG_E("Flash_Write_ConfigInfo failed\r\n");
return RT_ERROR;
}
}
return RT_EOK;
}
INIT_APP_EXPORT(BSP_Flash_Init);
INIT_ENV_EXPORT(BSP_Flash_Init);
#if 1
/**
@ -706,15 +725,15 @@ ErrorStatus Flash_Read_Record(TuFlashHrRecordFrame *pHrRecord, TeRecord record,
if (RecoderFrame.time.check_sum == sum_check)
{
pHrRecord->hr_data = RecoderFrame.hr_data;//赋值后读出,看对不对
pHrRecord->hr_data = RecoderFrame.hr_data; // 赋值后读出,看对不对
RTT_LOG_D("Flash_Read_(%d)Record(%d):%04d-%02d-%02d,%02d:%02d", record, index,
BASE_YEAR + pHrRecord->time.year, pHrRecord->time.month, pHrRecord->time.day,
pHrRecord->time.hour, pHrRecord->time.minute);
RTT_LOG_D("read :hr_start_addr = %#x, index_addr: %#x, hr_num: %d, hr_page:%d, read_data : %#X\r\n",
Index_Frame.hr_start_addr, index_addr, Index_Frame.hr_num, Index_Frame.hr_page, pHrRecord->hr_data);
return SUCCESS;
}
else
@ -851,7 +870,7 @@ static void TEST_Flash_Write_Record(int argc, char **argv)
{
RTT_LOG_I("Flash_Write_(%d)Record:%d", record, i);
Flash_Write_Record(record);
rt_thread_mdelay(1000 * 60);// 1min
rt_thread_mdelay(1000 * 60); // 1min
}
}
else