From 15d3711a75adea0e14cde2fa4a0100f4b1b97953 Mon Sep 17 00:00:00 2001 From: Vinayak Kariappa Chettimada Date: Tue, 12 May 2020 15:26:43 +0530 Subject: [PATCH] Bluetooth: controller: split: Remove +1 magic ticks and microseconds Remove use of magic numbers to adjust ticks offset, replace with vendor defines. Signed-off-by: Vinayak Kariappa Chettimada --- .../controller/ll_sw/nordic/lll/lll_adv.c | 2 +- subsys/bluetooth/controller/ll_sw/ull_adv_aux.c | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv.c index 5b27646d43f..ff94a69d3ce 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv.c @@ -478,7 +478,7 @@ static void isr_done(void *param) #if defined(CONFIG_BT_CTLR_ADV_EXT) if (lll->aux) { lll_adv_aux_offset_fill(lll->aux->ticks_offset, - start_us + 1, pdu); + start_us, pdu); } #else /* !CONFIG_BT_CTLR_ADV_EXT */ ARG_UNUSED(pdu); diff --git a/subsys/bluetooth/controller/ll_sw/ull_adv_aux.c b/subsys/bluetooth/controller/ll_sw/ull_adv_aux.c index ee730f62eb0..abc712f9f7f 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_adv_aux.c +++ b/subsys/bluetooth/controller/ll_sw/ull_adv_aux.c @@ -710,11 +710,20 @@ static void mfy_aux_offset_get(void *param) LL_ASSERT(id != TICKER_NULL); } while (id != ticker_id); - /* NOTE: as remainder not used in scheduling primary PDU - * packet timer starts transmission after 1 tick hence the +1. + /* Store the ticks offset for population in other advertising primary + * channel PDUs. */ - aux->lll.ticks_offset = ticks_to_expire + 1; + aux->lll.ticks_offset = ticks_to_expire; + /* NOTE: as remainder used in scheduling primary PDU not available, + * compensate with a probable jitter of one ticker resolution unit that + * would be included in the packet timer capture when scheduling next + * advertising primary channel PDU. + */ + aux->lll.ticks_offset += + HAL_TICKER_US_TO_TICKS(EVENT_TICKER_RES_MARGIN_US); + + /* FIXME: we are in ULL_LOW context, fill offset in LLL context */ pdu = lll_adv_data_curr_get(&adv->lll); lll_adv_aux_offset_fill(ticks_to_expire, 0, pdu); }