Skip to content

Commit 5dfc58c

Browse files
cvinayakcarlescufi
authored andcommitted
Bluetooth: Controller: Fix single switch timer minimum compare value
Fix implementation of single switch timer minimum compare value requirement. Do not always add the maximum possible radio latency duration, but check if the required compare value is smaller, then use the remainder required as the extra compare value. This fix reduces latencies to setup radio receptions and fixes an assertion in lll_scan_aux when radio_tmr_start_us() is checked for latencies. Relates to commit bcd28e0 ("Bluetooth: Controller: Fix sw switch single timer for spurious TXEN/RXEN"). Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent 7ac41a1 commit 5dfc58c

File tree

1 file changed

+11
-7
lines changed
  • subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio

1 file changed

+11
-7
lines changed

subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,10 +1349,12 @@ uint32_t radio_tmr_start(uint8_t trx, uint32_t ticks_start, uint32_t remainder)
13491349
* by the Radio ISR, the compare will trigger again.
13501350
*/
13511351
uint32_t latency_ticks;
1352+
uint32_t latency_us;
13521353

1353-
latency_ticks = HAL_TICKER_US_TO_TICKS(HAL_RADIO_ISR_LATENCY_MAX_US);
1354+
latency_us = MAX(remainder, HAL_RADIO_ISR_LATENCY_MAX_US) - remainder;
1355+
latency_ticks = HAL_TICKER_US_TO_TICKS(latency_us);
13541356
ticks_start -= latency_ticks;
1355-
remainder += HAL_TICKER_TICKS_TO_US(latency_ticks);
1357+
remainder += latency_us;
13561358
#endif /* !CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER */
13571359

13581360
nrf_timer_task_trigger(EVENT_TIMER, NRF_TIMER_TASK_CLEAR);
@@ -1473,10 +1475,12 @@ uint32_t radio_tmr_start_tick(uint8_t trx, uint32_t ticks_start)
14731475
* by the Radio ISR, the compare will trigger again.
14741476
*/
14751477
uint32_t latency_ticks;
1478+
uint32_t latency_us;
14761479

1477-
latency_ticks = HAL_TICKER_US_TO_TICKS(HAL_RADIO_ISR_LATENCY_MAX_US);
1480+
latency_us = MAX(remainder_us, HAL_RADIO_ISR_LATENCY_MAX_US) - remainder_us;
1481+
latency_ticks = HAL_TICKER_US_TO_TICKS(latency_us);
14781482
ticks_start -= latency_ticks;
1479-
remainder_us += HAL_TICKER_TICKS_TO_US(latency_ticks);
1483+
remainder_us += latency_us;
14801484
#endif /* !CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER */
14811485

14821486
nrf_timer_task_trigger(EVENT_TIMER, NRF_TIMER_TASK_STOP);
@@ -1614,10 +1618,10 @@ uint32_t radio_tmr_start_us(uint8_t trx, uint32_t start_us)
16141618
* The timer is cleared on Radio End and if the PPI/DPPI is not disabled
16151619
* by the Radio ISR, the compare will trigger again.
16161620
*/
1617-
uint32_t latency_ticks;
1621+
uint32_t latency_us;
16181622

1619-
latency_ticks = HAL_TICKER_US_TO_TICKS(HAL_RADIO_ISR_LATENCY_MAX_US);
1620-
actual_us += HAL_TICKER_TICKS_TO_US(latency_ticks);
1623+
latency_us = MAX(actual_us, HAL_RADIO_ISR_LATENCY_MAX_US) - actual_us;
1624+
actual_us += latency_us;
16211625
#endif /* !CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER */
16221626

16231627
nrf_timer_event_clear(EVENT_TIMER, NRF_TIMER_EVENT_COMPARE0);

0 commit comments

Comments
 (0)