Skip to content

Commit e7799d4

Browse files
cvinayakfabiobaltieri
authored andcommitted
Bluetooth: Controller: Separate Tx/Rx frame spacing
Separate Tx/Rx frame spacing. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent cbae5d5 commit e7799d4

File tree

13 files changed

+55
-25
lines changed

13 files changed

+55
-25
lines changed

subsys/bluetooth/controller/ll_sw/lll_conn.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,15 @@ struct lll_conn {
4343
uint8_t access_addr[4];
4444
uint8_t crc_init[3];
4545

46+
uint16_t tifs_tx_us;
47+
uint16_t tifs_rx_us;
48+
uint16_t tifs_hcto_us;
49+
uint16_t tifs_cis_us;
50+
4651
uint16_t handle;
4752
uint16_t interval;
48-
uint16_t latency;
4953

54+
uint16_t latency;
5055
uint16_t latency_prepare;
5156
uint16_t lazy_prepare;
5257
uint16_t latency_event;

subsys/bluetooth/controller/ll_sw/lll_conn_iso.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ struct lll_conn_iso_stream {
3636
uint32_t offset; /* Offset of CIS from start of CIG in us */
3737
uint32_t sub_interval; /* Interval between subevents in us */
3838
uint8_t nse:5; /* Number of subevents */
39+
40+
/* Frame Spacing */
41+
uint16_t tifs_us;
42+
43+
/* Stream parameters */
3944
struct lll_conn_iso_stream_rxtx rx; /* RX parameters */
4045
struct lll_conn_iso_stream_rxtx tx; /* TX parameters */
4146

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_central.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ static int prepare_cb(struct lll_prepare_param *p)
186186

187187
radio_isr_set(lll_conn_isr_tx, lll);
188188

189-
radio_tmr_tifs_set(EVENT_IFS_US);
189+
radio_tmr_tifs_set(lll->tifs_rx_us);
190190

191191
#if defined(CONFIG_BT_CTLR_DF_CONN_CTE_RX)
192192
/* If CTE RX is enabled and the PHY is not CODED, store channel used for

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_central_iso.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ static int prepare_cb(struct lll_prepare_param *p)
306306

307307
radio_isr_set(isr_tx, cis_lll);
308308

309-
radio_tmr_tifs_set(EVENT_IFS_US);
309+
radio_tmr_tifs_set(cis_lll->tifs_us);
310310

311311
#if defined(CONFIG_BT_CTLR_PHY)
312312
radio_switch_complete_and_rx(cis_lll->rx.phy);
@@ -501,7 +501,7 @@ static void isr_tx(void *param)
501501
LL_ASSERT(!radio_is_ready());
502502

503503
/* +/- 2us active clock jitter, +1 us PPI to timer start compensation */
504-
hcto = radio_tmr_tifs_base_get() + EVENT_IFS_US +
504+
hcto = radio_tmr_tifs_base_get() + cis_lll->tifs_us +
505505
(EVENT_CLOCK_JITTER_US << 1) + RANGE_DELAY_US +
506506
HAL_RADIO_TMR_START_DELAY_US;
507507

@@ -527,13 +527,13 @@ static void isr_tx(void *param)
527527
radio_gpio_lna_setup();
528528

529529
#if defined(CONFIG_BT_CTLR_PHY)
530-
radio_gpio_pa_lna_enable(radio_tmr_tifs_base_get() + EVENT_IFS_US -
530+
radio_gpio_pa_lna_enable(radio_tmr_tifs_base_get() + cis_lll->tifs_us -
531531
(EVENT_CLOCK_JITTER_US << 1) -
532532
radio_tx_chain_delay_get(cis_lll->tx.phy,
533533
cis_lll->tx.phy_flags) -
534534
HAL_RADIO_GPIO_LNA_OFFSET);
535535
#else /* !CONFIG_BT_CTLR_PHY */
536-
radio_gpio_pa_lna_enable(radio_tmr_tifs_base_get() + EVENT_IFS_US -
536+
radio_gpio_pa_lna_enable(radio_tmr_tifs_base_get() + cis_lll->tifs_us -
537537
(EVENT_CLOCK_JITTER_US << 1) -
538538
radio_tx_chain_delay_get(0U, 0U) -
539539
HAL_RADIO_GPIO_LNA_OFFSET);
@@ -1044,7 +1044,7 @@ static void isr_prepare_subevent(void *param)
10441044
radio_tmr_rx_disable();
10451045
radio_tmr_tx_enable();
10461046

1047-
radio_tmr_tifs_set(EVENT_IFS_US);
1047+
radio_tmr_tifs_set(cis_lll->tifs_us);
10481048

10491049
#if defined(CONFIG_BT_CTLR_PHY)
10501050
radio_switch_complete_and_rx(cis_lll->rx.phy);

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_conn.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ void lll_conn_isr_rx(void *param)
403403
#endif /* CONFIG_BT_PERIPHERAL */
404404
}
405405
} else {
406-
radio_tmr_tifs_set(EVENT_IFS_US);
406+
radio_tmr_tifs_set(lll->tifs_rx_us);
407407

408408
#if defined(CONFIG_BT_CTLR_PHY)
409409
radio_switch_complete_and_rx(lll->phy_rx);
@@ -436,7 +436,7 @@ void lll_conn_isr_rx(void *param)
436436
radio_gpio_pa_setup();
437437

438438
pa_lna_enable_us =
439-
radio_tmr_tifs_base_get() + EVENT_IFS_US + cte_len - HAL_RADIO_GPIO_PA_OFFSET;
439+
radio_tmr_tifs_base_get() + lll->tifs_tx_us - cte_len - HAL_RADIO_GPIO_PA_OFFSET;
440440
#if defined(CONFIG_BT_CTLR_PHY)
441441
pa_lna_enable_us -= radio_rx_chain_delay_get(lll->phy_rx, PHY_FLAGS_S8);
442442
#else /* !CONFIG_BT_CTLR_PHY */
@@ -462,7 +462,7 @@ void lll_conn_isr_rx(void *param)
462462
lll->empty = 0U;
463463

464464
/* Setup deferred tx packet set */
465-
tx_defer_us = radio_tmr_tifs_base_get() + EVENT_IFS_US -
465+
tx_defer_us = radio_tmr_tifs_base_get() + lll->tifs_tx_us -
466466
HAL_RADIO_TMR_DEFERRED_TX_DELAY_US;
467467
defer_us = radio_tmr_isr_set(tx_defer_us, isr_tx_deferred_set,
468468
param);
@@ -575,11 +575,11 @@ void lll_conn_isr_tx(void *param)
575575
/* Clear radio tx status and events */
576576
lll_isr_tx_status_reset();
577577

578-
/* setup tIFS switching */
579-
radio_tmr_tifs_set(EVENT_IFS_US);
580-
581578
lll = param;
582579

580+
/* setup tIFS switching */
581+
radio_tmr_tifs_set(lll->tifs_tx_us);
582+
583583
#if defined(CONFIG_BT_CTLR_DF_CONN_CTE_RX)
584584
#if defined(CONFIG_BT_CTLR_DF_PHYEND_OFFSET_COMPENSATION_ENABLE)
585585
enum radio_end_evt_delay_state end_evt_delay;
@@ -616,6 +616,7 @@ void lll_conn_isr_tx(void *param)
616616

617617
#if defined(CONFIG_BT_CTLR_DF_PHYEND_OFFSET_COMPENSATION_ENABLE)
618618
/* Use special API for SOC that requires compensation for PHYEND event delay. */
619+
619620
#if defined(CONFIG_BT_CTLR_PHY)
620621
radio_switch_complete_with_delay_compensation_and_tx(lll->phy_rx, 0, lll->phy_tx,
621622
lll->phy_flags, end_evt_delay);
@@ -660,7 +661,7 @@ void lll_conn_isr_tx(void *param)
660661
#endif /* CONFIG_BT_CTLR_DF_CONN_CTE_TX */
661662

662663
/* +/- 2us active clock jitter, +1 us PPI to timer start compensation */
663-
hcto = radio_tmr_tifs_base_get() + EVENT_IFS_US +
664+
hcto = radio_tmr_tifs_base_get() + lll->tifs_hcto_us +
664665
(EVENT_CLOCK_JITTER_US << 1) + RANGE_DELAY_US +
665666
HAL_RADIO_TMR_START_DELAY_US;
666667
#if defined(CONFIG_BT_CTLR_DF_CONN_CTE_TX)
@@ -701,13 +702,15 @@ void lll_conn_isr_tx(void *param)
701702
#if defined(HAL_RADIO_GPIO_HAVE_LNA_PIN)
702703
radio_gpio_lna_setup();
703704
#if defined(CONFIG_BT_CTLR_PHY)
704-
radio_gpio_pa_lna_enable(radio_tmr_tifs_base_get() + EVENT_IFS_US - 4 -
705+
radio_gpio_pa_lna_enable(radio_tmr_tifs_base_get() + lll->tifs_rx_us -
706+
(EVENT_CLOCK_JITTER_US << 1) -
705707
radio_tx_chain_delay_get(lll->phy_tx,
706708
lll->phy_flags) -
707709
HAL_RADIO_GPIO_LNA_OFFSET);
708710
#else /* !CONFIG_BT_CTLR_PHY */
709-
radio_gpio_pa_lna_enable(radio_tmr_tifs_base_get() + EVENT_IFS_US - 4 -
710-
radio_tx_chain_delay_get(0, 0) -
711+
radio_gpio_pa_lna_enable(radio_tmr_tifs_base_get() + lll->tifs_rx_us -
712+
(EVENT_CLOCK_JITTER_US << 1) -
713+
radio_tx_chain_delay_get(0U, 0U) -
711714
HAL_RADIO_GPIO_LNA_OFFSET);
712715
#endif /* !CONFIG_BT_CTLR_PHY */
713716
#endif /* HAL_RADIO_GPIO_HAVE_LNA_PIN */

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_peripheral.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ static int prepare_cb(struct lll_prepare_param *p)
211211

212212
radio_isr_set(lll_conn_isr_rx, lll);
213213

214-
radio_tmr_tifs_set(EVENT_IFS_US);
214+
radio_tmr_tifs_set(lll->tifs_tx_us);
215215

216216
#if defined(CONFIG_BT_CTLR_DF_CONN_CTE_RX)
217217
#if defined(CONFIG_BT_CTLR_DF_PHYEND_OFFSET_COMPENSATION_ENABLE)

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_peripheral_iso.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ static int prepare_cb(struct lll_prepare_param *p)
261261

262262
radio_isr_set(isr_rx, cis_lll);
263263

264-
radio_tmr_tifs_set(EVENT_IFS_US);
264+
radio_tmr_tifs_set(cis_lll->tifs_us);
265265

266266
#if defined(CONFIG_BT_CTLR_PHY)
267267
radio_switch_complete_and_tx(cis_lll->rx.phy, 0U, cis_lll->tx.phy,
@@ -743,7 +743,7 @@ static void isr_rx(void *param)
743743

744744
radio_gpio_pa_setup();
745745

746-
pa_lna_enable_us = radio_tmr_tifs_base_get() + EVENT_IFS_US -
746+
pa_lna_enable_us = radio_tmr_tifs_base_get() + cis_lll->tifs_us -
747747
HAL_RADIO_GPIO_PA_OFFSET;
748748
#if defined(CONFIG_BT_CTLR_PHY)
749749
pa_lna_enable_us -= radio_rx_chain_delay_get(cis_lll->rx.phy,
@@ -897,7 +897,7 @@ static void isr_tx(void *param)
897897
radio_tmr_tx_disable();
898898
radio_tmr_rx_enable();
899899

900-
radio_tmr_tifs_set(EVENT_IFS_US);
900+
radio_tmr_tifs_set(cis_lll->tifs_us);
901901

902902
#if defined(CONFIG_BT_CTLR_PHY)
903903
radio_switch_complete_and_tx(cis_lll->rx.phy, 0U, cis_lll->tx.phy,
@@ -1114,7 +1114,7 @@ static void isr_prepare_subevent_common(void *param)
11141114
radio_tmr_tx_disable();
11151115
radio_tmr_rx_enable();
11161116

1117-
radio_tmr_tifs_set(EVENT_IFS_US);
1117+
radio_tmr_tifs_set(cis_lll->tifs_us);
11181118

11191119
#if defined(CONFIG_BT_CTLR_PHY)
11201120
radio_switch_complete_and_tx(cis_lll->rx.phy, 0U, cis_lll->tx.phy,

subsys/bluetooth/controller/ll_sw/pdu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@
185185
#define EVENT_CLOCK_JITTER_US 2
186186
/* Event interframe timings */
187187
#define EVENT_IFS_US 150
188+
/* Event interframe timings, default */
189+
#define EVENT_IFS_DEFAULT_US EVENT_IFS_US
188190
/* Standard allows 2 us timing uncertainty inside the event */
189191
#define EVENT_IFS_MAX_US (EVENT_IFS_US + EVENT_CLOCK_JITTER_US)
190192
/* Specification defined Minimum AUX Frame Space (MAFS) */

subsys/bluetooth/controller/ll_sw/ull_central.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,11 @@ uint8_t ll_create_connection(uint16_t scan_interval, uint16_t scan_window,
311311
/* Re-initialize the Tx Q */
312312
ull_tx_q_init(&conn->tx_q);
313313

314+
conn_lll->tifs_tx_us = EVENT_IFS_DEFAULT_US;
315+
conn_lll->tifs_rx_us = EVENT_IFS_DEFAULT_US;
316+
conn_lll->tifs_hcto_us = EVENT_IFS_DEFAULT_US;
317+
conn_lll->tifs_cis_us = EVENT_IFS_DEFAULT_US;
318+
314319
/* TODO: active_to_start feature port */
315320
conn->ull.ticks_active_to_start = 0U;
316321
conn->ull.ticks_prepare_to_start =
@@ -363,7 +368,7 @@ uint8_t ll_create_connection(uint16_t scan_interval, uint16_t scan_window,
363368

364369
/* Calculate event time reservation */
365370
slot_us = max_tx_time + max_rx_time;
366-
slot_us += EVENT_IFS_US + (EVENT_CLOCK_JITTER_US << 1);
371+
slot_us += conn_lll->tifs_rx_us + (EVENT_CLOCK_JITTER_US << 1);
367372
slot_us += ready_delay_us;
368373
slot_us += EVENT_OVERHEAD_START_US + EVENT_OVERHEAD_END_US;
369374

subsys/bluetooth/controller/ll_sw/ull_central_iso.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,7 @@ uint8_t ull_central_iso_setup(uint16_t cis_handle,
931931
#endif /* CONFIG_BT_CTLR_ISOAL_PSN_IGNORE */
932932
cis->lll.event_count = LLL_CONN_ISO_EVENT_COUNT_MAX;
933933
cis->lll.next_subevent = 0U;
934+
cis->lll.tifs_us = conn->lll.tifs_cis_us;
934935
cis->lll.sn = 0U;
935936
cis->lll.nesn = 0U;
936937
cis->lll.cie = 0U;

0 commit comments

Comments
 (0)