aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules/General
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-12-21 04:36:23 +0200
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-12-21 04:36:23 +0200
commit7b6ec0a4e66a4402d5ee0beb4b34b18604e28cd8 (patch)
tree532466e4c88eef1ddc9b9b68b75e4c90a1ab45b9 /Software/Embedded_SW/Embedded/Modules/General
parent4ccaf0b3f68b3675a8527df349b3bc4b5b566682 (diff)
parent3f3d743a3f93c17571b681df94d4d9d1848614fa (diff)
downloadTango-7b6ec0a4e66a4402d5ee0beb4b34b18604e28cd8.tar.gz
Tango-7b6ec0a4e66a4402d5ee0beb4b34b18604e28cd8.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/General')
-rw-r--r--Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c124
-rw-r--r--Software/Embedded_SW/Embedded/Modules/General/process.c34
2 files changed, 66 insertions, 92 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c
index 010fc9607..4c727d377 100644
--- a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c
+++ b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c
@@ -105,33 +105,19 @@ uint32_t HWConfigurationInit(void)
GeneralHwReady = false;
//Control_WD(ENABLE,250);
- memcpy(&Bytes,(void *)GENHWCFG_MAP_IN_FLASH,sizeof(Bytes));
-
- if ((Bytes)&&(Bytes < 5000))
+ buffer = HWConfigurationLoadFromFile(&Bytes); //load hardware config
+ if (buffer)
{
- buffer = my_malloc (Bytes);
- if (buffer)
- {
- memcpy(buffer, (void *)(GENHWCFG_MAP_IN_FLASH+4),Bytes);
- UploadRequest = upload_hardware_configuration_request__unpack(NULL, Bytes, buffer);
- Report("HWConfigurationInit from flash", __FILE__,__LINE__,Bytes, RpMessage, UploadRequest->hardwareconfiguration->n_dancers, 0);
- }
+ //EraseFlashSection(GENHWCFG_SECTION_FLASH);
+ //ReadAppAndProgram(GENHWCFG_MAP_IN_FLASH, 4,&Bytes);
+ //ReadAppAndProgram(GENHWCFG_MAP_IN_FLASH+4, Bytes, buffer);
+ UploadRequest = upload_hardware_configuration_request__unpack(NULL, Bytes, buffer);
+ Report("HWConfigurationInit from file", __FILE__,__LINE__,Bytes, RpMessage, UploadRequest->hardwareconfiguration->n_dancers, 0);
+ //AlarmHandlingLoadFile();
}
- if (UploadRequest == NULL)
- {
- buffer = HWConfigurationLoadFromFile(&Bytes); //load hardware config
- if (buffer)
- {
- EraseFlashSection(GENHWCFG_SECTION_FLASH);
- ReadAppAndProgram(GENHWCFG_MAP_IN_FLASH, 4,&Bytes);
- ReadAppAndProgram(GENHWCFG_MAP_IN_FLASH+4, Bytes, buffer);
- UploadRequest = upload_hardware_configuration_request__unpack(NULL, Bytes, buffer);
- Report("HWConfigurationInit from file", __FILE__,__LINE__,Bytes, RpMessage, UploadRequest->hardwareconfiguration->n_dancers, 0);
- }
- else
- Report("HWConfigurationInit Not available", __FILE__,__LINE__,Bytes, RpMessage, 0, 0);
+ else
+ Report("HWConfigurationInit Not available", __FILE__,__LINE__,Bytes, RpMessage, 0, 0);
- }
//buffer = HWConfigurationLoadFromFile(&Bytes);
//status= memcmp(buffer,buffer1,Bytes);
@@ -323,9 +309,10 @@ uint32_t EmbeddedParametersInit(void)
FRESULT Fresult = FR_OK;
uint32_t Bytes = 0;
uint8_t* buffer = NULL;
-
+ bool success=false;
ConfigurationParameters *Params;
+ // try loading from flash
memcpy(&Bytes,(void *)EMBEDDED_PARAMETERS_MAP_IN_FLASH,sizeof(Bytes));
if ((Bytes)&&(Bytes < 1000))
@@ -339,26 +326,23 @@ uint32_t EmbeddedParametersInit(void)
LoadConfigurationParameters(Params);
Report("LoadConfigurationParameters from flash", __FILE__,__LINE__,Bytes, RpMessage, Fresult, 0);
free(buffer);
- }
- else
- {
- LoadConfigurationParameters(0);
- Report("LoadConfigurationParameters default", __FILE__,__LINE__,0, RpMessage, Fresult, 0);
+ success = true;
}
}
- else
+ if (success == false)
{
- if (LoadConfigurationParamsFromFile(false)!=OK)
- {
- LoadConfigurationParameters(0);
- Report("LoadConfigurationParameters default", __FILE__,__LINE__,0, RpMessage, Fresult, 0);
- }
- else
+ if (LoadConfigurationParamsFromFile(false)==OK)
{
+ success = true;
Report("LoadConfigurationParameters from file", __FILE__,__LINE__,EmbeddedParameters->closevalvetimeout, RpMessage, Fresult, 0);
}
}
-
+ if (success == false)
+ {
+ LoadConfigurationParameters(0);
+ Report("LoadConfigurationParameters default. flash and file error!!!", __FILE__,__LINE__,0, RpMessage, Fresult, 0);
+ AlarmHandlingSetAlarm (EVENT_TYPE__POWER_UP_BIT_FAILURE,ON);
+ }
if (EmbeddedParameters->n_generalparameters >= 6)
{
IDS_Dispenser_SetBackLashValues(EmbeddedParameters->initialdispenserpressure, EmbeddedParameters->initialdispensertimeout, EmbeddedParameters->initialdispensertimelag,EmbeddedParameters->generalparameters[5]);
@@ -734,9 +718,6 @@ uint32_t MidTankDataSetupFunc(MessageContainer* requestContainer)
uint32_t HWConfigurationFunc(MessageContainer* requestContainer)
{
uint32_t status = 0;
- uint32_t DataLen = 0;
- uint32_t ExistingDataLen = 0;
- int compare = 0;
MessageContainer responseContainer;
UploadHardwareConfigurationResponse response = UPLOAD_HARDWARE_CONFIGURATION_RESPONSE__INIT;
UploadHardwareConfigurationRequest* UploadRequest = NULL;
@@ -750,7 +731,7 @@ uint32_t HWConfigurationFunc(MessageContainer* requestContainer)
GeneralHwReady = false;
Control_WD(ENABLE,250);
//compare existing data to new data. update if different
- memcpy(&ExistingDataLen,(void *)GENHWCFG_MAP_IN_FLASH,sizeof(ExistingDataLen));
+ /*memcpy(&ExistingDataLen,(void *)GENHWCFG_MAP_IN_FLASH,sizeof(ExistingDataLen));
if (ExistingDataLen == requestContainer->data.len)
{
compare = memcmp (requestContainer->data.data,((void *)(GENHWCFG_MAP_IN_FLASH+4)),requestContainer->data.len);
@@ -766,15 +747,17 @@ uint32_t HWConfigurationFunc(MessageContainer* requestContainer)
ReadAppAndProgram(GENHWCFG_MAP_IN_FLASH, 4,&DataLen);
ReadAppAndProgram(GENHWCFG_MAP_IN_FLASH+4, DataLen, requestContainer->data.data);
Report("store hw configuration", __FILE__,compare,requestContainer->data.len,RpMessage,ExistingDataLen,0);
-
+ AlarmHandlingLoadFile();
FileWrite(requestContainer->data.data, requestContainer->data.len,HwConfigPath,BIOS_WAIT_FOREVER);
- }
+ }*/
UploadRequest = upload_hardware_configuration_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data);
-
-
- status = HWConfiguration(UploadRequest);
-
- GeneralHwReady = true;
+ if (UploadRequest)
+ {
+ FileWrite(requestContainer->data.data, requestContainer->data.len,HwConfigPath,BIOS_WAIT_FOREVER);
+ Report("store hw configuration", __FILE__,__LINE__,requestContainer->data.len,RpMessage,UploadRequest->hardwareconfiguration->n_motors,0);
+ status = HWConfiguration(UploadRequest);
+ GeneralHwReady = true;
+ }
}
@@ -833,7 +816,7 @@ void HWSystemResetRequest(MessageContainer* requestContainer)
HWREG(NVIC_APINT) = NVIC_APINT_VECTKEY | NVIC_APINT_SYSRESETREQ;
}
-uint32_t FlashInitResults[5] = {0,0,0,0,0};
+//uint32_t FlashInitResults[5] = {0,0,0,0,0};
uint32_t LoadConfigurationParamsFromFile(bool Initialize)
{
FRESULT Fresult = FR_OK;
@@ -849,9 +832,9 @@ uint32_t LoadConfigurationParamsFromFile(bool Initialize)
LoadConfigurationParameters(Params);
free (buffer);
//configuration_parameters__free_unpacked(Params,NULL);
- FlashInitResults[1] = true;
+ //FlashInitResults[1] = true;
Report("Parameters Initialized from file", __FILE__,__LINE__,Bytes, RpMessage, EMBEDDED_PARAMETERS_MAP_IN_FLASH, 0);
- EraseFlashSection(EMBEDDED_PARAMETERS_SECTION_FLASH);
+ EraseFlashSection();
ReadAppAndProgram(EMBEDDED_PARAMETERS_MAP_IN_FLASH, 4,&Bytes);
ReadAppAndProgram(EMBEDDED_PARAMETERS_MAP_IN_FLASH+4, Bytes, buffer);
if (Initialize)
@@ -863,16 +846,16 @@ void HWConfigurationLoadFile(void)
{
uint8_t* buffer = NULL;
uint32_t Bytes = 0;
+ UploadHardwareConfigurationRequest* UploadRequest = NULL;
+
buffer = HWConfigurationLoadFromFile(&Bytes); //load hardware config
if (buffer)
{
- EraseFlashSection(GENHWCFG_SECTION_FLASH);
- ReadAppAndProgram(GENHWCFG_MAP_IN_FLASH, 4,&Bytes);
- ReadAppAndProgram(GENHWCFG_MAP_IN_FLASH+4, Bytes, buffer);
- free (buffer);
- FlashInitResults[0] = true;
+ UploadRequest = upload_hardware_configuration_request__unpack(NULL, Bytes, buffer);
+ Report("HWConfigurationInit from file", __FILE__,__LINE__,Bytes, RpMessage, UploadRequest->hardwareconfiguration->n_dancers, 0);
}
- Report("Hardware Initialized", __FILE__,__LINE__,Bytes, RpMessage, GENHWCFG_MAP_IN_FLASH, 0);
+ else
+ Report("HWConfigurationInit Not available", __FILE__,__LINE__,Bytes, RpMessage, 0, 0);
}
void FlashInitAndLoad(void)
{
@@ -895,7 +878,7 @@ void FlashInitAndLoad(void)
FlashInit(); //initialize flash
Report("Flash Initialized", __FILE__,__LINE__,FLASH_SIZE, RpMessage, FLASH_RAM_BASE, 0);
- buffer = HWConfigurationLoadFromFile(&Bytes); //load hardware config
+ /*buffer = HWConfigurationLoadFromFile(&Bytes); //load hardware config
if (buffer)
{
EraseFlashSection(GENHWCFG_SECTION_FLASH);
@@ -904,7 +887,7 @@ void FlashInitAndLoad(void)
free (buffer);
FlashInitResults[0] = true;
}
- Report("Hardware Initialized", __FILE__,__LINE__,Bytes, RpMessage, GENHWCFG_MAP_IN_FLASH, 0);
+ Report("Hardware Initialized", __FILE__,__LINE__,Bytes, RpMessage, GENHWCFG_MAP_IN_FLASH, 0);*/
StoreDancerConfigMessage(0);
StoreDancerConfigMessage(1);
@@ -915,7 +898,7 @@ void FlashInitAndLoad(void)
{
Report("Alarm Initialized from file", __FILE__,__LINE__,Bytes, RpMessage, ALARM_MAP_IN_FLASH, 0);
}*/
- EraseFlashSection(EMBEDDED_PARAMETERS_SECTION_FLASH);
+ EraseFlashSection();
Fresult = FileRead(EmbeddedParametersPath, &Bytes, &buffer);
if (Fresult == FR_OK)
@@ -927,33 +910,14 @@ void FlashInitAndLoad(void)
ReadAppAndProgram(EMBEDDED_PARAMETERS_MAP_IN_FLASH+4, Bytes, buffer);
free (buffer);
//configuration_parameters__free_unpacked(Params,NULL);
- FlashInitResults[1] = true;
Report("Parameters Initialized from file", __FILE__,__LINE__,sizeof(EmbeddedParameters), RpMessage, EMBEDDED_PARAMETERS_MAP_IN_FLASH, 0);
}
else
{
LoadConfigurationParameters(0);
- FlashInitResults[1] = 2;
Report("Parameters Initialized from default", __FILE__,__LINE__,sizeof(EmbeddedParameters), RpMessage, EMBEDDED_PARAMETERS_MAP_IN_FLASH, 0);
}
- /*Fresult = FileRead(ProcessParamsPath, &Bytes, &buffer);
- if (Fresult == FR_OK)
- {
- request = upload_process_parameters_request__unpack(NULL, Bytes, buffer);
- if (request)
- {
- ProcessParams = request->processparameters;
- Bytes = sizeof(ProcessParams);
- ReadAppAndProgram(PROCESS_PARAMETERS_MAP_IN_FLASH, 4,&Bytes);
- ReadAppAndProgram(PROCESS_PARAMETERS_MAP_IN_FLASH+4, Bytes, &ProcessParams);
- upload_process_parameters_request__free_unpacked(request,NULL);
- FlashInitResults[2] = true;
- Report("Process Initialized", __FILE__,__LINE__,Bytes, RpMessage, (int)ProcessParams->dryerzone1temp, 0);
- }
- }
- else
- Report("Process not Initialized", __FILE__,__LINE__,0, RpMessage, 0, 0);*/
#ifdef WATCHDOG
ROM_WatchdogResetEnable(WATCHDOG0_BASE);
timeout = 120000000*3;
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);
}
}
}