P2 #8

Merged
sundp merged 18 commits from P2 into master 2024-09-20 14:41:45 +08:00
1 changed files with 24 additions and 24 deletions
Showing only changes of commit 25fef2cd4c - Show all commits

View File

@ -76,7 +76,7 @@ volatile sts_cfg_nvm_t sts_cfg_nvm = {
}, // above 20 bytes
0x00, //reserve2
0x00, //reserve3
0x20, //sensor install height in 10 cm, default 32*10=320cm, 3.2meter
0x20, //sensor install height in dm =10 cm, default 32*10=320cm, 3.2meter
0x00, //reserve5 alarm_parameter05
0x06, //reserve6 alarm_mute_or_reset_expire_timer_in_10sec, 60 seconds
@ -92,6 +92,7 @@ volatile sts_cfg_nvm_t sts_cfg_nvm = {
// below 20 bytes for RFAC code
{0x0,0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,0x0}
};
static uint8_t nvm_store_value[YUNHORN_STS_MAX_NVM_CFG_SIZE]={0x0};
volatile uint8_t sts_ac_code[20]={0x0};
volatile uint8_t sts_service_mask=STS_SERVICE_MASK_L0;
volatile uint8_t sts_work_mode=4;
@ -1334,7 +1335,7 @@ void OnStoreSTSCFGContextRequest(void)
{
/* USER CODE BEGIN OnStoreContextRequest_1 */
uint8_t nvm_store_value[YUNHORN_STS_MAX_NVM_CFG_SIZE]={0x0},i=0,j=0;
uint8_t i=0,j=0;
#if 1
sts_cfg_nvm.length = STS_NVM_CFG_SIZE;
nvm_store_value[i++] = sts_cfg_nvm.mtmcode1;
@ -1409,14 +1410,13 @@ void OnRestoreSTSCFGContextRequest(uint8_t *cfg_in_nvm)
void STS_REBOOT_CONFIG_Init(void)
{
/* USER CODE BEGIN OnRestoreContextRequest_1 */
uint8_t nvm_stored_value[YUNHORN_STS_MAX_NVM_CFG_SIZE]={0x0};
/* USER CODE END OnRestoreContextRequest_1 */
UTIL_MEM_cpy_8(nvm_stored_value, (void *)STS_CONFIG_NVM_BASE_ADDRESS, YUNHORN_STS_MAX_NVM_CFG_SIZE);
UTIL_MEM_cpy_8(nvm_store_value, (void *)STS_CONFIG_NVM_BASE_ADDRESS, YUNHORN_STS_MAX_NVM_CFG_SIZE);
/* USER CODE BEGIN OnRestoreContextRequest_Last */
if ((nvm_stored_value[NVM_MTM1] != sts_mtmcode1) || (nvm_stored_value[NVM_MTM2] != sts_mtmcode2) || (nvm_stored_value[NVM_VER] != sts_version))
if ((nvm_store_value[NVM_MTM1] != sts_mtmcode1) || (nvm_store_value[NVM_MTM2] != sts_mtmcode2) || (nvm_store_value[NVM_VER] != sts_version))
{
APP_LOG(TS_OFF, VLEVEL_H, "\r\nInitial Boot with Empty Config, Flash with default config....\r\n");
OnStoreSTSCFGContextRequest();
@ -1425,33 +1425,33 @@ void STS_REBOOT_CONFIG_Init(void)
} else
{
#if 0
sts_cfg_nvm.mtmcode1 = (uint8_t)nvm_stored_value[NVM_MTM1];
sts_cfg_nvm.mtmcode2 = (uint8_t)nvm_stored_value[NVM_MTM2];
sts_cfg_nvm.version = (uint8_t)nvm_stored_value[NVM_VER];
sts_cfg_nvm.hardware_ver = (uint8_t)nvm_stored_value[NVM_HWV];
sts_cfg_nvm.periodicity = (uint8_t)(nvm_stored_value[NVM_PERIODICITY]); //TxPeriodicity interval
sts_cfg_nvm.unit = (uint8_t)(nvm_stored_value[NVM_UNIT]);
sts_cfg_nvm.sampling = (uint8_t)(nvm_stored_value[NVM_SAMPLING]); //Heart-beat or sampling interval
sts_cfg_nvm.s_unit = (uint8_t)(nvm_stored_value[NVM_S_UNIT]);
sts_cfg_nvm.work_mode = (uint8_t)(nvm_stored_value[NVM_WORK_MODE]);
sts_cfg_nvm.sts_service_mask = (uint8_t)(nvm_stored_value[NVM_SERVICE_MASK]);
sts_cfg_nvm.sts_ioc_mask = (uint8_t)(nvm_stored_value[NVM_IOC_MASK]);
sts_cfg_nvm.length = (uint8_t)(nvm_stored_value[NVM_LEN]&0x3F); //MAX 32 bytes
sts_cfg_nvm.mtmcode1 = (uint8_t)nvm_store_value[NVM_MTM1];
sts_cfg_nvm.mtmcode2 = (uint8_t)nvm_store_value[NVM_MTM2];
sts_cfg_nvm.version = (uint8_t)nvm_store_value[NVM_VER];
sts_cfg_nvm.hardware_ver = (uint8_t)nvm_store_value[NVM_HWV];
sts_cfg_nvm.periodicity = (uint8_t)(nvm_store_value[NVM_PERIODICITY]); //TxPeriodicity interval
sts_cfg_nvm.unit = (uint8_t)(nvm_store_value[NVM_UNIT]);
sts_cfg_nvm.sampling = (uint8_t)(nvm_store_value[NVM_SAMPLING]); //Heart-beat or sampling interval
sts_cfg_nvm.s_unit = (uint8_t)(nvm_store_value[NVM_S_UNIT]);
sts_cfg_nvm.work_mode = (uint8_t)(nvm_store_value[NVM_WORK_MODE]);
sts_cfg_nvm.sts_service_mask = (uint8_t)(nvm_store_value[NVM_SERVICE_MASK]);
sts_cfg_nvm.sts_ioc_mask = (uint8_t)(nvm_store_value[NVM_IOC_MASK]);
sts_cfg_nvm.length = (uint8_t)(nvm_store_value[NVM_LEN]&0x3F); //MAX 32 bytes
for (uint8_t j=0; j< sts_cfg_nvm.length; j++) {
sts_cfg_nvm.p[j] = (uint8_t)nvm_stored_value[NVM_CFG_START+j];
sts_cfg_nvm.p[j] = (uint8_t)nvm_store_value[NVM_CFG_START+j];
}
sts_cfg_nvm.fall_detection_acc_threshold = (uint8_t)nvm_stored_value[NVM_FALL_DETECTION_ACC_THRESHOLD];
sts_cfg_nvm.fall_detection_depth_threshold = (uint8_t)nvm_stored_value[NVM_FALL_DETECTION_DEPTH_THRESHOLD];
sts_cfg_nvm.fall_detection_reserve = (uint8_t)nvm_stored_value[NVM_FALL_DETECTION_RESERVE];
sts_cfg_nvm.occupancy_overtime_threshold = (uint8_t)nvm_stored_value[NVM_OCCUPANCY_OVERTIME_THRESHOLD];
sts_cfg_nvm.fall_detection_acc_threshold = (uint8_t)nvm_store_value[NVM_FALL_DETECTION_ACC_THRESHOLD];
sts_cfg_nvm.fall_detection_depth_threshold = (uint8_t)nvm_store_value[NVM_FALL_DETECTION_DEPTH_THRESHOLD];
sts_cfg_nvm.fall_detection_reserve = (uint8_t)nvm_store_value[NVM_FALL_DETECTION_RESERVE];
sts_cfg_nvm.occupancy_overtime_threshold = (uint8_t)nvm_store_value[NVM_OCCUPANCY_OVERTIME_THRESHOLD];
for (uint8_t j=0; j< YUNHORN_STS_AC_CODE_SIZE; j++) {
sts_cfg_nvm.ac[j] = (uint8_t)nvm_stored_value[NVM_AC_CODE_START +j];
sts_cfg_nvm.ac[j] = (uint8_t)nvm_store_value[NVM_AC_CODE_START +j];
}
#endif
UTIL_MEM_cpy_8((void*) &sts_cfg_nvm, (void*)nvm_stored_value, YUNHORN_STS_MAX_NVM_CFG_SIZE);
UTIL_MEM_cpy_8((void*) &sts_cfg_nvm, (void*)nvm_store_value, YUNHORN_STS_MAX_NVM_CFG_SIZE);
}
OnRestoreSTSCFGContextProcess();