raspikeyer/settings.cpp
2024-02-06 22:11:58 +01:00

19 lines
No EOL
472 B
C++

#include "settings.h"
namespace
{
const size_t PAGE_SIZE{256};
const size_t NVS_SIZE{4096};
const uint32_t FLASH_WRITE_START = PICO_FLASH_SIZE_BYTES - NVS_SIZE;
}
void flash_store_callback(void *settings)
{
flash_range_erase(FLASH_WRITE_START, NVS_SIZE);
flash_range_program(FLASH_WRITE_START, (const uint8_t *)settings, PAGE_SIZE);
}
void store_settings(Settings &settings)
{
flash_safe_execute(flash_store_callback, (void *)&settings, 1000);
}