From 295cc6981e5fca0f958c7aef06ee9cf8f25a762c Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Sun, 20 Dec 2020 11:32:47 +0200 Subject: Version 1.6.0 mostly changes in flash and EEPROM --- .../Embedded_SW/Embedded/Modules/General/process.c | 34 ++++++++++++++-------- 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/General/process.c') diff --git a/Software/Embedded_SW/Embedded/Modules/General/process.c b/Software/Embedded_SW/Embedded/Modules/General/process.c index 807e9f8e9..137b5a19f 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/process.c +++ b/Software/Embedded_SW/Embedded/Modules/General/process.c @@ -124,9 +124,11 @@ uint32_t HandleProcessParameters(ProcessParameters* ProcessParams,bool saveData) { Bytes = sizeof(ProcessParameters); FileWrite(ProcessParams,Bytes,ProcessParamsConfigPath,BIOS_WAIT_FOREVER); - EraseFlashSection(PROCESS_PARAMETERS_MAP_IN_FLASH); + MCU_E2PromProgramChunk(PROCESS_PARAMATERS_IN_EEPROM,4,&Bytes); + MCU_E2PromProgramChunk(PROCESS_PARAMATERS_IN_EEPROM+4, Bytes, ProcessParams); + /*EraseFlashSection(PROCESS_PARAMETERS_MAP_IN_FLASH); ReadAppAndProgram(PROCESS_PARAMETERS_MAP_IN_FLASH, 4,&Bytes); - ReadAppAndProgram(PROCESS_PARAMETERS_MAP_IN_FLASH+4, Bytes, ProcessParams); + ReadAppAndProgram(PROCESS_PARAMETERS_MAP_IN_FLASH+4, Bytes, ProcessParams);*/ REPORT_MSG(Bytes,"Bytes write to flash"); } else @@ -386,9 +388,11 @@ uint32_t LoadProcessParamsFromFile(void) if ((ProcessParams->dryerzone1temp > 0.1)||(ProcessParams->headzone2temp > 0.1)||(ProcessParams->headzone3temp > 0.1)||(ProcessParams->headzone4temp > 0.1))//NOT turning off heaters { Bytes = sizeof(ProcessParameters); - EraseFlashSection(PROCESS_PARAMETERS_MAP_IN_FLASH); + MCU_E2PromProgramChunk(PROCESS_PARAMATERS_IN_EEPROM,4,&Bytes); + MCU_E2PromProgramChunk(PROCESS_PARAMATERS_IN_EEPROM+4, Bytes, ProcessParams); + /*EraseFlashSection(PROCESS_PARAMETERS_MAP_IN_FLASH); ReadAppAndProgram(PROCESS_PARAMETERS_MAP_IN_FLASH, 4,&Bytes); - ReadAppAndProgram(PROCESS_PARAMETERS_MAP_IN_FLASH+4, Bytes, ProcessParams); + ReadAppAndProgram(PROCESS_PARAMETERS_MAP_IN_FLASH+4, Bytes, ProcessParams);*/ REPORT_MSG(Bytes,"ProcessParameters Bytes write to flash"); free (buffer); } @@ -406,26 +410,32 @@ uint32_t ProcessParamsInit(void) { FRESULT Fresult = FR_NOT_READY; uint32_t Bytes; + ProcessParameters ProcessParams; - memcpy(&Bytes,(void *)PROCESS_PARAMETERS_MAP_IN_FLASH,sizeof(Bytes)); - REPORT_MSG(Bytes,"Bytes read from flash"); + //memcpy(&Bytes,(void *)PROCESS_PARAMETERS_MAP_IN_FLASH,sizeof(Bytes)); + MCU_E2PromReadChunk(PROCESS_PARAMATERS_IN_EEPROM,4,&Bytes); + + REPORT_MSG(Bytes,"Bytes read from EEPROM"); if ((Bytes)&&(Bytes < 1000)) { - ProcessParameters* ProcessParams = (ProcessParameters *)(PROCESS_PARAMETERS_MAP_IN_FLASH+4); - Fresult = HandleProcessParameters(ProcessParams,false); + //ProcessParameters* ProcessParams = (ProcessParameters *)(PROCESS_PARAMETERS_MAP_IN_FLASH+4); + MCU_E2PromReadChunk(PROCESS_PARAMATERS_IN_EEPROM+4,Bytes,&ProcessParams); + Fresult = HandleProcessParameters(&ProcessParams,false); } else { if (LoadProcessParamsFromFile()==OK) { - memcpy(&Bytes,(void *)PROCESS_PARAMETERS_MAP_IN_FLASH,sizeof(Bytes)); - REPORT_MSG(Bytes,"ProcessParams Bytes read from flash"); + MCU_E2PromReadChunk(PROCESS_PARAMATERS_IN_EEPROM,4,&Bytes); + //memcpy(&Bytes,(void *)PROCESS_PARAMETERS_MAP_IN_FLASH,sizeof(Bytes)); + REPORT_MSG(Bytes,"ProcessParams Bytes read from EEPROM"); if ((Bytes)&&(Bytes < 1000)) { - ProcessParameters* ProcessParams = (ProcessParameters *)(PROCESS_PARAMETERS_MAP_IN_FLASH+4); - Fresult = HandleProcessParameters(ProcessParams,false); + MCU_E2PromReadChunk(PROCESS_PARAMATERS_IN_EEPROM+4,Bytes,&ProcessParams); + //ProcessParameters* ProcessParams = (ProcessParameters *)(PROCESS_PARAMETERS_MAP_IN_FLASH+4); + Fresult = HandleProcessParameters(&ProcessParams,false); } } } -- cgit v1.3.1