Skip to content

Commit

Permalink
Bluetooth: controller: nRF53 sw_switch always required Radio End
Browse files Browse the repository at this point in the history
nRF53 implementation of sw_switch always requires Radio End
event, hence optimize out redundant code due to explicit use
of radio_tmr_end_capture.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
  • Loading branch information
cvinayak authored and carlescufi committed Apr 22, 2021
1 parent 0426b1d commit 377d168
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
25 changes: 20 additions & 5 deletions subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -585,12 +585,19 @@ static void sw_switch(uint8_t dir, uint8_t phy_curr, uint8_t flags_curr, uint8_t
hal_radio_nrf_ppi_channels_enable(BIT(HAL_SW_SWITCH_TIMER_CLEAR_PPI) |
BIT(HAL_SW_SWITCH_GROUP_TASK_ENABLE_PPI));

#if defined(CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER)
/* Since the event timer is cleared on END, we
* always need to capture the PDU END time-stamp.
#if defined(CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER) || \
defined(CONFIG_SOC_SERIES_NRF53X)
/* NOTE: nRF5340 shares the DPPI channel being triggered by Radio End
* for End time capture and sw_switch DPPI channel toggling hence
* always need to capture End time. Or when using single event
* timer since the timer is cleared on Radio End, we always need
* to capture the Radio End time-stamp.
*/
radio_tmr_end_capture();
#endif /* CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER */
hal_radio_end_time_capture_ppi_config();
#if !defined(CONFIG_SOC_SERIES_NRF53X)
hal_radio_nrf_ppi_channels_enable(BIT(HAL_RADIO_END_TIME_CAPTURE_PPI));
#endif /* !CONFIG_SOC_SERIES_NRF53X */
#endif /* CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER || CONFIG_SOC_SERIES_NRF53X */

sw_tifs_toggle += 1U;
sw_tifs_toggle &= 1U;
Expand Down Expand Up @@ -950,8 +957,16 @@ uint32_t radio_tmr_ready_get(void)

void radio_tmr_end_capture(void)
{
/* NOTE: nRF5340 shares the DPPI channel being triggered by Radio End
* for End time capture and sw_switch DPPI channel toggling hence
* always need to capture End time. Hence, the below code is
* present in hal_sw_switch_timer_clear_ppi_config() and
* sw_switch().
*/
#if defined(CONFIG_BT_CTLR_TIFS_HW) || !defined(CONFIG_SOC_SERIES_NRF53X)
hal_radio_end_time_capture_ppi_config();
hal_radio_nrf_ppi_channels_enable(BIT(HAL_RADIO_END_TIME_CAPTURE_PPI));
#endif /* CONFIG_BT_CTLR_TIFS_HW || !CONFIG_SOC_SERIES_NRF53X */
}

uint32_t radio_tmr_end_get(void)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,13 @@ static inline void hal_sw_switch_timer_clear_ppi_config(void)
nrf_radio_publish_set(NRF_RADIO, NRF_RADIO_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);

/* NOTE: nRF5340 shares the DPPI channel being triggered by Radio End,
* for End time capture and sw_switch DPPI channel toggling, hence
* always need to capture End time.
*/
nrf_dppi_channels_enable(NRF_DPPIC,
BIT(HAL_RADIO_END_TIME_CAPTURE_PPI));
}

/* The 2 adjacent PPI groups used for implementing SW_SWITCH_TIMER-based
Expand Down

0 comments on commit 377d168

Please sign in to comment.