ret_code_t nrf_drv_clock_calibration_start(uint8_t interval, nrf_drv_clock_event_handler_t handler) { #if CALIBRATION_SUPPORT ASSERT(m_clock_cb.cal_state == CAL_STATE_IDLE); ret_code_t ret = NRF_SUCCESS; if (m_clock_cb.lfclk_on == false) { ret = NRF_ERROR_INVALID_STATE; } else if (m_clock_cb.cal_state == CAL_STATE_IDLE) { m_clock_cb.cal_done_handler = handler; m_clock_cb.cal_hfclk_started_handler_item.event_handler = clock_calibration_hf_started; if (interval == 0) { m_clock_cb.cal_state = CAL_STATE_HFCLK_REQ; nrf_drv_clock_hfclk_request(&m_clock_cb.cal_hfclk_started_handler_item); } else { m_clock_cb.cal_state = CAL_STATE_CT; nrf_clock_cal_timer_timeout_set(interval); nrf_clock_int_enable(NRF_CLOCK_INT_CTTO_MASK); nrf_clock_task_trigger(NRF_CLOCK_TASK_CTSTART); } } else { ret = NRF_ERROR_BUSY; } return ret; #else //CALIBRATION_SUPPORT return NRF_ERROR_FORBIDDEN; #endif }
void nrfx_clock_calibration_timer_start(uint8_t interval) { nrf_clock_cal_timer_timeout_set(interval); nrf_clock_event_clear(NRF_CLOCK_EVENT_CTTO); nrf_clock_int_enable(NRF_CLOCK_INT_CTTO_MASK); nrf_clock_task_trigger(NRF_CLOCK_TASK_CTSTART); }
ret_code_t nrf_drv_clock_calibration_start(uint8_t interval, nrf_drv_clock_event_handler_t handler) { ret_code_t err_code = NRF_SUCCESS; #if CALIBRATION_SUPPORT ASSERT(m_clock_cb.cal_state == CAL_STATE_IDLE); if (m_clock_cb.lfclk_on == false) { err_code = NRF_ERROR_INVALID_STATE; } else if (m_clock_cb.cal_state == CAL_STATE_IDLE) { m_clock_cb.cal_done_handler = handler; m_clock_cb.cal_hfclk_started_handler_item.event_handler = clock_calibration_hf_started; if (interval == 0) { m_clock_cb.cal_state = CAL_STATE_HFCLK_REQ; nrf_drv_clock_hfclk_request(&m_clock_cb.cal_hfclk_started_handler_item); } else { m_clock_cb.cal_state = CAL_STATE_CT; nrf_clock_cal_timer_timeout_set(interval); nrf_clock_event_clear(NRF_CLOCK_EVENT_CTTO); nrf_clock_int_enable(NRF_CLOCK_INT_CTTO_MASK); nrf_clock_task_trigger(NRF_CLOCK_TASK_CTSTART); } } else { err_code = NRF_ERROR_BUSY; } NRF_LOG_WARNING("Function: %s, error code: %s.\r\n", (uint32_t)__func__, (uint32_t)ERR_TO_STR(err_code)); return err_code; #else err_code = NRF_ERROR_FORBIDDEN; NRF_LOG_WARNING("Function: %s, error code: %s.\r\n", (uint32_t)__func__, (uint32_t)ERR_TO_STR(err_code)); return err_code; #endif // CALIBRATION_SUPPORT }