Skip to content
Permalink
Browse files

Bluetooth: controller: Fix XTAL advanced feature

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 2, 2019
1 parent 4b9dee8 commit 211a81f9f4924ebc58f9eceafc536e10c3a05b15
Showing with 81 additions and 0 deletions.
  1. +81 −0 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();

0 comments on commit 211a81f

Please sign in to comment.
You can’t perform that action at this time.