Clear GPREGRET before setting

There are some troubles with that register:
it is recommended to clear it with 0xFF mask
and only after that perform a setting.
This commit is contained in:
MagnusKos 2025-07-21 18:40:24 +03:00
parent 7c45ada631
commit bdbc0afa2f

View File

@ -363,6 +363,7 @@ void cpuDeepSleep(uint32_t msecToWake)
// Resume on user button press
// https://github.com/lyusupov/SoftRF/blob/81c519ca75693b696752235d559e881f2e0511ee/software/firmware/source/SoftRF/src/platform/nRF52.cpp#L1738
constexpr uint32_t DFU_MAGIC_SKIP = 0x6d;
sd_power_gpregret_clr(0, 0xFF); // Clear the register before setting a new values in it for stability reasons
sd_power_gpregret_set(0, DFU_MAGIC_SKIP); // Equivalent NRF_POWER->GPREGRET = DFU_MAGIC_SKIP
// FIXME, use system off mode with ram retention for key state?