fix save config
This commit is contained in:
parent
b594480ff6
commit
d5ae799100
|
@ -157,14 +157,13 @@ static void save_config(void)
|
|||
for (uint16_t i = 0; i < sizeof(config); i += 4) {
|
||||
const uint32_t address = FLASH_CONFIG_ADDR + i;
|
||||
uint32_t data;
|
||||
memcpy(&data, &config + i, sizeof(data)); // works even if the data it not aligned
|
||||
memcpy(&data, (uint8_t*)&config + i, sizeof(data)); // works even if the data it not aligned
|
||||
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, address, data) != HAL_OK) {
|
||||
printf("flash page failed\r\n");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
printf("configuration saved\r\n");
|
||||
|
||||
printf("config saved\r\n");
|
||||
end:
|
||||
HAL_FLASH_Lock();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue