|
static bool rtc_schedule(app_timer_t * p_timer, bool * p_rerun)
{
ret_code_t ret = NRF_ERROR_TIMEOUT;
*p_rerun = false;
int64_t remaining = (int64_t)(p_timer->end_val - get_now());
if (remaining > 0) {
uint32_t cc_val = ((uint32_t)remaining > APP_TIMER_RTC_MAX_VALUE) ?
(app_timer_cnt_get() + APP_TIMER_RTC_MAX_VALUE) : p_timer->end_val;
ret = drv_rtc_windowed_compare_set(&m_rtc_inst, 0, cc_val, APP_TIMER_SAFE_WINDOW);
NRF_LOG_DEBUG("Setting CC to 0x%08x (err: %d)", cc_val & DRV_RTC_MAX_CNT, ret);
if (ret == NRF_SUCCESS)
{
return true;
}
}
else
{
drv_rtc_compare_disable(&m_rtc_inst, 0);
}
if (ret == NRF_ERROR_TIMEOUT)
{
*p_rerun = timer_expire(p_timer);
}
else
{
NRF_LOG_ERROR("Unexpected error: %d", ret);
ASSERT(0);
}
return false;
}
如上面的代码所示,出现NRF_ERROR_TIMEOUT错误,会执行timer_expire。NRF_ERROR_TIMEOUT是什么操作导致的。
|
|