void nrf_pwr_mgmt_run(void)
{
##if NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED
/*
* Clear FPU exceptions.
* Without this step, the FPU interrupt is marked as pending,
* preventing system from sleeping.
*/
uint32_t fpscr = __get_FPSCR();
__set_FPSCR(fpscr & ~0x9Fu);
__DMB();
NVIC_ClearPendingIRQ(FPU_IRQn);
// Assert if a critical FPU exception is signaled.
ASSERT((fpscr & 0x03) == 0);
##endif // NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED
SLEEP_LOCK();
##if NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED
uint32_t sleep_start;
uint32_t sleep_end;
uint32_t sleep_duration;
sleep_start = app_timer_cnt_get();
##endif // NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED
DEBUG_PIN_SET();
// Wait for an event.
##ifdef SOFTDEVICE_PRESENT
ret_code_t ret_code = sd_app_evt_wait();
if (ret_code == NRF_ERROR_SOFTDEVICE_NOT_ENABLED)
{
__WFE();
__SEV();
__WFE();
}
else
{
APP_ERROR_CHECK(ret_code);
}
##else
__WFE();
__SEV();
__WFE();
##endif // SOFTDEVICE_PRESENT
DEBUG_PIN_CLEAR();
##if NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED
sleep_end = app_timer_cnt_get();
UNUSED_VARIABLE(app_timer_cnt_diff_compute(sleep_end,
sleep_start,
&sleep_duration));
m_ticks_sleeping += sleep_duration;
##endif // NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED
SLEEP_RELEASE();
}
over just :
sd_app_evt_wait();
Seems like there are a lot of reasons why a SoC can't sleep.. :P whilst browsing the Nordic Forums..
Btw, where is most of the power usage values coming from? I see most figures in the low uA range on the forums.. What makes our device use ~0.8mA? I'm surely getting confused by their figures, mb they are referring to only the SoC, whereas we are referring to an entire board?
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Btw, is it better to call this :
over just :
Seems like there are a lot of reasons why a SoC can't sleep.. :P whilst browsing the Nordic Forums..
Btw, where is most of the power usage values coming from? I see most figures in the low uA range on the forums.. What makes our device use ~0.8mA? I'm surely getting confused by their figures, mb they are referring to only the SoC, whereas we are referring to an entire board?