|
@@ -67,7 +67,8 @@ int nv_read_sn(uint8_t *sn, int len){
|
|
|
memcpy(sn, sn_info.sn, sn_info.len);
|
|
memcpy(sn, sn_info.sn, sn_info.len);
|
|
|
return sn_info.len;
|
|
return sn_info.len;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+static int _soc_write_error = 0;
|
|
|
|
|
+static int _soc_write_success = 0;
|
|
|
/* soc 保存,拆分每次保存一个byte,确保e2rom写操作不会占用太长时间 */
|
|
/* soc 保存,拆分每次保存一个byte,确保e2rom写操作不会占用太长时间 */
|
|
|
void nv_save_soc(void){
|
|
void nv_save_soc(void){
|
|
|
#if 0
|
|
#if 0
|
|
@@ -87,13 +88,21 @@ void nv_save_soc(void){
|
|
|
#endif
|
|
#endif
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+void nv_storage_log(void) {
|
|
|
|
|
+ state_debug("soc nv write: %d\n", _soc_write_success, _soc_write_error);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
static void nv_save_soc_task(shark_timer_t *timer){
|
|
static void nv_save_soc_task(shark_timer_t *timer){
|
|
|
if (soc_write_pending == 0) {
|
|
if (soc_write_pending == 0) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
if (soc_write_index < sizeof(soc_data)){
|
|
if (soc_write_index < sizeof(soc_data)){
|
|
|
- AT24CXX_Write(SOC_ADDR + SOC_SIZE * soc_write_backup_index + soc_write_index, soc_data + soc_write_index, 1);
|
|
|
|
|
- soc_write_index ++;
|
|
|
|
|
|
|
+ if (AT24CXX_Write(SOC_ADDR + SOC_SIZE * soc_write_backup_index + soc_write_index, soc_data + soc_write_index, 1) == 1) {
|
|
|
|
|
+ soc_write_index ++;
|
|
|
|
|
+ _soc_write_success ++;
|
|
|
|
|
+ }else {
|
|
|
|
|
+ _soc_write_error ++;
|
|
|
|
|
+ }
|
|
|
}else {
|
|
}else {
|
|
|
soc_write_index = 0;
|
|
soc_write_index = 0;
|
|
|
soc_write_backup_index ++;
|
|
soc_write_backup_index ++;
|