diff --git a/subsys/bluetooth/controller/ll_sw/ctrl.c b/subsys/bluetooth/controller/ll_sw/ctrl.c index 2ea8c8e3e51e5a..2a5b2c255d3a56 100644 --- a/subsys/bluetooth/controller/ll_sw/ctrl.c +++ b/subsys/bluetooth/controller/ll_sw/ctrl.c @@ -6603,6 +6603,13 @@ static void mayfly_adv_stop(void *param) static inline void ticker_stop_adv_stop_active(void) { +#if defined(CONFIG_BT_CTLR_XTAL_ADVANCED) + static memq_link_t link_calc; + static struct mayfly s_mfy_xtal_calc = {0, 0, &link_calc, + (void *)RADIO_TICKER_ID_ADV, + mayfly_xtal_stop_calc}; +#endif /* CONFIG_BT_CTLR_XTAL_ADVANCED */ + static memq_link_t link_inact; static struct mayfly s_mfy_radio_inactive = {0, 0, &link_inact, NULL, mayfly_radio_inactive}; @@ -6681,6 +6688,17 @@ static inline void ticker_stop_adv_stop_active(void) RADIO_TICKER_USER_ID_WORKER, 0, &s_mfy_xtal_stop); LL_ASSERT(!ret); + +#if defined(CONFIG_BT_CTLR_XTAL_ADVANCED) + /* calc whether xtal needs to be retained after + * this event + */ + ret = mayfly_enqueue( + RADIO_TICKER_USER_ID_JOB, + RADIO_TICKER_USER_ID_JOB, 0, + &s_mfy_xtal_calc); + LL_ASSERT(!ret); +#endif /* CONFIG_BT_CTLR_XTAL_ADVANCED */ } } else if (ret_cb_m0 == TICKER_STATUS_FAILURE) { /* Step 2.1.2: Deassert Radio Active and XTAL start */ @@ -6696,6 +6714,16 @@ static inline void ticker_stop_adv_stop_active(void) RADIO_TICKER_USER_ID_WORKER, 0, &s_mfy_xtal_stop); LL_ASSERT(!ret); + +#if defined(CONFIG_BT_CTLR_XTAL_ADVANCED) + /* calc whether xtal needs to be retained after this + * event + */ + ret = mayfly_enqueue(RADIO_TICKER_USER_ID_JOB, + RADIO_TICKER_USER_ID_JOB, 0, + &s_mfy_xtal_calc); + LL_ASSERT(!ret); +#endif /* CONFIG_BT_CTLR_XTAL_ADVANCED */ } else { LL_ASSERT(0); } @@ -6717,6 +6745,16 @@ static inline void ticker_stop_adv_stop_active(void) &s_mfy_radio_stop); LL_ASSERT(!ret); +#if defined(CONFIG_BT_CTLR_XTAL_ADVANCED) + /* calc whether xtal needs to be retained after this + * event + */ + ret = mayfly_enqueue(RADIO_TICKER_USER_ID_JOB, + RADIO_TICKER_USER_ID_JOB, 0, + &s_mfy_xtal_calc); + LL_ASSERT(!ret); +#endif /* CONFIG_BT_CTLR_XTAL_ADVANCED */ + /* NOTE: Cannot wait here for the event to finish * as we need to let radio ISR to execute if we are in * the same priority. @@ -10326,6 +10364,12 @@ static inline void role_active_disable(u8_t ticker_id_stop, u32_t ticks_xtal_to_start, u32_t ticks_active_to_start) { +#if defined(CONFIG_BT_CTLR_XTAL_ADVANCED) + static memq_link_t link_calc; + static struct mayfly s_mfy_xtal_calc = {0, 0, &link_calc, NULL, + mayfly_xtal_stop_calc}; +#endif /* CONFIG_BT_CTLR_XTAL_ADVANCED */ + static memq_link_t link_inact; static struct mayfly s_mfy_radio_inactive = {0, 0, &link_inact, NULL, mayfly_radio_inactive}; @@ -10394,6 +10438,19 @@ static inline void role_active_disable(u8_t ticker_id_stop, RADIO_TICKER_USER_ID_WORKER, 0, &s_mfy_xtal_stop); LL_ASSERT(!ret); + +#if defined(CONFIG_BT_CTLR_XTAL_ADVANCED) + /* calc whether xtal needs to be retained after + * this event + */ + s_mfy_xtal_calc.param = + (void *)(u32_t)_radio.ticker_id_stop; + ret = mayfly_enqueue( + RADIO_TICKER_USER_ID_APP, + RADIO_TICKER_USER_ID_JOB, 0, + &s_mfy_xtal_calc); + LL_ASSERT(!ret); +#endif /* CONFIG_BT_CTLR_XTAL_ADVANCED */ } } else if (ret_cb_m0 == TICKER_STATUS_FAILURE) { /* Step 2.1.2: Deassert Radio Active and XTAL start */ @@ -10409,6 +10466,18 @@ static inline void role_active_disable(u8_t ticker_id_stop, RADIO_TICKER_USER_ID_WORKER, 0, &s_mfy_xtal_stop); LL_ASSERT(!ret); + +#if defined(CONFIG_BT_CTLR_XTAL_ADVANCED) + /* calc whether xtal needs to be retained after this + * event + */ + s_mfy_xtal_calc.param = + (void *)(u32_t)_radio.ticker_id_stop; + ret = mayfly_enqueue(RADIO_TICKER_USER_ID_APP, + RADIO_TICKER_USER_ID_JOB, 0, + &s_mfy_xtal_calc); + LL_ASSERT(!ret); +#endif /* CONFIG_BT_CTLR_XTAL_ADVANCED */ } else { LL_ASSERT(0); } @@ -10457,6 +10526,18 @@ static inline void role_active_disable(u8_t ticker_id_stop, &s_mfy_radio_stop); LL_ASSERT(!ret); +#if defined(CONFIG_BT_CTLR_XTAL_ADVANCED) + /* calc whether xtal needs to be retained after this + * event + */ + s_mfy_xtal_calc.param = + (void *)(u32_t)_radio.ticker_id_stop; + ret = mayfly_enqueue(RADIO_TICKER_USER_ID_APP, + RADIO_TICKER_USER_ID_JOB, 0, + &s_mfy_xtal_calc); + LL_ASSERT(!ret); +#endif /* CONFIG_BT_CTLR_XTAL_ADVANCED */ + /* wait for radio ISR to exit */ while (_radio.role != ROLE_NONE) { cpu_sleep();