when I call sd_power_gpregret_set in gpiote handler function ,I got HardFault, why?
when I call sd_power_gpregret_set in gpiote handler function ,I got HardFault, why?
what interrupt priority is your gpiote handler running at? Higher than that for the SVC call? if so you're going to hardfault.
I find that nrf_drv_common_irq_enable(GPIOTE_IRQn, GPIOTE_CONFIG_IRQ_PRIORITY)
in file nrf_drv_gpiote.c
priority define in the nrf_drv_config.h
#define GPIOTE_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_HIGH
so that's your problem then. As is discussed here most weeks a few times, you can't call sd_* functions from anything other than main context or the lower of the user interrupt contexts.