diff --git a/.vscode/settings.json b/.vscode/settings.json
index 8d0cb1a..f7bbcc6 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -82,7 +82,8 @@
"fontlib.h": "c",
"font.h": "c",
"display_manager.h": "c",
- "wave_drawer.h": "c"
+ "wave_drawer.h": "c",
+ "sample_data_manager.h": "c"
},
"files.encoding": "gbk"
}
\ No newline at end of file
diff --git a/README.md b/README.md
index 0572f8f..a36ecc3 100644
--- a/README.md
+++ b/README.md
@@ -1,34 +1,34 @@
# conduction1_dynamic_electrocardiograph
-## 使用说明
+## ʹ˵
```
https://iflytop1.feishu.cn/wiki/Fp0fwciUEibtm4kaUeXcraOCneg
```
```
-开发板IO资源说明:
+IOԴ˵:
#define BSP_LED_0 13
#define BSP_LED_1 14
#define BSP_LED_2 15
#define BSP_LED_3 16
-#define BUTTON_1 11 // 上拉低电平有效
-#define BUTTON_2 12 // 上拉低电平有效
-#define BUTTON_3 24 // 上拉低电平有效
-#define BUTTON_4 25 // 上拉低电平有效
+#define BUTTON_1 11 // ͵ƽЧ
+#define BUTTON_2 12 // ͵ƽЧ
+#define BUTTON_3 24 // ͵ƽЧ
+#define BUTTON_4 25 // ͵ƽЧ
sdk\components\boards\pca10100.h
-清风开发板
+翪
- AIN2 -> 光感
+ AIN2 ->
I2C
-#define TWI_SCL_M 28 //I2C SCL引脚
-#define TWI_SDA_M 30 //I2C SDA引脚
+#define TWI_SCL_M 28 //I2C SCL
+#define TWI_SDA_M 30 //I2C SDA
------------------------------------
@@ -41,59 +41,59 @@ PIN4 PIN30/PIN31 PIN28/PIN29 PIN11/PIN20
```
```
-设备行为:
-1. 按下按键或者电极触发后开始广播
+豸Ϊ:
+1. °ߵ缫ʼ㲥
-2. 当电极没有触发,且蓝牙没有连接,且超时10s后,停止广播,进入低功耗模式
+2. 缫ûдûӣҳʱ10sֹͣ㲥ģʽ
-3. 设备状态
+3. 豸״̬
- 关机(休眠)
- 开机蓝牙未连接(广播中)
- 蓝牙已连接
+ ػ()
+ δ(㲥)
+
```
```
-难点:
- 1.采样间隔2ms (500HZ)
- 2.数据往flash中写入时间消耗,cache选择多大,数据什么时候上报。
- 1. ADC:单次采样,阻塞拿数值(50us)
- 2. 电池电量的采集ADC和电压采集ADC用的是同一个ADC
+ѵ:
+ 1.2ms (500HZ)
+ 2.flashдʱģcacheѡʲôʱϱ
+ 1. ADC:βֵ(50us)
+ 2. صIJɼADC͵ѹɼADCõͬһADC
- (这里先使用最简单的阻塞式ADC采集,电池ADC3次,采样ADC3次)
+ ʹʽADCɼADC3ΣADC3Σ
```
```
-屏幕驱动:
+Ļ:
https://github.com/libdriver/ssd1306
-1306驱动和1312是一样的,只不过1312默认是镜像的
+13061312һģֻ1312ĬǾ
```
```
-UI元素:
+UIԪ:
-------------------
-1. 不同大小的字体
-2. 进度条
+1. ͬС
+2.
3. [X]
4. APP
-------------------
-1. 进度条
-2. 圈,x
-3. 时间
+1.
+2. Ȧ,x
+3. ʱ
4. LOGO
5. [X]
6. HR
-7. APP查看结果
-8. 年月日/时分秒
-9. 不同大小的字体
+7. APP鿴
+8. /ʱ
+9. ͬС
xxx
@@ -101,26 +101,113 @@ xxx
LOGO
- 进度条
+
- 年月日
- 时分秒
+
+ ʱ
- 保持静止
+ ־ֹ
___________
[===== ]
------------
- 心电图
+ ĵͼ
[===== ]
[X]
- 不足30秒
+ 30
- 正在保存
+ ڱ
[===== ]
APP
- 查看结果
+ 鿴
+```
+
+
+```
+洢:
+1֡
+2byte
+200֡
+400byte
+1
+400byte
+30
+12kbyte
+120
+48kbyte
+
+----------------------------
+2Mbit
+256Kbyte
+
+640 /120 = 5¼
+
+256kbyte
+
+256byte
+
+[
+ ID:[]
+ packetOFF:[]
+ usage[]:
+ date:[]
+]
+48kbyte --> һ
+
+256/4k = 64 10s
+
+openStorage()
+writeData(){
+
+// Ƿֵ
+
+// Ƿпռ
+// ɵĿռ
+// д
+// д뻺
+
+// Ƿˢ»棿
+
+ҵдݡ
+Ҳ˳ͷžɵ
+Ѱ
+}
+
+// ȡ
+readData(){
+ 1. жĸ
+ 3. ȡϢ
+ 2. ȡ
+ 3.
+}
+
+// Header
+
+[
+ usage:
+ fileHeaderdata:
+ fileId:
+ dataoff:
+ datalen:
+]
+
+{
+ fileUUID:ʱ
+ sector:[1,2,3,4,5]
+ datalen: 100
+ //ֱ
+ //ʱ
+ //
+}
+
+
+```
+
+```
+Ӳ쳣:
+ 1. eepromдʧ
+ 2. ص
```
\ No newline at end of file
diff --git a/app/app.uvoptx b/app/app.uvoptx
index a5f0a2d..38ad6a4 100644
--- a/app/app.uvoptx
+++ b/app/app.uvoptx
@@ -140,7 +140,7 @@
0
JL2CM3
- -U150710864 -O78 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD20000000 -FC4000 -FN2 -FF0nrf52xxx.flm -FS00 -FL0200000 -FP0($$Device:nRF52833_xxAA$Flash\nrf52xxx.flm) -FF1nrf52xxx_uicr.flm -FS110001000 -FL11000 -FP1($$Device:nRF52833_xxAA$Flash\nrf52xxx_uicr.flm)
+ -U150710864 -O78 -S1 -ZTIFSpeedSel10000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD20000000 -FC4000 -FN2 -FF0nrf52xxx.flm -FS00 -FL0200000 -FP0($$Device:nRF52833_xxAA$Flash\nrf52xxx.flm) -FF1nrf52xxx_uicr.flm -FS110001000 -FL11000 -FP1($$Device:nRF52833_xxAA$Flash\nrf52xxx_uicr.flm)
0
@@ -152,18 +152,34 @@
0
0
- 576
+ 157
1
- 181920
+ 206788
0
0
0
0
0
1
- .\src\basic\ssd1306\driver_ssd1306_basic.c
+ .\src\one_conduction\zeeprom_fs.c
- \\nrf52833_xxaa\src/basic/ssd1306/driver_ssd1306_basic.c\576
+ \\nrf52833_xxaa\src/one_conduction/zeeprom_fs.c\157
+
+
+ 1
+ 0
+ 495
+ 1
+ 192364
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ .\src\one_conduction\zeeprom_fs.c
+
+ \\nrf52833_xxaa\src/one_conduction/zeeprom_fs.c\495
@@ -520,7 +536,7 @@
1
12
1
- 0
+ 1
0
0
.\src\basic\ads1293\ads1293.c
@@ -576,6 +592,30 @@
0
0
+
+ 1
+ 17
+ 1
+ 0
+ 0
+ 0
+ .\src\one_conduction\sample_data_manager.c
+ sample_data_manager.c
+ 0
+ 0
+
+
+ 1
+ 18
+ 1
+ 0
+ 0
+ 0
+ .\src\one_conduction\zeeprom_fs.c
+ zeeprom_fs.c
+ 0
+ 0
+
@@ -586,7 +626,7 @@
0
2
- 17
+ 19
1
0
0
@@ -606,7 +646,7 @@
0
3
- 18
+ 20
1
0
0
@@ -618,7 +658,7 @@
3
- 19
+ 21
1
0
0
@@ -638,7 +678,7 @@
0
4
- 20
+ 22
1
0
0
@@ -658,7 +698,7 @@
0
5
- 21
+ 23
1
0
0
@@ -670,7 +710,7 @@
5
- 22
+ 24
1
0
0
@@ -682,7 +722,7 @@
5
- 23
+ 25
1
0
0
@@ -694,7 +734,7 @@
5
- 24
+ 26
1
0
0
@@ -706,7 +746,7 @@
5
- 25
+ 27
1
0
0
@@ -718,7 +758,7 @@
5
- 26
+ 28
1
0
0
@@ -730,7 +770,7 @@
5
- 27
+ 29
1
0
0
@@ -742,7 +782,7 @@
5
- 28
+ 30
1
0
0
@@ -762,7 +802,7 @@
0
6
- 29
+ 31
1
0
0
@@ -782,7 +822,7 @@
0
7
- 30
+ 32
1
0
0
@@ -794,7 +834,7 @@
7
- 31
+ 33
1
0
0
@@ -806,7 +846,7 @@
7
- 32
+ 34
1
0
0
@@ -818,7 +858,7 @@
7
- 33
+ 35
1
0
0
@@ -830,7 +870,7 @@
7
- 34
+ 36
1
0
0
@@ -842,7 +882,7 @@
7
- 35
+ 37
1
0
0
@@ -854,7 +894,7 @@
7
- 36
+ 38
1
0
0
@@ -866,7 +906,7 @@
7
- 37
+ 39
1
0
0
@@ -878,7 +918,7 @@
7
- 38
+ 40
1
0
0
@@ -890,7 +930,7 @@
7
- 39
+ 41
1
0
0
@@ -902,7 +942,7 @@
7
- 40
+ 42
1
0
0
@@ -914,7 +954,7 @@
7
- 41
+ 43
1
0
0
@@ -926,7 +966,7 @@
7
- 42
+ 44
1
0
0
@@ -938,7 +978,7 @@
7
- 43
+ 45
1
0
0
@@ -950,7 +990,7 @@
7
- 44
+ 46
1
0
0
@@ -962,7 +1002,7 @@
7
- 45
+ 47
1
0
0
@@ -974,7 +1014,7 @@
7
- 46
+ 48
1
0
0
@@ -986,7 +1026,7 @@
7
- 47
+ 49
1
0
0
@@ -998,7 +1038,7 @@
7
- 48
+ 50
1
0
0
@@ -1018,7 +1058,7 @@
0
8
- 49
+ 51
1
0
0
@@ -1030,7 +1070,7 @@
8
- 50
+ 52
1
0
0
@@ -1042,7 +1082,7 @@
8
- 51
+ 53
1
0
0
@@ -1054,7 +1094,7 @@
8
- 52
+ 54
1
0
0
@@ -1066,7 +1106,7 @@
8
- 53
+ 55
1
0
0
@@ -1078,7 +1118,7 @@
8
- 54
+ 56
1
0
0
@@ -1090,7 +1130,7 @@
8
- 55
+ 57
1
0
0
@@ -1102,7 +1142,7 @@
8
- 56
+ 58
1
0
0
@@ -1114,7 +1154,7 @@
8
- 57
+ 59
1
0
0
@@ -1126,7 +1166,7 @@
8
- 58
+ 60
1
0
0
@@ -1138,7 +1178,7 @@
8
- 59
+ 61
1
0
0
@@ -1150,7 +1190,7 @@
8
- 60
+ 62
1
0
0
@@ -1162,7 +1202,7 @@
8
- 61
+ 63
1
0
0
@@ -1174,7 +1214,7 @@
8
- 62
+ 64
1
0
0
@@ -1186,7 +1226,7 @@
8
- 63
+ 65
1
0
0
@@ -1198,7 +1238,7 @@
8
- 64
+ 66
1
0
0
@@ -1210,7 +1250,7 @@
8
- 65
+ 67
1
0
0
@@ -1222,7 +1262,7 @@
8
- 66
+ 68
1
0
0
@@ -1234,7 +1274,7 @@
8
- 67
+ 69
1
0
0
@@ -1246,7 +1286,7 @@
8
- 68
+ 70
1
0
0
@@ -1258,7 +1298,7 @@
8
- 69
+ 71
1
0
0
@@ -1270,7 +1310,7 @@
8
- 70
+ 72
1
0
0
@@ -1282,7 +1322,7 @@
8
- 71
+ 73
1
0
0
@@ -1294,7 +1334,7 @@
8
- 72
+ 74
1
0
0
@@ -1306,7 +1346,7 @@
8
- 73
+ 75
1
0
0
@@ -1318,7 +1358,7 @@
8
- 74
+ 76
1
0
0
@@ -1330,7 +1370,7 @@
8
- 75
+ 77
1
0
0
@@ -1350,7 +1390,7 @@
0
9
- 76
+ 78
1
0
0
@@ -1362,7 +1402,7 @@
9
- 77
+ 79
1
0
0
@@ -1374,7 +1414,7 @@
9
- 78
+ 80
1
0
0
@@ -1386,7 +1426,7 @@
9
- 79
+ 81
1
0
0
@@ -1398,7 +1438,7 @@
9
- 80
+ 82
1
0
0
@@ -1410,7 +1450,7 @@
9
- 81
+ 83
1
0
0
@@ -1430,7 +1470,7 @@
0
10
- 82
+ 84
1
0
0
@@ -1442,7 +1482,7 @@
10
- 83
+ 85
1
0
0
@@ -1454,7 +1494,7 @@
10
- 84
+ 86
1
0
0
@@ -1474,7 +1514,7 @@
0
11
- 85
+ 87
1
0
0
@@ -1486,7 +1526,7 @@
11
- 86
+ 88
1
0
0
@@ -1498,7 +1538,7 @@
11
- 87
+ 89
1
0
0
@@ -1518,7 +1558,7 @@
0
12
- 88
+ 90
1
0
0
@@ -1538,7 +1578,7 @@
0
13
- 89
+ 91
1
0
0
@@ -1550,7 +1590,7 @@
13
- 90
+ 92
1
0
0
diff --git a/app/app.uvprojx b/app/app.uvprojx
index 76b25e8..74de99b 100644
--- a/app/app.uvprojx
+++ b/app/app.uvprojx
@@ -313,7 +313,7 @@
1
- 4
+ 1
0
0
1
@@ -337,7 +337,7 @@
0
--reduce_paths --diag_suppress=1295 --diag_suppress=1
- CONFIG_NFCT_PINS_AS_GPIOS APP_TIMER_V2 APP_TIMER_V2_RTC1_ENABLED BOARD_PCA10100 FLOAT_ABI_HARD NRF52833_XXAA NRF_SD_BLE_API_VERSION=7 S140 SOFTDEVICE_PRESENT __HEAP_SIZE=2048 __STACK_SIZE=4048
+ CONFIG_NFCT_PINS_AS_GPIOS APP_TIMER_V2 APP_TIMER_V2_RTC1_ENABLED BOARD_PCA10100 FLOAT_ABI_HARD NRF52833_XXAA NRF_SD_BLE_API_VERSION=7 S140 SOFTDEVICE_PRESENT __HEAP_SIZE=2048 __STACK_SIZE=4096
..\sdk\config;..\sdk\components;..\sdk\components\ble\ble_advertising;..\sdk\components\ble\ble_dtm;..\sdk\components\ble\ble_link_ctx_manager;..\sdk\components\ble\ble_racp;..\sdk\components\ble\ble_services\ble_ancs_c;..\sdk\components\ble\ble_services\ble_ans_c;..\sdk\components\ble\ble_services\ble_bas;..\sdk\components\ble\ble_services\ble_bas_c;..\sdk\components\ble\ble_services\ble_cscs;..\sdk\components\ble\ble_services\ble_cts_c;..\sdk\components\ble\ble_services\ble_dfu;..\sdk\components\ble\ble_services\ble_dis;..\sdk\components\ble\ble_services\ble_gls;..\sdk\components\ble\ble_services\ble_hids;..\sdk\components\ble\ble_services\ble_hrs;..\sdk\components\ble\ble_services\ble_hrs_c;..\sdk\components\ble\ble_services\ble_hts;..\sdk\components\ble\ble_services\ble_ias;..\sdk\components\ble\ble_services\ble_ias_c;..\sdk\components\ble\ble_services\ble_lbs;..\sdk\components\ble\ble_services\ble_lbs_c;..\sdk\components\ble\ble_services\ble_lls;..\sdk\components\ble\ble_services\ble_nus;..\sdk\components\ble\ble_services\ble_nus_c;..\sdk\components\ble\ble_services\ble_rscs;..\sdk\components\ble\ble_services\ble_rscs_c;..\sdk\components\ble\ble_services\ble_tps;..\sdk\components\ble\common;..\sdk\components\ble\nrf_ble_gatt;..\sdk\components\ble\nrf_ble_qwr;..\sdk\components\ble\peer_manager;..\sdk\components\boards;..\sdk\components\libraries\atomic;..\sdk\components\libraries\atomic_fifo;..\sdk\components\libraries\atomic_flags;..\sdk\components\libraries\balloc;..\sdk\components\libraries\bootloader\ble_dfu;..\sdk\components\libraries\bsp;..\sdk\components\libraries\button;..\sdk\components\libraries\cli;..\sdk\components\libraries\crc16;..\sdk\components\libraries\crc32;..\sdk\components\libraries\crypto;..\sdk\components\libraries\csense;..\sdk\components\libraries\csense_drv;..\sdk\components\libraries\delay;..\sdk\components\libraries\ecc;..\sdk\components\libraries\experimental_section_vars;..\sdk\components\libraries\experimental_task_manager;..\sdk\components\libraries\fds;..\sdk\components\libraries\fifo;..\sdk\components\libraries\fstorage;..\sdk\components\libraries\gfx;..\sdk\components\libraries\gpiote;..\sdk\components\libraries\hardfault;..\sdk\components\libraries\hci;..\sdk\components\libraries\led_softblink;..\sdk\components\libraries\log;..\sdk\components\libraries\log\src;..\sdk\components\libraries\low_power_pwm;..\sdk\components\libraries\mem_manager;..\sdk\components\libraries\memobj;..\sdk\components\libraries\mpu;..\sdk\components\libraries\mutex;..\sdk\components\libraries\pwm;..\sdk\components\libraries\pwr_mgmt;..\sdk\components\libraries\queue;..\sdk\components\libraries\ringbuf;..\sdk\components\libraries\scheduler;..\sdk\components\libraries\sdcard;..\sdk\components\libraries\slip;..\sdk\components\libraries\sortlist;..\sdk\components\libraries\spi_mngr;..\sdk\components\libraries\stack_guard;..\sdk\components\libraries\strerror;..\sdk\components\libraries\svc;..\sdk\components\libraries\timer;..\sdk\components\libraries\twi_mngr;..\sdk\components\libraries\twi_sensor;..\sdk\components\libraries\uart;..\sdk\components\libraries\usbd;..\sdk\components\libraries\usbd\class\audio;..\sdk\components\libraries\usbd\class\cdc;..\sdk\components\libraries\usbd\class\cdc\acm;..\sdk\components\libraries\usbd\class\hid;..\sdk\components\libraries\usbd\class\hid\generic;..\sdk\components\libraries\usbd\class\hid\kbd;..\sdk\components\libraries\usbd\class\hid\mouse;..\sdk\components\libraries\usbd\class\msc;..\sdk\components\libraries\util;..\sdk\components\nfc\ndef\conn_hand_parser;..\sdk\components\nfc\ndef\conn_hand_parser\ac_rec_parser;..\sdk\components\nfc\ndef\conn_hand_parser\ble_oob_advdata_parser;..\sdk\components\nfc\ndef\conn_hand_parser\le_oob_rec_parser;..\sdk\components\nfc\ndef\connection_handover\ac_rec;..\sdk\components\nfc\ndef\connection_handover\ble_oob_advdata;..\sdk\components\nfc\ndef\connection_handover\ble_pair_lib;..\sdk\components\nfc\ndef\connection_handover\ble_pair_msg;..\sdk\components\nfc\ndef\connection_handover\common;..\sdk\components\nfc\ndef\connection_handover\ep_oob_rec;..\sdk\components\nfc\ndef\connection_handover\hs_rec;..\sdk\components\nfc\ndef\connection_handover\le_oob_rec;..\sdk\components\nfc\ndef\generic\message;..\sdk\components\nfc\ndef\generic\record;..\sdk\components\nfc\ndef\launchapp;..\sdk\components\nfc\ndef\parser\message;..\sdk\components\nfc\ndef\parser\record;..\sdk\components\nfc\ndef\text;..\sdk\components\nfc\ndef\uri;..\sdk\components\nfc\platform;..\sdk\components\nfc\t2t_lib;..\sdk\components\nfc\t2t_parser;..\sdk\components\nfc\t4t_lib;..\sdk\components\nfc\t4t_parser\apdu;..\sdk\components\nfc\t4t_parser\cc_file;..\sdk\components\nfc\t4t_parser\hl_detection_procedure;..\sdk\components\nfc\t4t_parser\tlv;..\sdk\components\softdevice\common;..\sdk\components\softdevice\s140\headers;..\sdk\components\softdevice\s140\headers\nrf52;..\sdk\external\fprintf;..\sdk\external\segger_rtt;..\sdk\external\utf_converter;..\sdk\integration\nrfx;..\sdk\integration\nrfx\legacy;..\sdk\modules\nrfx;..\sdk\modules\nrfx\drivers\include;..\sdk\modules\nrfx\hal;.\config\;.\src\;..\libznordic\include;..\sdk\external\fatfs\port;..\sdk\external\fatfs\src;..\sdk\components\libraries\block_dev;..\sdk\components\libraries\block_dev\sdc\;..\sdk\external\protothreads\;..\sdk\external\protothreads\pt-1.4\;..\sdk\components\libraries\scheduler
@@ -355,7 +355,7 @@
1
--cpreproc_opts=-DAPP_TIMER_V2,-DAPP_TIMER_V2_RTC1_ENABLED,-DBOARD_PCA10100,-DFLOAT_ABI_HARD,-DNRF52833_XXAA,-DNRF_SD_BLE_API_VERSION=7,-DS140,-DSOFTDEVICE_PRESENT,-D__HEAP_SIZE=2048,-D__STACK_SIZE=2048
- APP_TIMER_V2 APP_TIMER_V2_RTC1_ENABLED BOARD_PCA10100 FLOAT_ABI_HARD NRF52833_XXAA NRF_SD_BLE_API_VERSION=7 S140 SOFTDEVICE_PRESENT __HEAP_SIZE=2048 __STACK_SIZE=2048
+ APP_TIMER_V2 APP_TIMER_V2_RTC1_ENABLED BOARD_PCA10100 FLOAT_ABI_HARD NRF52833_XXAA NRF_SD_BLE_API_VERSION=7 S140 SOFTDEVICE_PRESENT __HEAP_SIZE=2048 __STACK_SIZE=4096
..\sdk\config;..\sdk\components;..\sdk\components\ble\ble_advertising;..\sdk\components\ble\ble_dtm;..\sdk\components\ble\ble_link_ctx_manager;..\sdk\components\ble\ble_racp;..\sdk\components\ble\ble_services\ble_ancs_c;..\sdk\components\ble\ble_services\ble_ans_c;..\sdk\components\ble\ble_services\ble_bas;..\sdk\components\ble\ble_services\ble_bas_c;..\sdk\components\ble\ble_services\ble_cscs;..\sdk\components\ble\ble_services\ble_cts_c;..\sdk\components\ble\ble_services\ble_dfu;..\sdk\components\ble\ble_services\ble_dis;..\sdk\components\ble\ble_services\ble_gls;..\sdk\components\ble\ble_services\ble_hids;..\sdk\components\ble\ble_services\ble_hrs;..\sdk\components\ble\ble_services\ble_hrs_c;..\sdk\components\ble\ble_services\ble_hts;..\sdk\components\ble\ble_services\ble_ias;..\sdk\components\ble\ble_services\ble_ias_c;..\sdk\components\ble\ble_services\ble_lbs;..\sdk\components\ble\ble_services\ble_lbs_c;..\sdk\components\ble\ble_services\ble_lls;..\sdk\components\ble\ble_services\ble_nus;..\sdk\components\ble\ble_services\ble_nus_c;..\sdk\components\ble\ble_services\ble_rscs;..\sdk\components\ble\ble_services\ble_rscs_c;..\sdk\components\ble\ble_services\ble_tps;..\sdk\components\ble\common;..\sdk\components\ble\nrf_ble_gatt;..\sdk\components\ble\nrf_ble_qwr;..\sdk\components\ble\peer_manager;..\sdk\components\boards;..\sdk\components\libraries\atomic;..\sdk\components\libraries\atomic_fifo;..\sdk\components\libraries\atomic_flags;..\sdk\components\libraries\balloc;..\sdk\components\libraries\bootloader\ble_dfu;..\sdk\components\libraries\bsp;..\sdk\components\libraries\button;..\sdk\components\libraries\cli;..\sdk\components\libraries\crc16;..\sdk\components\libraries\crc32;..\sdk\components\libraries\crypto;..\sdk\components\libraries\csense;..\sdk\components\libraries\csense_drv;..\sdk\components\libraries\delay;..\sdk\components\libraries\ecc;..\sdk\components\libraries\experimental_section_vars;..\sdk\components\libraries\experimental_task_manager;..\sdk\components\libraries\fds;..\sdk\components\libraries\fifo;..\sdk\components\libraries\fstorage;..\sdk\components\libraries\gfx;..\sdk\components\libraries\gpiote;..\sdk\components\libraries\hardfault;..\sdk\components\libraries\hci;..\sdk\components\libraries\led_softblink;..\sdk\components\libraries\log;..\sdk\components\libraries\log\src;..\sdk\components\libraries\low_power_pwm;..\sdk\components\libraries\mem_manager;..\sdk\components\libraries\memobj;..\sdk\components\libraries\mpu;..\sdk\components\libraries\mutex;..\sdk\components\libraries\pwm;..\sdk\components\libraries\pwr_mgmt;..\sdk\components\libraries\queue;..\sdk\components\libraries\ringbuf;..\sdk\components\libraries\scheduler;..\sdk\components\libraries\sdcard;..\sdk\components\libraries\slip;..\sdk\components\libraries\sortlist;..\sdk\components\libraries\spi_mngr;..\sdk\components\libraries\stack_guard;..\sdk\components\libraries\strerror;..\sdk\components\libraries\svc;..\sdk\components\libraries\timer;..\sdk\components\libraries\twi_mngr;..\sdk\components\libraries\twi_sensor;..\sdk\components\libraries\uart;..\sdk\components\libraries\usbd;..\sdk\components\libraries\usbd\class\audio;..\sdk\components\libraries\usbd\class\cdc;..\sdk\components\libraries\usbd\class\cdc\acm;..\sdk\components\libraries\usbd\class\hid;..\sdk\components\libraries\usbd\class\hid\generic;..\sdk\components\libraries\usbd\class\hid\kbd;..\sdk\components\libraries\usbd\class\hid\mouse;..\sdk\components\libraries\usbd\class\msc;..\sdk\components\libraries\util;..\sdk\components\nfc\ndef\conn_hand_parser;..\sdk\components\nfc\ndef\conn_hand_parser\ac_rec_parser;..\sdk\components\nfc\ndef\conn_hand_parser\ble_oob_advdata_parser;..\sdk\components\nfc\ndef\conn_hand_parser\le_oob_rec_parser;..\sdk\components\nfc\ndef\connection_handover\ac_rec;..\sdk\components\nfc\ndef\connection_handover\ble_oob_advdata;..\sdk\components\nfc\ndef\connection_handover\ble_pair_lib;..\sdk\components\nfc\ndef\connection_handover\ble_pair_msg;..\sdk\components\nfc\ndef\connection_handover\common;..\sdk\components\nfc\ndef\connection_handover\ep_oob_rec;..\sdk\components\nfc\ndef\connection_handover\hs_rec;..\sdk\components\nfc\ndef\connection_handover\le_oob_rec;..\sdk\components\nfc\ndef\generic\message;..\sdk\components\nfc\ndef\generic\record;..\sdk\components\nfc\ndef\launchapp;..\sdk\components\nfc\ndef\parser\message;..\sdk\components\nfc\ndef\parser\record;..\sdk\components\nfc\ndef\text;..\sdk\components\nfc\ndef\uri;..\sdk\components\nfc\platform;..\sdk\components\nfc\t2t_lib;..\sdk\components\nfc\t2t_parser;..\sdk\components\nfc\t4t_lib;..\sdk\components\nfc\t4t_parser\apdu;..\sdk\components\nfc\t4t_parser\cc_file;..\sdk\components\nfc\t4t_parser\hl_detection_procedure;..\sdk\components\nfc\t4t_parser\tlv;..\sdk\components\softdevice\common;..\sdk\components\softdevice\s140\headers;..\sdk\components\softdevice\s140\headers\nrf52;..\sdk\external\fprintf;..\sdk\external\segger_rtt;..\sdk\external\utf_converter;..\sdk\integration\nrfx;..\sdk\integration\nrfx\legacy;..\sdk\modules\nrfx;..\sdk\modules\nrfx\drivers\include;..\sdk\modules\nrfx\hal;.\config\
@@ -463,6 +463,16 @@
1
.\src\basic\ssd1306\wave_drawer.c
+
+ sample_data_manager.c
+ 1
+ .\src\one_conduction\sample_data_manager.c
+
+
+ zeeprom_fs.c
+ 1
+ .\src\one_conduction\zeeprom_fs.c
+
@@ -4267,6 +4277,16 @@
1
.\src\basic\ssd1306\wave_drawer.c
+
+ sample_data_manager.c
+ 1
+ .\src\one_conduction\sample_data_manager.c
+
+
+ zeeprom_fs.c
+ 1
+ .\src\one_conduction\zeeprom_fs.c
+
diff --git a/app/config/sdk_config.h b/app/config/sdk_config.h
index 12dcb3b..f064baa 100644
--- a/app/config/sdk_config.h
+++ b/app/config/sdk_config.h
@@ -6306,7 +6306,7 @@
// will fail.
#ifndef APP_TIMER_CONFIG_OP_QUEUE_SIZE
-#define APP_TIMER_CONFIG_OP_QUEUE_SIZE 10
+#define APP_TIMER_CONFIG_OP_QUEUE_SIZE 20
#endif
// APP_TIMER_CONFIG_USE_SCHEDULER - Enable scheduling app_timer events to app_scheduler
@@ -7824,7 +7824,7 @@
// a timestamp and up to 2 arguments in a single memory object.
#ifndef NRF_LOG_MSGPOOL_ELEMENT_SIZE
-#define NRF_LOG_MSGPOOL_ELEMENT_SIZE 20
+#define NRF_LOG_MSGPOOL_ELEMENT_SIZE 40
#endif
// NRF_LOG_MSGPOOL_ELEMENT_COUNT - Number of elements in the pool of memory objects
@@ -7834,7 +7834,7 @@
// RAM memory usage.
#ifndef NRF_LOG_MSGPOOL_ELEMENT_COUNT
-#define NRF_LOG_MSGPOOL_ELEMENT_COUNT 8
+#define NRF_LOG_MSGPOOL_ELEMENT_COUNT 20
#endif
//
@@ -7865,7 +7865,7 @@
// <16384=> 16384
#ifndef NRF_LOG_BUFSIZE
-#define NRF_LOG_BUFSIZE 1024
+#define NRF_LOG_BUFSIZE 2048
#endif
// NRF_LOG_CLI_CMDS - Enable CLI commands for the module.
@@ -7911,7 +7911,7 @@
// but system will spend significant amount of time in critical section
#ifndef NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED
-#define NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED 0
+#define NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED 1
#endif
// NRF_LOG_STR_PUSH_BUFFER_SIZE - Size of the buffer dedicated for strings stored using @ref NRF_LOG_PUSH.
@@ -7925,7 +7925,7 @@
// <1024=> 1024
#ifndef NRF_LOG_STR_PUSH_BUFFER_SIZE
-#define NRF_LOG_STR_PUSH_BUFFER_SIZE 128
+#define NRF_LOG_STR_PUSH_BUFFER_SIZE 256
#endif
// NRF_LOG_STR_PUSH_BUFFER_SIZE - Size of the buffer dedicated for strings stored using @ref NRF_LOG_PUSH.
@@ -7939,7 +7939,7 @@
// <1024=> 1024
#ifndef NRF_LOG_STR_PUSH_BUFFER_SIZE
-#define NRF_LOG_STR_PUSH_BUFFER_SIZE 128
+#define NRF_LOG_STR_PUSH_BUFFER_SIZE 256
#endif
// NRF_LOG_USES_COLORS - If enabled then ANSI escape code for colors is prefixed to every string
diff --git a/app/main.hardtest.c b/app/main.hardtest.c
index 2a81373..20c1296 100644
--- a/app/main.hardtest.c
+++ b/app/main.hardtest.c
@@ -47,7 +47,7 @@ void main() {
#endif
// EEPROM_TEST
-#if 0
+#if 1
static void test_tx_timer_cb(void* p_context) {
static uint32_t data;
data++;
@@ -297,7 +297,7 @@ void main() {
extern uint32_t g_nrf_log_tx_pin;
APP_TIMER_DEF(m_test_tx_timer);
-ZDATACHANNEL_DEF(m_zhrs, 2 /*回调事件优先级*/, 1 /*client num*/);
+ZDATACHANNEL_DEF(m_zhrs, 2 /*回调事件优先?*/, 1 /*client num*/);
static const char* hex2str(const uint8_t* data, int32_t len) {
static char rx[64] = {0};
memset(rx, 0, sizeof(rx));
@@ -309,7 +309,7 @@ static const char* hex2str(const uint8_t* data, int32_t len) {
static void zdatachannel_data_handler(zdatachannel_evt_t* p_evt) {
/**
- * @brief 接收到指令数据
+ * @brief 接收到指令数?
*/
if (p_evt->type == ZDATACHANNEL_EVT_RX_DATA) {
ZLOGI("rx:%s", hex2str(p_evt->params.rx_data.p_data, p_evt->params.rx_data.length));
@@ -317,7 +317,7 @@ static void zdatachannel_data_handler(zdatachannel_evt_t* p_evt) {
}
static void on_service_init(void) {
/**
- * @brief 数据通道初始化
+ * @brief 数据通道初始?
*/
ZLOGI("init zdatachannel service");
zdatachannel_init_t zdatachannle_init;
@@ -459,7 +459,7 @@ static void test_tx_timer_cb(void* p_context) {
// zdatachannel_data_send(tx, &p_length);
}
-ZDATACHANNEL_DEF(m_zhrs, 2 /*回调事件优先级*/, 1 /*client num*/);
+ZDATACHANNEL_DEF(m_zhrs, 2 /*回调事件优先?*/, 1 /*client num*/);
static const char* hex2str(const uint8_t* data, int32_t len) {
static char rx[64] = {0};
memset(rx, 0, sizeof(rx));
@@ -473,7 +473,7 @@ static const char* hex2str(const uint8_t* data, int32_t len) {
char cmdcache[256] = {0};
static void zdatachannel_data_handler(zdatachannel_evt_t* p_evt) {
/**
- * @brief 接收到指令数据
+ * @brief 接收到指令数?
*/
if (p_evt->type == ZDATACHANNEL_EVT_RX_DATA) {
@@ -481,7 +481,7 @@ static void zdatachannel_data_handler(zdatachannel_evt_t* p_evt) {
}
static void on_service_init(void) {
/**
- * @brief 数据通道初始化
+ * @brief 数据通道初始?
*/
ZLOGI("init zdatachannel service");
zdatachannel_init_t zdatachannle_init;
diff --git a/app/src/one_conduction/display_manager.c b/app/src/one_conduction/display_manager.c
index 28f5af7..0f5ca40 100644
--- a/app/src/one_conduction/display_manager.c
+++ b/app/src/one_conduction/display_manager.c
@@ -66,15 +66,6 @@ void dsp_mgr_change_to_welcome() {
dsp_mgr_change_to_page(kPage_welcome);
}
-const char* fmt(const char* format, ...) {
- static char buf[128];
- va_list args;
- va_start(args, format);
- vsprintf(buf, format, args);
- va_end(args);
- ZLOGI("fmt:%s", buf);
- return buf;
-}
int compute_x_pos_by_center(int16_t x, int16_t width) { return x - width / 2; }
int compute_y_pos_by_center(int16_t y, int16_t height) { return y - height / 2; }
diff --git a/app/src/one_conduction/one_conduction_board.c b/app/src/one_conduction/one_conduction_board.c
index d1fa06f..3d3d147 100644
--- a/app/src/one_conduction/one_conduction_board.c
+++ b/app/src/one_conduction/one_conduction_board.c
@@ -214,18 +214,16 @@ void SingleLeadECG_eeprom_init() {
config.scl = EEPROM_I2C_SCL_M;
config.sda = EEPROM_I2C_SDA_M;
- config.frequency = NRF_DRV_TWI_FREQ_100K;
- // {
- // .scl = EEPROM_I2C_SCL_M,
- // .sda = EEPROM_I2C_SDA_M,
- // .frequency = NRF_DRV_TWI_FREQ_100K,
- // .interrupt_priority = APP_IRQ_PRIORITY_HIGH,
- // .clear_bus_init = false,
- // };
-
+ config.frequency = NRF_DRV_TWI_FREQ_400K;
ZERROR_CHECK(nrf_drv_twi_init(&m_eeprom_twi_master, &config, NULL, NULL));
nrf_drv_twi_enable(&m_eeprom_twi_master);
}
+
+void SingleLeadECG_eeprom_uninit() {
+ nrf_drv_twi_disable(&m_eeprom_twi_master);
+ nrf_drv_twi_uninit(&m_eeprom_twi_master);
+}
+
static uint8_t eeprom_cache[EEPROM_PAGE + 2];
static void assign_i2c_add(uint32_t add, bool wr, uint8_t *i2cadd, uint8_t *memadd0, uint8_t *memadd1) {
@@ -250,18 +248,59 @@ static void assign_i2c_add(uint32_t add, bool wr, uint8_t *i2cadd, uint8_t *mema
*memadd1 = add & 0xFF;
}
-void SingleLeadECG_eeprom_write(uint16_t page, uint8_t *data, uint16_t len) { //
- uint32_t addr = page * EEPROM_PAGE;
- len = len > EEPROM_PAGE ? EEPROM_PAGE : len;
+void SingleLeadECG_eeprom_write(uint32_t addr, const uint8_t *data, uint16_t len) { //
+ // uint32_t addr = page * EEPROM_PAGE;
+ // len = len > EEPROM_PAGE ? EEPROM_PAGE : len;
+
+ // ZASSERT(len == EEPROM_PAGE);
+ ZASSERT((addr % EEPROM_PAGE) == 0);
+
uint8_t deviceSelect = 0;
assign_i2c_add(addr, true, &deviceSelect, &eeprom_cache[0], &eeprom_cache[1]);
memcpy(&eeprom_cache[2], data, len);
+
ret_code_t ecode = nrf_drv_twi_tx(&m_eeprom_twi_master, deviceSelect, eeprom_cache, len + 2, false);
if (ecode != NRF_SUCCESS) {
ZLOGE("nrf_drv_twi_tx error %x", ecode);
NRF_LOG_INTERNAL_FLUSH();
}
+ nrf_delay_ms(10);
+}
+/**
+ * @brief ȡeepromǷ
+ */
+void SingleLeadECG_eeprom_wr_check() {
+ /**
+ * @brief
+ * 256kbyte
+ * дݣضǷȷ
+ */
+
+ static uint8_t wdata_cache[256];
+ static uint8_t rdata_cache[256];
+#define CHECKCODE (i % 21)
+
+ for (uint32_t i = 0; i < 1024; i++) {
+ uint32_t addr = i * EEPROM_PAGE;
+ for (uint32_t j = 0; j < EEPROM_PAGE; j++) {
+ wdata_cache[j] = CHECKCODE;
+ }
+ ZLOGI_BLOCK("write %d", i);
+ SingleLeadECG_eeprom_write(addr, wdata_cache, EEPROM_PAGE);
+ nrf_delay_ms(15);
+ }
+
+ for (uint32_t i = 0; i < 1024; i++) {
+ uint32_t addr = i * EEPROM_PAGE;
+ ZLOGI_BLOCK("check %d", i);
+ SingleLeadECG_eeprom_read(addr, rdata_cache, EEPROM_PAGE);
+ for (uint32_t j = 0; j < EEPROM_PAGE; j++) {
+ if (rdata_cache[j] != (CHECKCODE)) {
+ ZLOGE("SingleLeadECG_eeprom_wr_check error %d %d %d", i, j, rdata_cache[j]);
+ }
+ }
+ }
}
void SingleLeadECG_eeprom_read(uint32_t add, uint8_t *data, uint16_t len) {
@@ -274,4 +313,3 @@ void SingleLeadECG_eeprom_read(uint32_t add, uint8_t *data, uint16_t len) {
deviceSelect |= 0x01; // read
nrf_drv_twi_rx(&m_eeprom_twi_master, deviceSelect, data, len);
}
-
diff --git a/app/src/one_conduction/one_conduction_board.h b/app/src/one_conduction/one_conduction_board.h
index bda3b8b..d8747eb 100644
--- a/app/src/one_conduction/one_conduction_board.h
+++ b/app/src/one_conduction/one_conduction_board.h
@@ -9,6 +9,7 @@
#include
#include "basic/ssd1306/driver_ssd1306_interface.h"
+#include "znordic.h"
/*******************************************************************************
* basic *
@@ -31,7 +32,8 @@ void SingleLeadECG_beep_set_state(bool state);
*/
#define EEPROM_PAGE 256
void SingleLeadECG_eeprom_init();
-void SingleLeadECG_eeprom_write(uint16_t page, uint8_t* data, uint16_t len);
+void SingleLeadECG_eeprom_uninit();
+void SingleLeadECG_eeprom_write(uint32_t page, const uint8_t *data, uint16_t len);
void SingleLeadECG_eeprom_read(uint32_t add, uint8_t* data, uint16_t len);
/*******************************************************************************
diff --git a/app/src/one_conduction/one_conduction_main.c b/app/src/one_conduction/one_conduction_main.c
index 8668273..f839fa2 100644
--- a/app/src/one_conduction/one_conduction_main.c
+++ b/app/src/one_conduction/one_conduction_main.c
@@ -2,8 +2,9 @@
#include "basic/zble_module.h"
#include "basic/zdatachannel_service.h"
-#include "one_conduction_board.h"
#include "display_manager.h"
+#include "one_conduction_board.h"
+#include "sample_data_manager.h"
#include "znordic.h"
ZDATACHANNEL_DEF(m_zhrs, 2 /*ص¼??*/, 1 /*client num*/);
@@ -11,14 +12,6 @@ ZDATACHANNEL_DEF(m_zhrs, 2 /*
/*******************************************************************************
* TOOLS *
*******************************************************************************/
-static const char* hex2str(const uint8_t* data, int32_t len) {
- static char rx[64] = {0};
- memset(rx, 0, sizeof(rx));
- for (int32_t i = 0; i < len; i++) {
- sprintf(rx + i * 2, "%02X", data[i]);
- }
- return rx;
-}
void zdatachannel_data_handler(zdatachannel_evt_t* p_evt) {
/**
@@ -32,13 +25,28 @@ void zdatachannel_data_handler(zdatachannel_evt_t* p_evt) {
#define SAMPLES 100
#define AMPLITUDE 50
static void test_tx_timer_cb(void* p_context) {
- static int i;
- float val = 50 + AMPLITUDE * sin(2 * PI * i / SAMPLES);
- // NRF_LOG_FLOAT(val);
+ // static int i;
+ // float val = 50 + AMPLITUDE * sin(2 * PI * i / SAMPLES);
+ // // NRF_LOG_FLOAT(val);
+
+ // ZLOGI("tx:" NRF_LOG_FLOAT_MARKER, NRF_LOG_FLOAT(val));
+ // i++;
+ // dsp_mgr_draw_point(val);
+
+ // SingleLeadECG_eeprom_init();
+ // static uint8_t eepromw_test_data[256];
+ // static uint8_t eepromw_rx_data[256];
+ // for (size_t i = 0; i < 256; i++) {
+ // eepromw_test_data[i] = i;
+ // }
+ // SingleLeadECG_eeprom_write(0, eepromw_test_data, 256);
+ // SingleLeadECG_eeprom_read(0, eepromw_rx_data, 256);
+ // NRF_LOG_HEXDUMP_INFO(eepromw_rx_data, 48);
+ // NRF_LOG_HEXDUMP_INFO(eepromw_rx_data+64, 64);
- ZLOGI("tx:" NRF_LOG_FLOAT_MARKER, NRF_LOG_FLOAT(val));
- i++;
- dsp_mgr_draw_point(val);
+ // for (size_t i = 0; i < 256; i++) {
+ // ZLOGI_BLOCK("eepromw_rx_data[%d] = %d", i, eepromw_rx_data[i]);
+ // }
}
extern uint32_t g_nrf_log_tx_pin;
@@ -78,8 +86,24 @@ void one_conduction_main() {
dsp_mgr_poweron();
dsp_mgr_change_to_sampling();
- ZERROR_CHECK(app_timer_create(&m_drawpoint_timer, APP_TIMER_MODE_REPEATED, test_tx_timer_cb));
- ZERROR_CHECK(app_timer_start(m_drawpoint_timer, APP_TIMER_TICKS(30), NULL));
+ sample_data_mgr_init();
+ static sample_data_filename_t filename = {0x01, 0x02, 0x03, 0x04, 0x05};
+
+ static uint8_t wd[256];
+ for (size_t i = 0; i < 256; i++) wd[i] = i;
+
+ int fd = sample_data_mgr_open(&filename);
+ sample_data_mgr_write(fd, wd, 256);
+ sample_data_mgr_close(fd);
+
+ zeeprom_fs_dump_sector_state();
+ // sample_data_mgr_dump_fileinfo_list();
+ sample_data_mgr_uninit();
+
+ // SingleLeadECG_eeprom_write(0, eepromw_test_data, 256);
+
+ ZERROR_CHECK(app_timer_create(&m_drawpoint_timer, APP_TIMER_MODE_SINGLE_SHOT, test_tx_timer_cb));
+ ZERROR_CHECK(app_timer_start(m_drawpoint_timer, APP_TIMER_TICKS(100), NULL));
znordic_loop();
}
diff --git a/app/src/one_conduction/sample_data_manager.c b/app/src/one_conduction/sample_data_manager.c
new file mode 100644
index 0000000..abcb226
--- /dev/null
+++ b/app/src/one_conduction/sample_data_manager.c
@@ -0,0 +1,82 @@
+#include "sample_data_manager.h"
+
+#include
+
+#include "zeeprom_fs.h"
+#include "znordic.h"
+
+static sample_data_fileinfo_t fileinfocache[FILE_MAX_COUNT];
+static uint8_t fileinfocache_count = 0;
+
+void sample_data_mgr_init() { zeeprom_fs_init(); }
+void sample_data_mgr_uninit() { zeeprom_fs_uinit(); }
+
+sample_data_fileinfo_list_t* sample_data_mgr_get_fileinfo_list() { //
+ static sample_data_fileinfo_list_t fileinfo_list;
+
+ // ȡм¼Ϣ
+ zeeprom_header_t* header = zeeprom_fs_get_header();
+
+ uint16_t fileoff = 0;
+
+ for (uint16_t i = 0; i < ZARRAY_SIZE(header->sectorinfos); i++) {
+ zeeprom_sector_info_t* sectorinfo = &header->sectorinfos[i];
+ if (sectorinfo->usage == 1 && sectorinfo->sector_index_in_file == 0) {
+ // ȡļϢ
+ sample_data_fileinfo_t* fileinfo = &fileinfocache[fileoff];
+ fileinfo->fileuuid = sectorinfo->fileuuid;
+ memcpy(fileinfo->filename, sectorinfo->filename, sizeof(fileinfo->filename));
+ fileinfo->size = zeeprom_fs_get_filesize(fileinfo->fileuuid);
+ fileoff += sectorinfo->datalen;
+
+ fileinfo_list.fileinfo[fileoff] = fileinfo;
+ fileinfo_list.count++;
+ }
+ }
+ // ļuuiduuidǰ
+ for (uint16_t i = 0; i < fileoff; i++) {
+ for (uint16_t j = i + 1; j < fileoff; j++) {
+ if (fileinfo_list.fileinfo[i]->fileuuid < fileinfo_list.fileinfo[j]->fileuuid) {
+ sample_data_fileinfo_t* tmp = fileinfo_list.fileinfo[i];
+ fileinfo_list.fileinfo[i] = fileinfo_list.fileinfo[j];
+ fileinfo_list.fileinfo[j] = tmp;
+ }
+ }
+ }
+ return &fileinfo_list;
+}
+#if 1
+static const char* filename2str(uint8_t* filename) {
+ static char filename_str[17];
+ for (size_t i = 0; i < 8; i++) {
+ filename_str[i * 2] = (filename[i] >> 4) + '0';
+ filename_str[i * 2 + 1] = (filename[i] & 0x0f) + '0';
+ }
+
+ return filename_str;
+}
+
+#endif
+
+void sample_data_mgr_dump_fileinfo_list() {
+ sample_data_fileinfo_list_t* fileinfo_list = sample_data_mgr_get_fileinfo_list();
+ ZLOGI_BLOCK("fileinfo_list->count=%d\n", fileinfo_list->count);
+ for (uint16_t i = 0; i < fileinfo_list->count; i++) {
+ sample_data_fileinfo_t* fileinfo = fileinfo_list->fileinfo[i];
+ ZLOGI_BLOCK("[%d]: filename=%s, fileuuid=%d, size=%d", i, filename2str(fileinfo->filename), fileinfo->fileuuid, fileinfo->size);
+ }
+}
+
+int32_t sample_data_mgr_open(sample_data_filename_t* filename) {
+ /**
+ * @brief 鿴ļ
+ */
+ if (zeeprom_fs_get_file_num() >= FILE_MAX_COUNT) {
+ zeeprom_fs_delete_the_oldest_file();
+ }
+ return zeeprom_fs_open((uint8_t*)filename, NULL, 0);
+}
+int32_t sample_data_mgr_close(int32_t fileId) { return zeeprom_fs_close(fileId); }
+int32_t sample_data_mgr_write(int32_t fileId, const uint8_t* data, int32_t size) { return zeeprom_fs_write(fileId, data, size); }
+int32_t sample_data_mgr_read(int32_t fileId, uint8_t* data, int32_t size) { return zeeprom_fs_read(fileId, data, size); }
+int32_t sample_data_mgr_delete_file(sample_data_filename_t* filename) { return zeeprom_fs_delete_by_name((uint8_t*)filename); }
diff --git a/app/src/one_conduction/sample_data_manager.h b/app/src/one_conduction/sample_data_manager.h
new file mode 100644
index 0000000..ebb3121
--- /dev/null
+++ b/app/src/one_conduction/sample_data_manager.h
@@ -0,0 +1,40 @@
+#pragma once
+#include
+
+void sample_data_mgr_init();
+
+#define FILE_MAX_COUNT 10
+
+typedef struct {
+ uint8_t year;
+ uint8_t month;
+ uint8_t day;
+ uint8_t hour;
+ uint8_t min;
+ uint8_t sec;
+ uint8_t placeholder[2];
+} sample_data_filename_t;
+
+typedef struct {
+ uint8_t filename[8];
+ int32_t fileuuid;
+ int32_t size;
+} sample_data_fileinfo_t;
+
+typedef struct {
+ sample_data_fileinfo_t* fileinfo[FILE_MAX_COUNT];
+ int count;
+} sample_data_fileinfo_list_t;
+
+void sample_data_mgr_init();
+void sample_data_mgr_uninit();
+
+sample_data_fileinfo_list_t* sample_data_mgr_get_fileinfo_list();
+
+int32_t sample_data_mgr_open(sample_data_filename_t* filename);
+int32_t sample_data_mgr_close(int32_t fileId);
+
+int32_t sample_data_mgr_write(int32_t fileId, const uint8_t* data, int32_t size);
+int32_t sample_data_mgr_read(int32_t fileId, uint8_t* data, int32_t size);
+
+int32_t sample_data_mgr_delete_file(sample_data_filename_t* filename);
diff --git a/app/src/one_conduction/zeeprom_fs.c b/app/src/one_conduction/zeeprom_fs.c
new file mode 100644
index 0000000..22ffcae
--- /dev/null
+++ b/app/src/one_conduction/zeeprom_fs.c
@@ -0,0 +1,539 @@
+#include "zeeprom_fs.h"
+
+#include "one_conduction_board.h"
+
+static zeeprom_header_t m_eeprom_header;
+static bool m_is_init = false;
+
+static filehandler_t m_filehandler[2];
+static int m_fd_off;
+
+/*******************************************************************************
+ * *
+ *******************************************************************************/
+
+static filehandler_t* filehandler_find(int fd);
+static filehandler_t* filehandler_alloc();
+static void filehandler_rlease(int fd);
+
+static int32_t sector_mgr_find_earliest_file_created_index();
+static int32_t sector_mgr_free_sector(int32_t fileuuid);
+static zeeprom_sector_info_t* sector_mgr_find_idle_sector();
+static bool sector_mgr_sector_is_open(int32_t fileuuid);
+static zeeprom_sector_info_t* sector_mgr_force_find_idle_sector();
+static void sector_mgr_open_sector(int32_t fileuuid);
+static void sector_mgr_close_sector(int32_t fileuuid);
+// static zeeprom_sector_info_t* sector_mgr_find_fileheader(int32_t fileuuid);
+static zeeprom_sector_info_t* sector_mgr_find_end_sector(int32_t fileuuid);
+static zeeprom_sector_info_t* sector_mgr_find_sector(int32_t fileuuid, int32_t sector_index_in_file);
+static int32_t sector_mgr_file_get_size(int32_t fileuuid);
+
+static zeeprom_sector_info_t* sector_mgr_find_fileheader_by_filename(uint8_t* fileid);
+static int32_t sector_mgr_get_sector_offset(zeeprom_sector_info_t* sector);
+static int32_t sector_mgr_get_sector_rom_add(zeeprom_sector_info_t* sector);
+
+static void zeeprom_read(int32_t add, uint8_t* data, uint16_t len);
+static void zeeprom_write(int32_t add, const uint8_t* data, uint16_t len);
+static int32_t compute_checksum(uint8_t* data, uint16_t len);
+
+/*******************************************************************************
+ * CODE *
+ *******************************************************************************/
+int zeeprom_fs_init() { //
+ SingleLeadECG_eeprom_init();
+ zeeprom_read(0, (uint8_t*)&m_eeprom_header, sizeof(m_eeprom_header));
+ int32_t checksum_val = compute_checksum((uint8_t*)&m_eeprom_header, sizeof(m_eeprom_header) - sizeof(m_eeprom_header.checksum));
+ if (checksum_val != m_eeprom_header.checksum) {
+ memset(&m_eeprom_header, 0, sizeof(m_eeprom_header));
+ }
+
+ m_is_init = true;
+ return 0;
+}
+int zeeprom_fs_uinit() { //
+ zeeprom_write(0, (uint8_t*)&m_eeprom_header, sizeof(m_eeprom_header));
+ SingleLeadECG_eeprom_uninit();
+ m_is_init = false;
+ return 0;
+}
+
+zeeprom_header_t* zeeprom_fs_get_header() { return &m_eeprom_header; }
+
+int zeeprom_fs_open(uint8_t* filename, uint8_t* usrdata[], uint8_t usrdata_len) {
+ ZASSERT(m_is_init);
+ /**
+ * @brief
+ * 1. ļѾڣļ
+ * 2. ļڣ ļ
+ *
+ * ļ:
+ * 1. ҵһ
+ * 2. ʼļͷ
+ */
+
+ filehandler_t* fileHander = filehandler_alloc();
+ if (!fileHander) {
+ ZLOGI("fileHander_alloc fail");
+ return -1;
+ }
+
+ zeeprom_sector_info_t* sectorHeaderInfo = sector_mgr_find_fileheader_by_filename(filename);
+ if (sectorHeaderInfo) {
+ /**
+ * @brief ļѴ
+ */
+ // ļλһ
+ fileHander->fileuuid = sectorHeaderInfo->fileuuid;
+ fileHander->file_offset = 0;
+ fileHander->fd = fileHander->fd;
+ fileHander->sector_header = sectorHeaderInfo;
+ fileHander->file_size = sector_mgr_file_get_size(fileHander->fileuuid);
+ memcpy(fileHander->filename, filename, 8);
+ memcpy(fileHander->usrdata, sectorHeaderInfo->usrdata, sizeof(sectorHeaderInfo->usrdata));
+ sector_mgr_open_sector(fileHander->fileuuid);
+ return fileHander->fd;
+ } else {
+ /**
+ * @brief ļ
+ */
+
+ sectorHeaderInfo = sector_mgr_force_find_idle_sector();
+ if (!sectorHeaderInfo) {
+ ZLOGE("sector_mgr_force_find_idle_sector fail");
+ filehandler_rlease(fileHander->fd);
+ return -1;
+ }
+
+ memset(sectorHeaderInfo, 0, sizeof(zeeprom_sector_info_t));
+ sectorHeaderInfo->usage = 1;
+ sectorHeaderInfo->opened = 1;
+ memcpy(sectorHeaderInfo->filename, filename, 8);
+ sectorHeaderInfo->sector_index_in_file = 0;
+ sectorHeaderInfo->datalen = 0;
+ sectorHeaderInfo->fileuuid = m_eeprom_header.fileuuid++;
+ if (usrdata) memcpy(sectorHeaderInfo->usrdata, usrdata, usrdata_len);
+
+ fileHander->fileuuid = sectorHeaderInfo->fileuuid;
+ fileHander->sector_header = sectorHeaderInfo;
+ fileHander->file_offset = 0;
+ fileHander->file_size = 0;
+ return fileHander->fd;
+ }
+}
+
+int zeeprom_fs_write(int fileid, const uint8_t* data, int32_t size) {
+ ZASSERT(m_is_init);
+
+ filehandler_t* fileHander = NULL;
+ zeeprom_sector_info_t* header_sinfo = NULL;
+ zeeprom_sector_info_t* endsector = NULL;
+ int32_t wadd = 0;
+
+ ZASSERT(size == 256);
+
+ fileHander = filehandler_find(fileid);
+ if (!fileHander) {
+ ZLOGE("fileHander_find fail");
+ return -1;
+ }
+
+ header_sinfo = fileHander->sector_header;
+ if (!header_sinfo) {
+ ZLOGE("header_sinfo fail");
+ return -1;
+ }
+
+ endsector = sector_mgr_find_end_sector(fileHander->fileuuid);
+ if (!endsector) {
+ ZLOGE("sector_mgr_find_end_sector fail");
+ return -1;
+ }
+
+ if (endsector->datalen + size > EEPROM_SECTOR_SIZE) {
+ ZLOGE("endsector->datalen + size > EEPROM_SECTOR_SIZE");
+ return -1;
+ }
+
+ wadd = sector_mgr_get_sector_rom_add(endsector);
+ if (wadd < 0) {
+ ZLOGE("sector_mgr_get_sector_rom_add fail");
+ return -1;
+ }
+ ZLOGI("wadd=%d", wadd);
+ ZASSERT(wadd % 256 == 0);
+ ZASSERT(wadd >= EEPROM_SECTOR_SIZE);
+ zeeprom_write(wadd + endsector->datalen, data, size);
+
+ endsector->datalen = endsector->datalen + size;
+ fileHander->file_offset += size;
+ fileHander->file_size += size;
+
+ if (endsector->datalen == EEPROM_SECTOR_SIZE) {
+ zeeprom_sector_info_t* newsector = sector_mgr_force_find_idle_sector();
+ if (!newsector) {
+ return -1;
+ }
+
+ memset(newsector, 0, sizeof(zeeprom_sector_info_t));
+ newsector->usage = 1;
+ newsector->opened = 1;
+ memcpy(newsector->filename, header_sinfo->filename, 8);
+ newsector->sector_index_in_file = endsector->sector_index_in_file + 1;
+ newsector->datalen = 0;
+ newsector->fileuuid = header_sinfo->fileuuid;
+ }
+ return size;
+}
+
+int zeeprom_fs_close(int fileid) {
+ ZASSERT(m_is_init);
+
+ filehandler_t* fileHander = filehandler_find(fileid);
+ if (!fileHander) {
+ ZLOGE("zeeprom_fs_close fileHander_find fail");
+ return -1;
+ }
+
+ sector_mgr_close_sector(fileHander->fileuuid);
+ int32_t checksum_val = compute_checksum((uint8_t*)&m_eeprom_header, sizeof(m_eeprom_header) - sizeof(m_eeprom_header.checksum));
+ m_eeprom_header.checksum = checksum_val;
+ zeeprom_write(0, (uint8_t*)&m_eeprom_header, sizeof(m_eeprom_header));
+
+ filehandler_rlease(fileid);
+ return 0;
+}
+
+int zeeprom_fs_read(int fileid, uint8_t* data, int32_t size) {
+ ZASSERT(m_is_init);
+
+ /**
+ * @brief
+ * ҵǰ
+ */
+ ZASSERT(size == 256);
+ filehandler_t* fileHander = filehandler_find(fileid);
+ if (!fileHander) return -1;
+
+ zeeprom_sector_info_t* header_sinfo = fileHander->sector_header;
+ if (!header_sinfo) {
+ return -1;
+ }
+
+ int32_t sector_idx = fileHander->file_offset / EEPROM_SECTOR_SIZE;
+ int32_t sector_off = fileHander->file_offset % EEPROM_SECTOR_SIZE;
+
+ zeeprom_sector_info_t* sector = sector_mgr_find_sector(fileHander->fileuuid, sector_idx);
+ if (!sector) {
+ return -1;
+ }
+
+ int32_t radd = sector_mgr_get_sector_rom_add(sector);
+ ZASSERT(radd % 256 == 0);
+ radd += sector_off;
+
+ int32_t readlen = size;
+ zeeprom_read(radd, data, readlen);
+ return readlen;
+}
+
+int zeeprom_fs_delete(int32_t fileuuid) {
+ ZASSERT(m_is_init);
+
+ sector_mgr_free_sector(fileuuid);
+ return 0;
+}
+int zeeprom_fs_delete_by_name(uint8_t* filename) {
+ ZASSERT(m_is_init);
+
+ zeeprom_sector_info_t* sectorHeaderInfo = sector_mgr_find_fileheader_by_filename(filename);
+ if (sectorHeaderInfo) {
+ sector_mgr_free_sector(sectorHeaderInfo->fileuuid);
+ }
+ return 0;
+}
+
+int zeeprom_fs_get_file_num() {
+ ZASSERT(m_is_init);
+
+ int count = 0;
+ for (int i = 0; i < MAX_SECTOR_NUM; i++) {
+ zeeprom_sector_info_t* sinfo = &m_eeprom_header.sectorinfos[i];
+ if (sinfo->usage == 1 && sinfo->sector_index_in_file == 0) {
+ count++;
+ }
+ }
+ return count;
+}
+int zeeprom_fs_delete_the_oldest_file() {
+ ZASSERT(m_is_init);
+
+ int32_t earliest_file_created_index = sector_mgr_find_earliest_file_created_index();
+ sector_mgr_free_sector(earliest_file_created_index);
+ return 0;
+}
+
+int zeeprom_fs_get_filesize(int32_t fileuuid) {
+ ZASSERT(m_is_init);
+
+ return sector_mgr_file_get_size(fileuuid);
+}
+
+static void zeeprom_read(int32_t add, uint8_t* data, uint16_t len) { //
+ int wrsize = EEPROM_SECTOR_MIN_WR_SIZE;
+
+ int readTimes = len / wrsize;
+ int readRemain = len % wrsize;
+
+ for (int i = 0; i < readTimes; i++) {
+ SingleLeadECG_eeprom_read(add + i * wrsize, data + i * wrsize, wrsize);
+ }
+ if (readRemain > 0) {
+ SingleLeadECG_eeprom_read(add + readTimes * wrsize, data + readTimes * wrsize, readRemain);
+ }
+}
+static void zeeprom_write(int32_t add, const uint8_t* data, uint16_t len) {
+ int wrsize = EEPROM_SECTOR_MIN_WR_SIZE;
+
+ int writeTimes = len / wrsize;
+ int writeRemain = len % wrsize;
+
+ for (int i = 0; i < writeTimes; i++) {
+ // int pageoff = add / wrsize + i;
+ int32_t writeadd = add + i * wrsize;
+ SingleLeadECG_eeprom_write(writeadd, data + i * wrsize, wrsize);
+ }
+ if (writeRemain > 0) {
+ int32_t writeadd = add + writeTimes * wrsize;
+ SingleLeadECG_eeprom_write(writeadd, data + writeTimes * wrsize, writeRemain);
+ }
+}
+
+static int32_t compute_checksum(uint8_t* data, uint16_t len) {
+ int32_t sum = 0;
+ for (int i = 0; i < len; i++) {
+ sum += data[i];
+ }
+ return sum;
+}
+/*******************************************************************************
+ * filehandler *
+ *******************************************************************************/
+static filehandler_t* filehandler_find(int fd) {
+ for (int i = 0; i < ZARRAY_SIZE(m_filehandler); i++) {
+ if (m_filehandler[i].fd == fd) {
+ return &m_filehandler[i];
+ }
+ }
+ return NULL;
+}
+static filehandler_t* filehandler_alloc() {
+ for (int i = 0; i < ZARRAY_SIZE(m_filehandler); i++) {
+ if (m_filehandler[i].fd == 0) {
+ m_filehandler[i].fd = ++m_fd_off;
+ return &m_filehandler[i];
+ }
+ }
+ return NULL;
+}
+static void filehandler_rlease(int fd) {
+ for (int i = 0; i < ZARRAY_SIZE(m_filehandler); i++) {
+ if (m_filehandler[i].fd == fd) {
+ m_filehandler[i].fd = 0;
+ return;
+ }
+ }
+}
+/*******************************************************************************
+ * sector_mgr *
+ *******************************************************************************/
+
+// 紴ļfile_created_index
+static int32_t sector_mgr_find_earliest_file_created_index() {
+ int32_t earliest_file_created_index = 0xFFFFFFFF;
+ for (int i = 0; i < MAX_SECTOR_NUM; i++) {
+ zeeprom_sector_info_t* sinfo = &m_eeprom_header.sectorinfos[i];
+ if (sinfo->usage == 1) {
+ if (sinfo->fileuuid < earliest_file_created_index) {
+ earliest_file_created_index = sinfo->fileuuid;
+ }
+ }
+ }
+ return earliest_file_created_index;
+}
+// ɾļ
+static int32_t sector_mgr_free_sector(int32_t fileuuid) {
+ for (int i = 0; i < MAX_SECTOR_NUM; i++) {
+ zeeprom_sector_info_t* sinfo = &m_eeprom_header.sectorinfos[i];
+ if (sinfo->usage == 1 && sinfo->fileuuid == fileuuid) {
+ sinfo->usage = 0;
+ }
+ }
+ return 0;
+}
+//
+static zeeprom_sector_info_t* sector_mgr_find_idle_sector() {
+ for (int i = 0; i < MAX_SECTOR_NUM; i++) {
+ zeeprom_sector_info_t* sinfo = &m_eeprom_header.sectorinfos[i];
+ if (sinfo->usage == 0) {
+ return sinfo;
+ }
+ }
+ return NULL;
+}
+static bool sector_mgr_sector_is_open(int32_t fileuuid) {
+ for (int i = 0; i < MAX_SECTOR_NUM; i++) {
+ zeeprom_sector_info_t* sinfo = &m_eeprom_header.sectorinfos[i];
+ if (sinfo->usage == 1 && sinfo->fileuuid == fileuuid) {
+ return sinfo->opened;
+ }
+ }
+ return false;
+}
+
+static zeeprom_sector_info_t* sector_mgr_force_find_idle_sector() {
+ /**
+ * @brief ҿ
+ */
+ zeeprom_sector_info_t* ret_sinfo = sector_mgr_find_idle_sector();
+ if (ret_sinfo) return ret_sinfo;
+ /**
+ * @brief 紴ļ
+ */
+ int32_t earliest_file_created_index = sector_mgr_find_earliest_file_created_index();
+
+ if (sector_mgr_sector_is_open(earliest_file_created_index)) {
+ return NULL;
+ }
+
+ /**
+ * @brief ɾ紴ļ
+ */
+ sector_mgr_free_sector(earliest_file_created_index);
+
+ /**
+ * @brief ²ҿ
+ */
+ ret_sinfo = sector_mgr_find_idle_sector();
+ if (ret_sinfo) return ret_sinfo;
+
+ return NULL;
+}
+
+static void sector_mgr_open_sector(int32_t fileuuid) {
+ for (int i = 0; i < MAX_SECTOR_NUM; i++) {
+ zeeprom_sector_info_t* sinfo = &m_eeprom_header.sectorinfos[i];
+ if (sinfo->usage == 1 && sinfo->fileuuid == fileuuid) {
+ sinfo->opened = true;
+ }
+ }
+}
+
+static void sector_mgr_close_sector(int32_t fileuuid) {
+ for (int i = 0; i < MAX_SECTOR_NUM; i++) {
+ zeeprom_sector_info_t* sinfo = &m_eeprom_header.sectorinfos[i];
+ if (sinfo->usage == 1 && sinfo->fileuuid == fileuuid) {
+ sinfo->opened = false;
+ }
+ }
+}
+
+// static zeeprom_sector_info_t* sector_mgr_find_fileheader(int32_t fileuuid) {
+// for (int i = 0; i < MAX_SECTOR_NUM; i++) {
+// zeeprom_sector_info_t* sinfo = &m_eeprom_header.sectorinfos[i];
+// if (sinfo->usage == 1 && sinfo->sector_index_in_file == 0 && sinfo->fileuuid == fileuuid) {
+// return sinfo;
+// }
+// }
+// return NULL;
+// }
+
+static zeeprom_sector_info_t* sector_mgr_find_sector(int32_t fileuuid, int32_t sector_index_in_file) {
+ for (int i = 0; i < MAX_SECTOR_NUM; i++) {
+ zeeprom_sector_info_t* sinfo = &m_eeprom_header.sectorinfos[i];
+ if (sinfo->usage == 1 && sinfo->sector_index_in_file == sector_index_in_file && sinfo->fileuuid == fileuuid) {
+ return sinfo;
+ }
+ }
+ return NULL;
+}
+
+static zeeprom_sector_info_t* sector_mgr_find_end_sector(int32_t fileuuid) {
+ int32_t maxsectorindex = 0;
+ for (int i = 0; i < MAX_SECTOR_NUM; i++) {
+ zeeprom_sector_info_t* sinfo = &m_eeprom_header.sectorinfos[i];
+ if (sinfo->usage == 1 && sinfo->fileuuid == fileuuid) {
+ if (sinfo->sector_index_in_file >= maxsectorindex) {
+ maxsectorindex = sinfo->sector_index_in_file;
+ }
+ }
+ }
+ return sector_mgr_find_sector(fileuuid, maxsectorindex);
+}
+
+static zeeprom_sector_info_t* sector_mgr_find_fileheader_by_filename(uint8_t* fileid) {
+ for (int i = 0; i < MAX_SECTOR_NUM; i++) {
+ zeeprom_sector_info_t* sinfo = &m_eeprom_header.sectorinfos[i];
+ if (sinfo->usage == 1 && sinfo->sector_index_in_file == 0 && memcmp(sinfo->filename, fileid, 8) == 0) {
+ return sinfo;
+ }
+ }
+ return NULL;
+}
+
+static int32_t sector_mgr_get_sector_offset(zeeprom_sector_info_t* sector) {
+ for (int i = 0; i < MAX_SECTOR_NUM; i++) {
+ zeeprom_sector_info_t* sinfo = &m_eeprom_header.sectorinfos[i];
+ if (sinfo == sector) {
+ return i;
+ }
+ }
+ return -1;
+}
+
+static int32_t sector_mgr_get_sector_rom_add(zeeprom_sector_info_t* sector) {
+ int32_t offset = sector_mgr_get_sector_offset(sector);
+ if (offset < 0) return -1;
+ return (offset + 1) * EEPROM_SECTOR_SIZE;
+}
+
+static int32_t sector_mgr_file_get_size(int32_t fileuuid) {
+ int32_t filesize = 0;
+ for (int i = 0; i < MAX_SECTOR_NUM; i++) {
+ zeeprom_sector_info_t* sinfo = &m_eeprom_header.sectorinfos[i];
+
+ if (sinfo->usage == 1 && sinfo->fileuuid == fileuuid) {
+ filesize += sinfo->datalen;
+ }
+ }
+ return filesize;
+}
+
+static const char* filename2str(uint8_t* filename) {
+ static char filename_str[32];
+ sprintf(filename_str, "%02x%02x%02x%02x%02x%02x%02x%02x", filename[0], filename[1], filename[2], filename[3], filename[4], filename[5], filename[6], filename[7]);
+ return filename_str;
+}
+
+int zeeprom_fs_dump_sector_state() {
+ ZLOGI_BLOCK("zeeprom_fs_dump_sector_state\n");
+ for (int i = 0; i < MAX_SECTOR_NUM; i++) {
+ zeeprom_sector_info_t* sinfo = &m_eeprom_header.sectorinfos[i];
+#if 0
+ uint8_t usage;
+ uint8_t opened;
+ uint8_t filename[8]; // עļΪ̶˸ֽڵĶݣַ
+ int32_t sector_index_in_file; // ǰļݵʼַ
+ int32_t datalen; // ǰļݵij
+ int32_t fileuuid; // indexжļȺ˳ͬʱҲ൱ļΨһʶ
+ uint8_t usrdata[20];
+#endif
+
+ if (sinfo->usage == 1) {
+ ZLOGI_BLOCK("[%d]: usage=%d opened=%d", i, sinfo->usage, sinfo->opened);
+ ZLOGI_BLOCK(" fname=%s, index_in_file=%d, datalen=%d, fileuuid=%d\n", filename2str(sinfo->filename), sinfo->sector_index_in_file, sinfo->datalen, sinfo->fileuuid);
+ } else {
+ ZLOGI_BLOCK("[%d]: usage=%d\n", i, sinfo->usage);
+ }
+ }
+ return 0;
+}
diff --git a/app/src/one_conduction/zeeprom_fs.h b/app/src/one_conduction/zeeprom_fs.h
new file mode 100644
index 0000000..360dea2
--- /dev/null
+++ b/app/src/one_conduction/zeeprom_fs.h
@@ -0,0 +1,60 @@
+#pragma once
+#include
+
+#define EEPROM_SIZE (256 * 1024)
+#define EEPROM_SECTOR_MIN_WR_SIZE (256)
+#define EEPROM_SECTOR_SIZE (8 * 1024)
+#define MAX_SECTOR_NUM (EEPROM_SIZE / EEPROM_SECTOR_SIZE - 1)
+#define EEPROM_FILE_SIZE (EEPROM_SECTOR_SIZE * MAX_SECTOR_NUM)
+
+//
+#pragma pack(1)
+typedef struct {
+ uint8_t usage;
+ uint8_t opened;
+ uint8_t filename[8]; // עļΪ̶˸ֽڵĶݣַ
+ int32_t sector_index_in_file; // ǰļݵʼַ
+ int32_t datalen; // ǰļݵij
+ int32_t fileuuid; // indexжļȺ˳ͬʱҲ൱ļΨһʶ
+ uint8_t usrdata[20];
+} zeeprom_sector_info_t;
+
+typedef struct {
+ uint8_t filename[8];
+ uint8_t usrdata[20];
+
+ zeeprom_sector_info_t* sector_header;
+ int32_t file_offset;
+ int32_t file_size;
+
+ int fd;
+ int32_t fileuuid;
+} filehandler_t;
+
+typedef struct {
+ zeeprom_sector_info_t sectorinfos[MAX_SECTOR_NUM];
+ int32_t fileuuid;
+ int32_t checksum;
+} zeeprom_header_t;
+#pragma pack()
+
+int zeeprom_fs_init();
+int zeeprom_fs_uinit();
+
+zeeprom_header_t* zeeprom_fs_get_header();
+
+int zeeprom_fs_open(uint8_t* filename, uint8_t* usrdata[], uint8_t usrdata_len);
+int zeeprom_fs_close(int fileid);
+
+int zeeprom_fs_write(int fileid, const uint8_t* data, int32_t size);
+int zeeprom_fs_read(int fileid, uint8_t* data, int32_t size);
+
+int zeeprom_fs_get_filesize(int32_t fileuuid);
+
+int zeeprom_fs_get_file_num();
+int zeeprom_fs_delete_the_oldest_file();
+int zeeprom_fs_delete(int32_t fileuuid);
+int zeeprom_fs_delete_by_name(uint8_t* filename);
+
+int zeeprom_fs_dump_sector_state();
+
diff --git a/libznordic b/libznordic
index 75bac49..c019696 160000
--- a/libznordic
+++ b/libznordic
@@ -1 +1 @@
-Subproject commit 75bac4942446a40e70c2e5d1cbfe5171a869fd69
+Subproject commit c0196969d9981245400057e8c8ef8567fc6c93ab
diff --git a/sdk b/sdk
index 869a0e4..4518670 160000
--- a/sdk
+++ b/sdk
@@ -1 +1 @@
-Subproject commit 869a0e4412889897e7ae801ae96e4491f0897798
+Subproject commit 45186701cdfa870204e0975dbf12a0feb50be71d