I would like to call sd_power_system_off in my error handler. The product is at a stage where occasional errors still occur as the devices are deployed "in the field" for test purposes.
I would like to log these errors to flash memory and afterwards go to system power off so that the battery doesn't drain unneccessarily while the device is doing nothing. Then I can later reset the device using the reset pin and read the logged error information from flash.
However, depending on where the fault handler is called from, calling sd_power_system_off causes a hardfault (resulting in ~5 mA of constant current consumption) because it is called from the wrong level of interrupt handler. How can I handle these cases and bring the system to a low power state?