Обновление

This commit is contained in:
cfif 2025-10-29 11:17:05 +03:00
parent baf09ee366
commit 12283d586a
2 changed files with 59 additions and 30 deletions

View File

@ -8,6 +8,7 @@
#include "DataNonVolatile.h" #include "DataNonVolatile.h"
#include "StorageOnFlashFlagchip.h" #include "StorageOnFlashFlagchip.h"
#include "SystemDelayInterface.h" #include "SystemDelayInterface.h"
#include "HVAC_preDefine.h"
#define LOGGER env->logger #define LOGGER env->logger
#define LOG_SIGN "Хран." #define LOG_SIGN "Хран."
@ -21,44 +22,65 @@ void DeviceStorage_InitVariablesTable(tDeviceStorage *env) {
DeviceDataRuntime_InitDefaults(&env->runtime); DeviceDataRuntime_InitDefaults(&env->runtime);
DeviceDataNonVolatile_AddToVarTab(env->nvm, &env->publicVariablesTable, VARIABLE_GROUP_FLASH); DeviceDataNonVolatile_AddToVarTab(env->dataParam, &env->publicVariablesTable, VARIABLE_GROUP_FLASH);
DeviceDataRuntime_AddToVarTab(&env->runtime, &env->publicVariablesTable, VARIABLE_GROUP_UNTRACKED); DeviceDataRuntime_AddToVarTab(&env->runtime, &env->publicVariablesTable, VARIABLE_GROUP_UNTRACKED);
} }
bool DeviceStorage_LoadNonVolatile(tDeviceStorage *env) { bool DeviceStorage_LoadParam(tDeviceStorage *env) {
bool isLoad = VarsTabDumpObserver_Load(&env->dumpObserver); bool isLoad = VarsTabDumpObserverParam_Load(&env->dumpObserver);
if (isLoad) { if (isLoad) {
if (env->nvm->version == DEVICE_DATA_NO_VOLATILE_VERSION) { if (env->dataParam->version == DEVICE_DATA_NO_VOLATILE_VERSION) {
return true; return true;
} }
} }
LoggerInfoStatic(LOGGER, LOG_SIGN, "Сброс настроек"); LoggerInfoStatic(LOGGER, LOG_SIGN, "Параметры. Сброс настроек");
DeviceDataNonVolatile_InitDefaults(env->nvm); DeviceDataParam_InitDefaults(env->dataParam);
return VarsTabDumpObserver_Dump(&env->dumpObserver); return VarsTabDumpObserverParam_Dump(&env->dumpObserver);
}
bool DeviceStorage_LoadCalib(tDeviceStorage *env) {
bool isLoad = VarsTabDumpObserverCalib_Load(&env->dumpObserver);
if (isLoad) {
if (env->dataParam->version == DEVICE_DATA_NO_VOLATILE_VERSION) {
return true;
}
}
LoggerInfoStatic(LOGGER, LOG_SIGN, "Калибровки. Сброс настроек");
DeviceDataCalib_InitDefaults(env->dataCalib);
return VarsTabDumpObserverCalib_Dump(&env->dumpObserver);
} }
void DeviceStorage_ForceDump(tDeviceStorage *env) { void DeviceStorage_ForceDump(tDeviceStorage *env) {
VarsTabDumpObserver_Dump(&env->dumpObserver); VarsTabDumpObserverParam_Dump(&env->dumpObserver);
} }
void DeviceStorage_DelayedDump(tDeviceStorage *env) { void DeviceStorage_DelayedDump(tDeviceStorage *env) {
env->publicVariablesTable.changes = 1; env->publicVariablesTable.changes = 1;
} }
void DeviceStorage_InitCommon(tDeviceStorage *env, tStorageInterface *storageInterface) { void DeviceStorage_InitCommon(tDeviceStorage *env, tStorageInterface *storageCalibInterface, size_t sizeCalib,
tStorageInterface *storageParamInterface, size_t sizeParam ) {
VarsTabDumpObserver_Init( VarsTabDumpObserver_Init(
&env->dumpObserver, &env->dumpObserver,
storageInterface, storageCalibInterface,
storageParamInterface,
5000, 5000,
env->nvm, env->dataCalib,
// sizeof(env->nvm), env->dataParam,
16000, sizeCalib,
sizeParam,
&env->publicVariablesTable, &env->publicVariablesTable,
VARIABLE_GROUP_FLASH VARIABLE_GROUP_FLASH
); );
@ -68,16 +90,22 @@ void DeviceStorage_InitCommon(tDeviceStorage *env, tStorageInterface *storageInt
} }
void DeviceStorage_InitDefaults(tDeviceStorage *env) { SECT_SRAM_NVM uint8_t dataReservedParamStore[2 * FLASH_PAGE_SIZE];
DeviceStorage_InitCommon(env, NULL); extern uint32_t __caldata_start[];
DeviceDataNonVolatile_InitDefaults(env->nvm);
} bool DeviceStorage_Init(tDeviceStorage *env, tStorageInterface *storageCalibInterface, tStorageInterface *storageParamInterface) {
env->dataParam = (tDeviceDataNonVolatile *) dataReservedParamStore;
uint8_t dataReservedStore[16000]; env->dataCalib = (void *)__caldata_start;
bool DeviceStorage_Init(tDeviceStorage *env, tStorageInterface *storageInterface) { DeviceStorage_InitCommon(env, storageParamInterface, sizeof(dataReservedParamStore),
env->nvm = (tDeviceDataNonVolatile *) dataReservedStore; storageCalibInterface, 7 * FLASH_PAGE_SIZE);
DeviceStorage_InitCommon(env, storageInterface); bool resultParam = DeviceStorage_LoadParam(env);
return DeviceStorage_LoadNonVolatile(env); bool resultCalib = DeviceStorage_LoadCalib(env);
if ((resultParam) && (resultCalib)) {
return true;
}
return false;
} }

View File

@ -17,20 +17,21 @@
typedef struct { typedef struct {
tLoggerInterface *logger; tLoggerInterface *logger;
tDeviceDataRuntime runtime; tDeviceDataRuntime runtime;
tDeviceDataNonVolatile *nvm; tDeviceDataNonVolatile *dataParam;
void *dataCalib;
tVariablesTable publicVariablesTable; tVariablesTable publicVariablesTable;
tVarsTabDumpObserver dumpObserver; tVarsTabDumpObserver dumpObserver;
struct { struct {
tVariableDescriptor vartab[50]; tVariableDescriptor vartab[50];
} mem; } mem;
} tDeviceStorage; } tDeviceStorage;
bool DeviceStorage_Init(tDeviceStorage *env, tStorageInterface *storageInterface); bool DeviceStorage_Init(tDeviceStorage *env, tStorageInterface *storageCalibInterface, tStorageInterface *storageParamInterface);
void DeviceStorage_InitDefaults(tDeviceStorage *env);
void DeviceStorage_ForceDump(tDeviceStorage *env); void DeviceStorage_ForceDump(tDeviceStorage *env);
void DeviceStorage_DelayedDump(tDeviceStorage *env); void DeviceStorage_DelayedDump(tDeviceStorage *env);