Skip to content

Commit fec5bbb

Browse files
alexandru-porosanu-nxpcarlescufi
authored andcommitted
Bluetooth: controller: openisa: sync with Nordic SW LL
There are some changes that were introduced to the Nordic SW LL, and as such, in order to maintain compatibility, propragate them to the OpenISA SW LL as well. Signed-off-by: Alex Porosanu <[email protected]>
1 parent 40ac3c4 commit fec5bbb

File tree

6 files changed

+31
-72
lines changed

6 files changed

+31
-72
lines changed

subsys/bluetooth/controller/ll_sw/openisa/lll/lll.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,9 @@ static int prepare(lll_is_abort_cb_t is_abort_cb, lll_abort_cb_t abort_cb,
387387
lll_prepare_cb_t prepare_cb, int prio,
388388
struct lll_prepare_param *prepare_param, u8_t is_resume)
389389
{
390-
struct lll_event *p;
391390
u8_t idx = UINT8_MAX;
391+
struct lll_event *p;
392+
int ret, err;
392393

393394
/* Find the ready prepare in the pipeline */
394395
p = ull_prepare_dequeue_iter(&idx);
@@ -407,7 +408,6 @@ static int prepare(lll_is_abort_cb_t is_abort_cb, lll_abort_cb_t abort_cb,
407408
struct lll_event *next;
408409
int resume_prio;
409410
#endif /* CONFIG_BT_CTLR_LOW_LAT */
410-
int ret;
411411

412412
if (IS_ENABLED(CONFIG_BT_CTLR_LOW_LAT) && event.curr.param) {
413413
/* early abort */
@@ -486,7 +486,16 @@ static int prepare(lll_is_abort_cb_t is_abort_cb, lll_abort_cb_t abort_cb,
486486
event.curr.is_abort_cb = is_abort_cb;
487487
event.curr.abort_cb = abort_cb;
488488

489-
return prepare_cb(prepare_param);
489+
err = prepare_cb(prepare_param);
490+
491+
/* Stop running pre-empt timer, if any */
492+
ret = ticker_stop(TICKER_INSTANCE_ID_CTLR, TICKER_USER_ID_LLL,
493+
TICKER_ID_LLL_PREEMPT, NULL, NULL);
494+
LL_ASSERT((ret == TICKER_STATUS_SUCCESS) ||
495+
(ret == TICKER_STATUS_FAILURE) ||
496+
(ret == TICKER_STATUS_BUSY));
497+
498+
return err;
490499
}
491500

492501
static int resume_enqueue(lll_prepare_cb_t resume_cb, int resume_prio)

subsys/bluetooth/controller/ll_sw/openisa/lll/lll_adv.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,8 @@ static void isr_tx(void *param)
361361
*/
362362
radio_tmr_end_capture();
363363

364-
if (IS_ENABLED(CONFIG_BT_CTLR_SCAN_REQ_RSSI)) {
364+
if (IS_ENABLED(CONFIG_BT_CTLR_SCAN_REQ_RSSI) ||
365+
IS_ENABLED(CONFIG_BT_CTLR_CONN_RSSI)) {
365366
radio_rssi_measure();
366367
}
367368

@@ -716,6 +717,11 @@ static inline int isr_rx_pdu(struct lll_adv *lll,
716717
lll_prof_cputime_capture();
717718
}
718719

720+
#if defined(CONFIG_BT_CTLR_CONN_RSSI)
721+
if (rssi_ready) {
722+
lll->conn->rssi_latest = radio_rssi_get();
723+
}
724+
#endif /* CONFIG_BT_CTLR_CONN_RSSI */
719725
/* Stop further LLL radio events */
720726
ret = lll_stop(lll);
721727
LL_ASSERT(!ret);

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

Lines changed: 2 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -536,76 +536,14 @@ void lll_conn_pdu_tx_prep(struct lll_conn *lll, struct pdu_data **pdu_data_tx)
536536
p->len = lll->packet_tx_head_len - lll->packet_tx_head_offset;
537537
p->md = 0;
538538

539-
#if defined(CONFIG_BT_CTLR_DATA_LENGTH)
540-
#if defined(CONFIG_BT_CTLR_PHY)
541-
switch (lll->phy_tx_time) {
542-
default:
543-
case BIT(0):
544-
/* 1M PHY, 1us = 1 bit, hence divide by 8.
545-
* Deduct 10 bytes for preamble (1), access address (4),
546-
* header (2), and CRC (3).
547-
*/
548-
max_tx_octets = (lll->max_tx_time >> 3) - 10;
549-
break;
550-
551-
case BIT(1):
552-
/* 2M PHY, 1us = 2 bits, hence divide by 4.
553-
* Deduct 11 bytes for preamble (2), access address (4),
554-
* header (2), and CRC (3).
555-
*/
556-
max_tx_octets = (lll->max_tx_time >> 2) - 11;
557-
break;
558-
559-
#if defined(CONFIG_BT_CTLR_PHY_CODED)
560-
case BIT(2):
561-
if (lll->phy_flags & 0x01) {
562-
/* S8 Coded PHY, 8us = 1 bit, hence divide by
563-
* 64.
564-
* Subtract time for preamble (80), AA (256),
565-
* CI (16), TERM1 (24), CRC (192) and
566-
* TERM2 (24), total 592 us.
567-
* Subtract 2 bytes for header.
568-
*/
569-
max_tx_octets = ((lll->max_tx_time - 592) >>
570-
6) - 2;
571-
} else {
572-
/* S2 Coded PHY, 2us = 1 bit, hence divide by
573-
* 16.
574-
* Subtract time for preamble (80), AA (256),
575-
* CI (16), TERM1 (24), CRC (48) and
576-
* TERM2 (6), total 430 us.
577-
* Subtract 2 bytes for header.
578-
*/
579-
max_tx_octets = ((lll->max_tx_time - 430) >>
580-
4) - 2;
581-
}
582-
break;
583-
#endif /* CONFIG_BT_CTLR_PHY_CODED */
584-
}
585-
586-
#if defined(CONFIG_BT_CTLR_LE_ENC)
587-
if (lll->enc_tx) {
588-
/* deduct the MIC */
589-
max_tx_octets -= 4U;
590-
}
591-
#endif /* CONFIG_BT_CTLR_LE_ENC */
592-
593-
if (max_tx_octets > lll->max_tx_octets) {
594-
max_tx_octets = lll->max_tx_octets;
595-
}
596-
#else /* !CONFIG_BT_CTLR_PHY */
597-
max_tx_octets = lll->max_tx_octets;
598-
#endif /* !CONFIG_BT_CTLR_PHY */
599-
#else /* !CONFIG_BT_CTLR_DATA_LENGTH */
600-
max_tx_octets = PDU_DC_PAYLOAD_SIZE_MIN;
601-
#endif /* !CONFIG_BT_CTLR_DATA_LENGTH */
539+
max_tx_octets = ull_conn_lll_max_tx_octets_get(lll);
602540

603541
if (p->len > max_tx_octets) {
604542
p->len = max_tx_octets;
605543
p->md = 1;
606544
}
607545

608-
if (link->next) {
546+
if (link->next != lll->memq_tx.tail) {
609547
p->md = 1;
610548
}
611549
}

subsys/bluetooth/controller/ll_sw/openisa/lll/lll_master.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ static int prepare_cb(struct lll_prepare_param *prepare_param)
8585
struct evt_hdr *evt;
8686
u16_t event_counter;
8787
u32_t remainder_us;
88-
u8_t data_chan_use = 0;
88+
u8_t data_chan_use;
8989
u32_t remainder;
9090
u16_t lazy;
9191

subsys/bluetooth/controller/ll_sw/openisa/lll/lll_scan.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ static inline u32_t isr_rx_pdu(struct lll_scan *lll, u8_t devmatch_ok,
704704
evt = HDR_LLL2EVT(lll);
705705
if (pdu_end_us > (HAL_TICKER_TICKS_TO_US(evt->ticks_slot) -
706706
502 - EVENT_OVERHEAD_START_US -
707-
(EVENT_JITTER_US << 1))) {
707+
EVENT_TICKER_RES_MARGIN_US)) {
708708
return -ETIME;
709709
}
710710

@@ -804,6 +804,12 @@ static inline u32_t isr_rx_pdu(struct lll_scan *lll, u8_t devmatch_ok,
804804
CONFIG_BT_CTLR_GPIO_PA_OFFSET);
805805
#endif /* CONFIG_BT_CTLR_GPIO_PA_PIN */
806806

807+
#if defined(CONFIG_BT_CTLR_CONN_RSSI)
808+
if (rssi_ready) {
809+
lll_conn->rssi_latest = radio_rssi_get();
810+
}
811+
#endif /* CONFIG_BT_CTLR_CONN_RSSI */
812+
807813
/* block CPU so that there is no CRC error on pdu tx,
808814
* this is only needed if we want the CPU to sleep.
809815
* while(!radio_has_disabled())

subsys/bluetooth/controller/ll_sw/openisa/lll/lll_slave.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static int prepare_cb(struct lll_prepare_param *prepare_param)
8484
struct evt_hdr *evt;
8585
u16_t event_counter;
8686
u32_t remainder_us;
87-
u8_t data_chan_use = 0;
87+
u8_t data_chan_use;
8888
u32_t remainder;
8989
u32_t hcto;
9090
u16_t lazy;
@@ -251,7 +251,7 @@ static int prepare_cb(struct lll_prepare_param *prepare_param)
251251
LL_ASSERT(!ret);
252252
}
253253

254-
DEBUG_RADIO_START_S(0);
254+
DEBUG_RADIO_START_S(1);
255255

256256
return 0;
257257
}

0 commit comments

Comments
 (0)