Skip to content

Commit

Permalink
Bluetooth: controller: Fix XTAL advanced feature
Browse files Browse the repository at this point in the history
Fix XTAL advanced feature by adding the missing
implementation to calculate and, retain or release the XTAL
clock source after a Bluetooth state or role is stopped.

Fixes #15817.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
  • Loading branch information
cvinayak authored and carlescufi committed May 3, 2019
1 parent 4b9dee8 commit 211a81f
Showing 1 changed file with 81 additions and 0 deletions.
81 changes: 81 additions & 0 deletions subsys/bluetooth/controller/ll_sw/ctrl.c
Expand Up @@ -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};
Expand Down Expand Up @@ -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 */
Expand All @@ -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);
}
Expand All @@ -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.
Expand Down Expand Up @@ -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};
Expand Down Expand Up @@ -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 */
Expand All @@ -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);
}
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 211a81f

Please sign in to comment.