diff --git a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_df.c b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_df.c index 500720ba35709..1f5c810bc2aed 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_df.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_df.c @@ -399,7 +399,7 @@ void radio_switch_complete_and_phy_end_b2b_tx(uint8_t phy_curr, uint8_t flags_cu uint8_t phy_next, uint8_t flags_next) { #if defined(CONFIG_BT_CTLR_TIFS_HW) - NRF_RADIO->SHORTS = RADIO_SHORTS_READY_START_Msk | RADIO_SHORTS_END_DISABLE_Msk | + NRF_RADIO->SHORTS = RADIO_SHORTS_READY_START_Msk | NRF_RADIO_SHORTS_TRX_END_DISABLE_Msk | RADIO_SHORTS_DISABLED_TXEN_Msk; #else /* !CONFIG_BT_CTLR_TIFS_HW */ NRF_RADIO->SHORTS = RADIO_SHORTS_READY_START_Msk | NRF_RADIO_SHORTS_TRX_END_DISABLE_Msk; diff --git a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5_dppi.h b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5_dppi.h index 06aea328eaf46..4dabe97d910bf 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5_dppi.h +++ b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5_dppi.h @@ -89,7 +89,8 @@ static inline void hal_radio_disable_on_hcto_ppi_config(void) */ static inline void hal_radio_end_time_capture_ppi_config(void) { - nrf_radio_publish_set(NRF_RADIO, HAL_NRF_RADIO_EVENT_END, HAL_RADIO_END_TIME_CAPTURE_PPI); + nrf_radio_publish_set(NRF_RADIO, HAL_NRF_RADIO_EVENT_END, + HAL_RADIO_END_TIME_CAPTURE_PPI); nrf_timer_subscribe_set(EVENT_TIMER, HAL_EVENT_TIMER_TRX_END_TASK, HAL_RADIO_END_TIME_CAPTURE_PPI); } @@ -230,15 +231,15 @@ static inline void hal_trigger_crypt_by_bcmatch_ppi_config(void) /******************************************************************************/ #if !defined(CONFIG_BT_CTLR_TIFS_HW) - /* DPPI setup used for SW-based auto-switching during TIFS. */ -#if defined(CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER) -#define HAL_NRF_RADIO_TIFS_DPPI_EVENT_END HAL_NRF_RADIO_EVENT_END -#define HAL_RADIO_TIFS_DPPI_PUBLISH_END HAL_RADIO_PUBLISH_END -#else /* !CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER */ -#define HAL_NRF_RADIO_TIFS_DPPI_EVENT_END HAL_NRF_RADIO_EVENT_PHYEND -#define HAL_RADIO_TIFS_DPPI_PUBLISH_END HAL_RADIO_PUBLISH_PHYEND -#endif /* !CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER */ + +#if defined(CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER) && !defined(CONFIG_BT_CTLR_DF) +#define HAL_NRF_RADIO_TIMER_CLEAR_EVENT_END HAL_NRF_RADIO_EVENT_END +#define HAL_RADIO_GROUP_TASK_ENABLE_PUBLISH_END HAL_RADIO_PUBLISH_END +#else /* !CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER || CONFIG_BT_CTLR_DF */ +#define HAL_NRF_RADIO_TIMER_CLEAR_EVENT_END HAL_NRF_RADIO_EVENT_PHYEND +#define HAL_RADIO_GROUP_TASK_ENABLE_PUBLISH_END HAL_RADIO_PUBLISH_PHYEND +#endif /* !CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER || CONFIG_BT_CTLR_DF */ /* Clear SW-switch timer on packet end: * wire the RADIO EVENTS_END event to SW_SWITCH_TIMER TASKS_CLEAR task. @@ -250,7 +251,7 @@ static inline void hal_trigger_crypt_by_bcmatch_ppi_config(void) */ static inline void hal_sw_switch_timer_clear_ppi_config(void) { - nrf_radio_publish_set(NRF_RADIO, HAL_NRF_RADIO_TIFS_DPPI_EVENT_END, + nrf_radio_publish_set(NRF_RADIO, HAL_NRF_RADIO_TIMER_CLEAR_EVENT_END, HAL_SW_SWITCH_TIMER_CLEAR_PPI); nrf_timer_subscribe_set(SW_SWITCH_TIMER, NRF_TIMER_TASK_CLEAR, HAL_SW_SWITCH_TIMER_CLEAR_PPI); @@ -321,7 +322,7 @@ static inline void hal_sw_switch_timer_clear_ppi_config(void) * a PPI to publish RADIO END event. */ #define HAL_SW_SWITCH_GROUP_TASK_ENABLE_PPI_REGISTER_EVT \ - (NRF_RADIO->HAL_RADIO_TIFS_DPPI_PUBLISH_END) + (NRF_RADIO->HAL_RADIO_GROUP_TASK_ENABLE_PUBLISH_END) #define HAL_SW_SWITCH_GROUP_TASK_ENABLE_PPI_EVT \ (((HAL_SW_SWITCH_GROUP_TASK_ENABLE_PPI << \ RADIO_PUBLISH_END_CHIDX_Pos) \ @@ -528,8 +529,10 @@ static inline void hal_radio_sw_switch_cleanup(void) { hal_radio_sw_switch_disable(); nrf_dppi_channels_disable(NRF_DPPIC, - (BIT(HAL_SW_SWITCH_TIMER_CLEAR_PPI) | - BIT(HAL_SW_SWITCH_GROUP_TASK_ENABLE_PPI))); +#if !defined(CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER) + BIT(HAL_SW_SWITCH_TIMER_CLEAR_PPI) | +#endif /* !CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER */ + BIT(HAL_SW_SWITCH_GROUP_TASK_ENABLE_PPI)); nrf_dppi_group_disable(NRF_DPPIC, SW_SWITCH_TIMER_TASK_GROUP(0)); nrf_dppi_group_disable(NRF_DPPIC, SW_SWITCH_TIMER_TASK_GROUP(1)); } diff --git a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5_ppi.h b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5_ppi.h index 05445e1fb48bc..d9ead6803a9d2 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5_ppi.h +++ b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5_ppi.h @@ -170,18 +170,18 @@ static inline void hal_radio_end_time_capture_ppi_config(void) /* No need to configure anything for the pre-programmed channel. */ } -#else +#else /* !(EVENT_TIMER_ID == 0) */ static inline void hal_radio_end_time_capture_ppi_config(void) { nrf_ppi_channel_endpoint_setup( NRF_PPI, HAL_RADIO_END_TIME_CAPTURE_PPI, - (uint32_t)&(NRF_RADIO->HAL_RADIO_TRX_EVENTS_END), + (uint32_t)&(NRF_RADIO->HAL_RADIO_EVENTS_END), (uint32_t)&(EVENT_TIMER->TASKS_CAPTURE[HAL_EVENT_TIMER_TRX_END_CC_OFFSET])); } -#endif /* (EVENT_TIMER_ID == 0) */ +#endif /* !(EVENT_TIMER_ID == 0) */ /******************************************************************************* * Start event timer on RTC tick: @@ -307,7 +307,7 @@ static inline void hal_sw_switch_timer_clear_ppi_config(void) (uint32_t)&(SW_SWITCH_TIMER->TASKS_CLEAR)); } -#else /* !CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER */ +#else /* CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER */ /* Clear event timer (sw-switch timer) on Radio end: * wire the RADIO EVENTS_END event to the @@ -325,7 +325,7 @@ static inline void hal_sw_switch_timer_clear_ppi_config(void) (uint32_t)&(SW_SWITCH_TIMER->TASKS_CLEAR)); } -#endif /* !CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER */ +#endif /* CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER */ /* The 2 adjacent PPI groups used for implementing SW_SWITCH_TIMER-based * auto-switch for TIFS. 'index' must be 0 or 1. @@ -453,11 +453,15 @@ static inline void hal_radio_sw_switch_disable(void) { /* Disable the following PPI channels that implement SW Switch: * - Clearing SW SWITCH TIMER on RADIO END event + * - Do not clear for single timer use as it uses the same PPI as + * end time capture * - Enabling SW SWITCH PPI Group on RADIO END event */ nrf_ppi_channels_disable( NRF_PPI, +#if !defined(CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER) BIT(HAL_SW_SWITCH_TIMER_CLEAR_PPI) | +#endif /* !CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER */ BIT(HAL_SW_SWITCH_GROUP_TASK_ENABLE_PPI)); /* Invalidation of subscription of S2 timer Compare used when diff --git a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5_resources.h b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5_resources.h index 8bd540bbfa658..a60b27e248246 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5_resources.h +++ b/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5_resources.h @@ -18,7 +18,8 @@ * or reception of a PDU on air. In case of regular PDU it is generated when last bit of CRC is * received or transmitted. */ -#define HAL_RADIO_TRX_EVENTS_END HAL_RADIO_EVENTS_END +#define HAL_RADIO_TRX_EVENTS_END HAL_RADIO_EVENTS_END +#define HAL_NRF_RADIO_TRX_EVENT_END HAL_NRF_RADIO_EVENT_END /* Wrapper for RADIO_SHORTS mask connecting EVENTS_END to EVENTS_DISABLE. * This is a default shortcut used to automatically disable Radio after end of PDU. @@ -62,59 +63,62 @@ */ #define HAL_RADIO_ISR_LATENCY_MAX_US 80U -#if defined(CONFIG_BT_CTLR_DF_CONN_CTE_RX) -/* Delay of CCM TASKS_CRYPT start in number of bits for Radio Bit counter */ -#define CCM_TASKS_CRYPT_DELAY_BITS 3 -#endif /* CONFIG_BT_CTLR_DF_CONN_CTE_RX */ +#define SW_SWITCH_TIMER_EVTS_COMP_BASE 4 #if defined(CONFIG_BT_CTLR_PHY_CODED) -#define SW_SWITCH_TIMER_EVTS_COMP_BASE 4 #define SW_SWITCH_TIMER_EVTS_COMP_S2_BASE 6 +#endif /* !CONFIG_BT_CTLR_PHY_CODED */ + +#if defined(CONFIG_BT_CTLR_DF) +#if defined(CONFIG_BT_CTLR_DF_PHYEND_OFFSET_COMPENSATION_ENABLE) +/* Allocate 2 adjacent channels for PHYEND delay compensation. Use the same channels as for + * PHY CODED S2. The CTEINLINE may not be enabled for PHY CODED so PHYEND event is generated + * at the same instant as END event. Hence the channels are used interchangeably. + * That saves from use of another timer. + */ +#define SW_SWITCH_TIMER_EVTS_COMP_PHYEND_DELAY_COMPENSATION_BASE 6 +#endif /* CONFIG_BT_CTLR_DF_PHYEND_OFFSET_COMPENSATION_ENABLE */ /* Wrapper for EVENTS_END event generated by Radio peripheral at the very end of the transmission * or reception of a PDU on air. In case of regular PDU it is generated when last bit of CRC is * received or transmitted. + * + * When direction finding is enabled a PDU may include Constant Tone Extension at its end. For PDU + * including CTE EVENTS_PHYEND event is generated at very end of a PDU. In case there is no CTE in + * a PDU the EVENTS_PHYEND event is generated in the same instant as EVENTS_END event. */ -#define HAL_RADIO_TRX_EVENTS_END HAL_RADIO_EVENTS_END +#define HAL_RADIO_TRX_EVENTS_END HAL_RADIO_EVENTS_PHYEND +#define HAL_NRF_RADIO_TRX_EVENT_END HAL_NRF_RADIO_EVENT_PHYEND -/* Wrapper for RADIO_SHORTS mask connecting EVENTS_END to EVENTS_DISABLE. - * This is a default shortcut used to automatically disable Radio after end of PDU. +/* Wrapper for RADIO_SHORTS mask connecting EVENTS_PHYEND to EVENTS_DISABLE. + * This is a mask for SOC that has Direction Finding Extension in a Radio peripheral. + * It enables shortcut for EVENTS_PHYEND event generated at very end to Radio EVENTS_DISABLE event. + * In case there is a CTE in a PDU then EVENTS_PHYEND event is generated after the CTE. + * If there is no CTE, it is generated in the same instant as EVENTS_END. */ -#define NRF_RADIO_SHORTS_TRX_END_DISABLE_Msk HAL_RADIO_SHORTS_TRX_END_DISABLE_Msk - -#define HAL_EVENT_TIMER_TRX_CC_OFFSET 0 -#define HAL_EVENT_TIMER_TRX_EVENT NRF_TIMER_EVENT_COMPARE0 -#define HAL_EVENT_TIMER_READY_TASK NRF_TIMER_TASK_CAPTURE0 - -#define HAL_EVENT_TIMER_HCTO_CC_OFFSET 1 -#define HAL_EVENT_TIMER_HCTO_EVENT NRF_TIMER_EVENT_COMPARE1 -#define HAL_EVENT_TIMER_ADDRESS_TASK NRF_TIMER_TASK_CAPTURE1 - -#define HAL_EVENT_TIMER_TRX_END_CC_OFFSET 2 -#define HAL_EVENT_TIMER_TRX_END_TASK NRF_TIMER_TASK_CAPTURE2 - -#define HAL_EVENT_TIMER_DEFERRED_TRX_CC_OFFSET 2 -#define HAL_EVENT_TIMER_DEFERRED_TX_EVENT NRF_TIMER_EVENT_COMPARE2 - -#define HAL_EVENT_TIMER_SAMPLE_CC_OFFSET 3 -#define HAL_EVENT_TIMER_SAMPLE_TASK NRF_TIMER_TASK_CAPTURE3 +#define NRF_RADIO_SHORTS_TRX_END_DISABLE_Msk HAL_RADIO_SHORTS_TRX_PHYEND_DISABLE_Msk -#define HAL_EVENT_TIMER_PA_LNA_CC_OFFSET 2 -#define HAL_EVENT_TIMER_PA_LNA_PDN_CC_OFFSET 3 +/* Delay of EVENTS_PHYEND event on receive PDU without CTE included when CTEINLINE is enabled */ +#define RADIO_EVENTS_PHYEND_DELAY_US 16 -#else /* !CONFIG_BT_CTLR_PHY_CODED */ -#define SW_SWITCH_TIMER_EVTS_COMP_BASE 4 +#if defined(CONFIG_BT_CTLR_DF_CONN_CTE_RX) +/* Delay of CCM TASKS_CRYPT start in number of bits for Radio Bit counter */ +#define CCM_TASKS_CRYPT_DELAY_BITS 3 +#endif /* CONFIG_BT_CTLR_DF_CONN_CTE_RX */ +#else /* !CONFIG_BT_CTLR_DF */ /* Wrapper for EVENTS_END event generated by Radio peripheral at the very end of the transmission * or reception of a PDU on air. In case of regular PDU it is generated when last bit of CRC is * received or transmitted. */ -#define HAL_RADIO_TRX_EVENTS_END HAL_RADIO_EVENTS_END +#define HAL_RADIO_TRX_EVENTS_END HAL_RADIO_EVENTS_END +#define HAL_NRF_RADIO_TRX_EVENT_END HAL_NRF_RADIO_EVENT_END /* Wrapper for RADIO_SHORTS mask connecting EVENTS_END to EVENTS_DISABLE. * This is a default shortcut used to automatically disable Radio after end of PDU. */ #define NRF_RADIO_SHORTS_TRX_END_DISABLE_Msk HAL_RADIO_SHORTS_TRX_END_DISABLE_Msk +#endif /* !CONFIG_BT_CTLR_DF */ #define HAL_EVENT_TIMER_TRX_CC_OFFSET 0 #define HAL_EVENT_TIMER_TRX_EVENT NRF_TIMER_EVENT_COMPARE0 @@ -135,7 +139,6 @@ #define HAL_EVENT_TIMER_PA_LNA_CC_OFFSET 2 #define HAL_EVENT_TIMER_PA_LNA_PDN_CC_OFFSET 3 -#endif /* !CONFIG_BT_CTLR_PHY_CODED */ #else /* !CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER */ #define EVENT_TIMER_ID 0 @@ -155,7 +158,6 @@ #endif /* !CONFIG_BT_CTLR_PHY_CODED */ #if defined(CONFIG_BT_CTLR_DF) - #if defined(CONFIG_BT_CTLR_DF_PHYEND_OFFSET_COMPENSATION_ENABLE) /* Allocate 2 adjacent channels for PHYEND delay compensation. Use the same channels as for * PHY CODED S2. The CTEINLINE may not be enabled for PHY CODED so PHYEND event is generated @@ -173,7 +175,8 @@ * including CTE EVENTS_PHYEND event is generated at very end of a PDU. In case there is no CTE in * a PDU the EVENTS_PHYEND event is generated in the same instant as EVENTS_END event. */ -#define HAL_RADIO_TRX_EVENTS_END HAL_RADIO_EVENTS_PHYEND +#define HAL_RADIO_TRX_EVENTS_END HAL_RADIO_EVENTS_PHYEND +#define HAL_NRF_RADIO_TRX_EVENT_END HAL_NRF_RADIO_EVENT_PHYEND /* Wrapper for RADIO_SHORTS mask connecting EVENTS_PHYEND to EVENTS_DISABLE. * This is a mask for SOC that has Direction Finding Extension in a Radio peripheral. @@ -196,7 +199,8 @@ * or reception of a PDU on air. In case of regular PDU it is generated when last bit of CRC is * received or transmitted. */ -#define HAL_RADIO_TRX_EVENTS_END HAL_RADIO_EVENTS_END +#define HAL_RADIO_TRX_EVENTS_END HAL_RADIO_EVENTS_END +#define HAL_NRF_RADIO_TRX_EVENT_END HAL_NRF_RADIO_EVENT_END /* Wrapper for RADIO_SHORTS mask connecting EVENTS_END to EVENTS_DISABLE. * This is a default shortcut used to automatically disable Radio after end of PDU. diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan.c index 5f51c55f4255d..8aedcd44a4f88 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan.c @@ -1381,9 +1381,10 @@ static inline int isr_rx_pdu(struct lll_scan *lll, struct pdu_adv *pdu_adv_rx, rl_idx, &dir_report))) || #if defined(CONFIG_BT_CTLR_ADV_EXT) ((pdu_adv_rx->type == PDU_ADV_TYPE_EXT_IND) && - lll->phy && lll_scan_ext_tgta_check(lll, true, false, - pdu_adv_rx, rl_idx, - &dir_report)) || + lll->phy && + !lll->state && + lll_scan_ext_tgta_check(lll, true, false, pdu_adv_rx, rl_idx, + &dir_report)) || #endif /* CONFIG_BT_CTLR_ADV_EXT */ ((pdu_adv_rx->type == PDU_ADV_TYPE_SCAN_RSP) && (pdu_adv_rx->len >= offsetof(struct pdu_adv_scan_rsp, data)) &&