void nrfx_clock_irq_handler(void) { if (nrf_clock_event_check(NRF_CLOCK_EVENT_HFCLKSTARTED)) { nrf_clock_event_clear(NRF_CLOCK_EVENT_HFCLKSTARTED); NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(NRF_CLOCK_EVENT_HFCLKSTARTED)); nrf_clock_int_disable(NRF_CLOCK_INT_HF_STARTED_MASK); #if defined(USE_WORKAROUND_FOR_ANOMALY_201) if (!m_clock_cb.hfclk_started) { m_clock_cb.hfclk_started = true; m_clock_cb.event_handler(NRFX_CLOCK_EVT_HFCLK_STARTED); } #else m_clock_cb.event_handler(NRFX_CLOCK_EVT_HFCLK_STARTED); #endif } if (nrf_clock_event_check(NRF_CLOCK_EVENT_LFCLKSTARTED)) { nrf_clock_event_clear(NRF_CLOCK_EVENT_LFCLKSTARTED); NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(NRF_CLOCK_EVENT_LFCLKSTARTED)); nrf_clock_int_disable(NRF_CLOCK_INT_LF_STARTED_MASK); m_clock_cb.event_handler(NRFX_CLOCK_EVT_LFCLK_STARTED); } #if CALIBRATION_SUPPORT if (nrf_clock_event_check(NRF_CLOCK_EVENT_CTTO)) { nrf_clock_event_clear(NRF_CLOCK_EVENT_CTTO); NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(NRF_CLOCK_EVENT_CTTO)); nrf_clock_int_disable(NRF_CLOCK_INT_CTTO_MASK); m_clock_cb.event_handler(NRFX_CLOCK_EVT_CTTO); } if (nrf_clock_event_check(NRF_CLOCK_EVENT_DONE)) { #if defined(USE_WORKAROUND_FOR_ANOMALY_192) *(volatile uint32_t *)0x40000C34 = 0x00000000; #endif nrf_clock_event_clear(NRF_CLOCK_EVENT_DONE); NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(NRF_CLOCK_EVENT_DONE)); nrf_clock_int_disable(NRF_CLOCK_INT_DONE_MASK); m_clock_cb.cal_state = CAL_STATE_IDLE; m_clock_cb.event_handler(NRFX_CLOCK_EVT_CAL_DONE); } #endif // CALIBRATION_SUPPORT }
void POWER_CLOCK_IRQHandler(void) #endif { if (nrf_clock_event_check(NRF_CLOCK_EVENT_HFCLKSTARTED)) { nrf_clock_event_clear(NRF_CLOCK_EVENT_HFCLKSTARTED); NRF_LOG_DEBUG("Event: %s.\r\n", (uint32_t)EVT_TO_STR(NRF_CLOCK_EVENT_HFCLKSTARTED)); nrf_clock_int_disable(NRF_CLOCK_INT_HF_STARTED_MASK); m_clock_cb.hfclk_on = true; clock_clk_started_notify(NRF_DRV_CLOCK_EVT_HFCLK_STARTED); } if (nrf_clock_event_check(NRF_CLOCK_EVENT_LFCLKSTARTED)) { nrf_clock_event_clear(NRF_CLOCK_EVENT_LFCLKSTARTED); NRF_LOG_DEBUG("Event: %s.\r\n", (uint32_t)EVT_TO_STR(NRF_CLOCK_EVENT_LFCLKSTARTED)); nrf_clock_int_disable(NRF_CLOCK_INT_LF_STARTED_MASK); m_clock_cb.lfclk_on = true; clock_clk_started_notify(NRF_DRV_CLOCK_EVT_LFCLK_STARTED); } #if CALIBRATION_SUPPORT if (nrf_clock_event_check(NRF_CLOCK_EVENT_CTTO)) { nrf_clock_event_clear(NRF_CLOCK_EVENT_CTTO); NRF_LOG_DEBUG("Event: %s.\r\n", (uint32_t)EVT_TO_STR(NRF_CLOCK_EVENT_CTTO)); nrf_clock_int_disable(NRF_CLOCK_INT_CTTO_MASK); nrf_drv_clock_hfclk_request(&m_clock_cb.cal_hfclk_started_handler_item); } if (nrf_clock_event_check(NRF_CLOCK_EVENT_DONE)) { nrf_clock_event_clear(NRF_CLOCK_EVENT_DONE); NRF_LOG_DEBUG("Event: %s.\r\n", (uint32_t)EVT_TO_STR(NRF_CLOCK_EVENT_DONE)); nrf_clock_int_disable(NRF_CLOCK_INT_DONE_MASK); nrf_drv_clock_hfclk_release(); bool aborted = (m_clock_cb.cal_state == CAL_STATE_ABORT); m_clock_cb.cal_state = CAL_STATE_IDLE; if (m_clock_cb.cal_done_handler) { m_clock_cb.cal_done_handler(aborted ? NRF_DRV_CLOCK_EVT_CAL_ABORTED : NRF_DRV_CLOCK_EVT_CAL_DONE); } } #endif // CALIBRATION_SUPPORT }
void POWER_CLOCK_IRQHandler(void) { if (nrf_clock_event_check(NRF_CLOCK_EVENT_HFCLKSTARTED)) { nrf_clock_event_clear(NRF_CLOCK_EVENT_HFCLKSTARTED); nrf_clock_int_disable(NRF_CLOCK_INT_HF_STARTED_MASK); m_clock_cb.hfclk_on = true; clock_clk_started_notify((nrf_drv_clock_handler_item_t **)&m_clock_cb.p_hf_head, NRF_DRV_CLOCK_EVT_HFCLK_STARTED); } if (nrf_clock_event_check(NRF_CLOCK_EVENT_LFCLKSTARTED)) { nrf_clock_event_clear(NRF_CLOCK_EVENT_LFCLKSTARTED); nrf_clock_int_disable(NRF_CLOCK_INT_LF_STARTED_MASK); m_clock_cb.lfclk_on = true; clock_clk_started_notify((nrf_drv_clock_handler_item_t **)&m_clock_cb.p_lf_head, NRF_DRV_CLOCK_EVT_LFCLK_STARTED); } #if CALIBRATION_SUPPORT if (nrf_clock_event_check(NRF_CLOCK_EVENT_CTTO)) { nrf_clock_event_clear(NRF_CLOCK_EVENT_CTTO); nrf_clock_int_disable(NRF_CLOCK_INT_CTTO_MASK); nrf_drv_clock_hfclk_request(&m_clock_cb.cal_hfclk_started_handler_item); } if (nrf_clock_event_check(NRF_CLOCK_EVENT_DONE)) { nrf_clock_event_clear(NRF_CLOCK_EVENT_DONE); nrf_clock_int_disable(NRF_CLOCK_INT_DONE_MASK); nrf_drv_clock_hfclk_release(); nrf_drv_clock_evt_type_t evt_type = (m_clock_cb.cal_state == CAL_STATE_ABORT) ? NRF_DRV_CLOCK_EVT_CAL_ABORTED : NRF_DRV_CLOCK_EVT_CAL_DONE; m_clock_cb.cal_state = CAL_STATE_IDLE; if (m_clock_cb.cal_done_handler) { m_clock_cb.cal_done_handler(evt_type); } } #endif //CALIBRATION_SUPPORT }
void nrfx_clock_irq_handler(void) { if (nrf_clock_event_check(NRF_CLOCK_EVENT_HFCLKSTARTED)) { nrf_clock_event_clear(NRF_CLOCK_EVENT_HFCLKSTARTED); NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(NRF_CLOCK_EVENT_HFCLKSTARTED)); nrf_clock_int_disable(NRF_CLOCK_INT_HF_STARTED_MASK); m_clock_cb.event_handler(NRFX_CLOCK_EVT_HFCLK_STARTED); } if (nrf_clock_event_check(NRF_CLOCK_EVENT_LFCLKSTARTED)) { nrf_clock_event_clear(NRF_CLOCK_EVENT_LFCLKSTARTED); NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(NRF_CLOCK_EVENT_LFCLKSTARTED)); nrf_clock_int_disable(NRF_CLOCK_INT_LF_STARTED_MASK); m_clock_cb.event_handler(NRFX_CLOCK_EVT_LFCLK_STARTED); } #if CALIBRATION_SUPPORT if (nrf_clock_event_check(NRF_CLOCK_EVENT_CTTO)) { nrf_clock_event_clear(NRF_CLOCK_EVENT_CTTO); NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(NRF_CLOCK_EVENT_CTTO)); nrf_clock_int_disable(NRF_CLOCK_INT_CTTO_MASK); m_clock_cb.event_handler(NRFX_CLOCK_EVT_CTTO); } if (nrf_clock_event_check(NRF_CLOCK_EVENT_DONE)) { nrf_clock_event_clear(NRF_CLOCK_EVENT_DONE); NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(NRF_CLOCK_EVENT_DONE)); nrf_clock_int_disable(NRF_CLOCK_INT_DONE_MASK); m_clock_cb.cal_state = CAL_STATE_IDLE; m_clock_cb.event_handler(NRFX_CLOCK_EVT_CAL_DONE); } #endif // CALIBRATION_SUPPORT }
int main(int argc, char **argv) { // configure console pins nrf_gpio_cfg_output(TXPIN); nrf_gpio_cfg_input(RXPIN, NRF_GPIO_PIN_NOPULL); nrf_uart_txrx_pins_set(NRF_UART0, TXPIN, RXPIN); // Start lf clock nrf_clock_lf_src_set(NRF_CLOCK_LFCLK_Xtal); nrf_clock_event_clear(NRF_CLOCK_EVENT_LFCLKSTARTED); nrf_clock_task_trigger(NRF_CLOCK_TASK_LFCLKSTART); while (!nrf_clock_event_check(NRF_CLOCK_EVENT_LFCLKSTARTED)); nrf_clock_event_clear(NRF_CLOCK_EVENT_LFCLKSTARTED); SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; testStart(); return 0; }