We appear to have discovered today that if you do this sequence
sd_power_gpregret_clr(0xFF); sd_power_gpregret_set(0xA0); sd_power_gpregret_set(0x0B);
GPREGRET will contain 0xAB and not 0x0B.
Based on the way that BOOTLOADER_DFU_START is used in the SDK examples it never occurred to me that GPREGRET is a bitmask. I should have probably guessed that from the fact that there are _set() and _clr() functions but I thought they were provided for convenience in accessing the register.
Are GPREGRET (and the new GPREGRET2) treated as bitmaps? I can't find anything that explicitly says that in the SDK 11 source, SDK 11 documenation or the Reference Manuals for the nRF51 and nRF52.
The only hint appears to be the presence of the sd_power_gpregret_set() / sd_power_gpregret_get() API functions.
Cheers!
--- ta2