diff --git a/Core/Inc/git_rev.h b/Core/Inc/git_rev.h index 851b2ec..160db2f 100644 --- a/Core/Inc/git_rev.h +++ b/Core/Inc/git_rev.h @@ -7,6 +7,6 @@ // Auto generated header file containing the last git revision -#define GIT_HASH "a982c79" +#define GIT_HASH "5b2e03a" #endif //FLOATPUMP_GIT_REVISION_TEMPLATE_H \ No newline at end of file diff --git a/Core/Src/main.cpp b/Core/Src/main.cpp index 06dc7f8..93e21ce 100644 --- a/Core/Src/main.cpp +++ b/Core/Src/main.cpp @@ -200,7 +200,7 @@ int main(void) { uint32_t last_menu_retrigger = 0; - bool f_store, f_restore = false; + bool f_store = false, f_restore = false; menu::Menu_Entry_Type_Execute t_MStore; menu::Menu_Entry_Type_Execute t_MRestore; t_MStore.linkConfig(&f_store); diff --git a/Middlewares/floatpump/Inc/Config_Store.h b/Middlewares/floatpump/Inc/Config_Store.h index 1cdd618..1822d6f 100644 --- a/Middlewares/floatpump/Inc/Config_Store.h +++ b/Middlewares/floatpump/Inc/Config_Store.h @@ -14,20 +14,34 @@ namespace floatpump { public: Config_Store(); - static uint32_t Flash_Write (uint32_t StartPageAddress, uint32_t Data, uint16_t n_words) { - static FLASH_EraseInitTypeDef EraseInitStruct; - uint32_t PAGEError; - int sofar=0; - + static uint32_t StoreInFlash(uint32_t StartAddress, uint32_t *Data, uint16_t nData) { + uint16_t progr = 0; HAL_FLASH_Unlock(); FLASH_Erase_Sector(FLASH_SECTOR_7, VOLTAGE_RANGE_1); - HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, StartPageAddress, Data); + while( progr < nData) { + if(HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, StartAddress, Data[progr]) == HAL_OK) { + progr++; + StartAddress += 4; } else { + return HAL_FLASH_GetError(); + } + } HAL_FLASH_Lock(); - return 0; } void saveToFlash() { - Flash_Write(0x08060000, this->RefillBelow.getValue(), 0); + uint32_t data[10]; + data[0] = TankCalibLow.getValue(); + data[1] = TankCalibHigh.getValue(); + data[2] = TankMinLevel.getValue(); + data[3] = TankHysteresis.getValue(); + data[4] = TankPumpInvert.getValue(); + data[5] = RefillEnable.getValue(); + data[6] = RefillBlockInvert.getValue(); + data[7] = RefillBlockEnable.getValue(); + data[8] = RefillBelow.getValue(); + data[9] = RefillHysteresis.getValue(); + + StoreInFlash(0x08060000, data, 10); }; void resetDefaults();