From d5da582e00a4e8105bf72dd473c270d4ae4d0a2e Mon Sep 17 00:00:00 2001 From: Vinayak Kariappa Chettimada Date: Mon, 17 Jun 2024 12:26:08 +0200 Subject: [PATCH] Bluetooth: Controller: Fix PA setup for ISO Broadcast Fix missing PA setup for ISO Broadcast subevent transmits. Signed-off-by: Vinayak Kariappa Chettimada --- subsys/bluetooth/controller/ll_sw/lll_adv.h | 4 ++ .../controller/ll_sw/nordic/lll/lll_adv_iso.c | 49 ++++++++++++++++--- 2 files changed, 45 insertions(+), 8 deletions(-) diff --git a/subsys/bluetooth/controller/ll_sw/lll_adv.h b/subsys/bluetooth/controller/ll_sw/lll_adv.h index eac2d4dcb26..c7b5d49ea25 100644 --- a/subsys/bluetooth/controller/ll_sw/lll_adv.h +++ b/subsys/bluetooth/controller/ll_sw/lll_adv.h @@ -88,6 +88,10 @@ struct lll_adv_iso { #endif /* CONFIG_BT_TICKER_EXT_EXPIRE_INFO */ uint16_t stream_handle[BT_CTLR_ADV_ISO_STREAM_MAX]; + +#if defined(HAL_RADIO_GPIO_HAVE_PA_PIN) + uint16_t pa_iss_us; +#endif /* HAL_RADIO_GPIO_HAVE_PA_PIN */ }; struct lll_adv_sync { diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_iso.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_iso.c index b0251ce06cc..a31b68b3ad1 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_iso.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_iso.c @@ -408,7 +408,7 @@ static int prepare_cb_common(struct lll_prepare_param *p) remainder = p->remainder; start_us = radio_tmr_start(1U, ticks_at_start, remainder); - if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) { + if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR) || IS_ENABLED(HAL_RADIO_GPIO_HAVE_PA_PIN)) { /* setup capture of PDU end timestamp */ radio_tmr_end_capture(); } @@ -417,7 +417,8 @@ static int prepare_cb_common(struct lll_prepare_param *p) radio_gpio_pa_setup(); radio_gpio_pa_lna_enable(start_us + - radio_tx_ready_delay_get(phy, PHY_FLAGS_S8) - + radio_tx_ready_delay_get(lll->phy, + lll->phy_flags) - HAL_RADIO_GPIO_PA_OFFSET); #else /* !HAL_RADIO_GPIO_HAVE_PA_PIN */ ARG_UNUSED(start_us); @@ -471,6 +472,10 @@ static void isr_tx_common(void *param, uint8_t crc_init[3]; uint8_t bis; +#if defined(HAL_RADIO_GPIO_HAVE_PA_PIN) + uint16_t pa_iss_us = 0U; +#endif /* HAL_RADIO_GPIO_HAVE_PA_PIN */ + if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) { lll_prof_latency_capture(); } @@ -747,20 +752,48 @@ static void isr_tx_common(void *param, lll->phy, lll->phy_flags); radio_isr_set(isr_tx, lll); + +#if defined(HAL_RADIO_GPIO_HAVE_PA_PIN) + /* local variable used later to store iss_us next subevent PA + * setup. + */ + pa_iss_us = iss_us; +#endif /* HAL_RADIO_GPIO_HAVE_PA_PIN */ } - if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) { - /* setup capture of PDU end timestamp */ - radio_tmr_end_capture(); - } - - /* assert if radio packet ptr is not set and radio started rx */ + /* assert if radio packet ptr is not set and radio started tx */ LL_ASSERT(!radio_is_ready()); if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) { lll_prof_cputime_capture(); } + if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR) || IS_ENABLED(HAL_RADIO_GPIO_HAVE_PA_PIN)) { + /* setup capture of PDU end timestamp */ + radio_tmr_end_capture(); + } + +#if defined(HAL_RADIO_GPIO_HAVE_PA_PIN) + if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) { + /* PA/LNA enable is overwriting packet end used in ISR + * profiling, hence back it up for later use. + */ + lll_prof_radio_end_backup(); + } + + radio_gpio_pa_setup(); + radio_gpio_pa_lna_enable(radio_tmr_tifs_base_get() + + lll->pa_iss_us - + (EVENT_CLOCK_JITTER_US << 1U) - + radio_tx_chain_delay_get(lll->phy, + lll->phy_flags) - + HAL_RADIO_GPIO_PA_OFFSET); + + /* Remember to use it for the next subevent PA setup */ + lll->pa_iss_us = pa_iss_us; + +#endif /* HAL_RADIO_GPIO_HAVE_PA_PIN */ + /* Calculate ahead the next subevent channel index */ const uint16_t event_counter = (lll->payload_count / lll->bn) - 1U;