diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_sync_iso.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_sync_iso.c index 5eeba29b5e8..d20be607915 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_sync_iso.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_sync_iso.c @@ -56,7 +56,8 @@ static void next_chan_calc(struct lll_sync_iso *lll, uint16_t event_counter, static void isr_rx_iso_data_valid(const struct lll_sync_iso *const lll, uint16_t handle, struct node_rx_pdu *node_rx); static void isr_rx_iso_data_invalid(const struct lll_sync_iso *const lll, - uint8_t bn, uint16_t handle, + uint16_t latency, uint8_t bn, + uint16_t handle, struct node_rx_pdu *node_rx); static void isr_rx_ctrl_recv(struct lll_sync_iso *lll, struct pdu_bis *pdu); @@ -1160,7 +1161,6 @@ static void isr_rx_done(void *param) uint16_t latency_event; uint16_t payload_index; uint8_t bis_idx; - uint8_t bn; /* Enqueue PDUs to ULL */ node_rx = NULL; @@ -1191,8 +1191,7 @@ static void isr_rx_done(void *param) } payload_tail = lll->payload_tail; - bn = lll->bn; - while (bn--) { + for (uint8_t bn = 0U; bn < lll->bn; bn++) { if (lll->payload[stream_curr][payload_tail]) { node_rx = lll->payload[stream_curr][payload_tail]; lll->payload[stream_curr][payload_tail] = NULL; @@ -1217,7 +1216,8 @@ static void isr_rx_done(void *param) pdu->len = 0U; handle = LL_BIS_SYNC_HANDLE_FROM_IDX(stream_handle); - isr_rx_iso_data_invalid(lll, bn, handle, node_rx); + isr_rx_iso_data_invalid(lll, latency_event, bn, + handle, node_rx); iso_rx_put(node_rx->hdr.link, node_rx); } @@ -1363,7 +1363,9 @@ static void isr_rx_iso_data_valid(const struct lll_sync_iso *const lll, iso_meta = &node_rx->rx_iso_meta; iso_meta->payload_number = lll->payload_count + (lll->bn_curr - 1U) + - (lll->ptc_curr * lll->pto) - lll->bn; + (lll->ptc_curr * lll->pto); + /* Decrement BN as payload_count was pre-incremented */ + iso_meta->payload_number -= lll->bn; stream = ull_sync_iso_lll_stream_get(lll->stream_handle[0]); iso_meta->timestamp = HAL_TICKER_TICKS_TO_US(radio_tmr_start_get()) + @@ -1381,7 +1383,8 @@ static void isr_rx_iso_data_valid(const struct lll_sync_iso *const lll, } static void isr_rx_iso_data_invalid(const struct lll_sync_iso *const lll, - uint8_t bn, uint16_t handle, + uint16_t latency, uint8_t bn, + uint16_t handle, struct node_rx_pdu *node_rx) { struct lll_sync_iso_stream *stream; @@ -1391,7 +1394,9 @@ static void isr_rx_iso_data_invalid(const struct lll_sync_iso *const lll, node_rx->hdr.handle = handle; iso_meta = &node_rx->rx_iso_meta; - iso_meta->payload_number = lll->payload_count - bn - 1U; + iso_meta->payload_number = lll->payload_count + bn; + /* Decrement BN as payload_count was pre-incremented */ + iso_meta->payload_number -= (latency + 1U) * lll->bn; stream = ull_sync_iso_lll_stream_get(lll->stream_handle[0]); iso_meta->timestamp = HAL_TICKER_TICKS_TO_US(radio_tmr_start_get()) + @@ -1399,6 +1404,8 @@ static void isr_rx_iso_data_invalid(const struct lll_sync_iso *const lll, ((stream->bis_index - 1U) * lll->sub_interval * ((lll->irc * lll->bn) + lll->ptc)); + iso_meta->timestamp -= (latency * lll->iso_interval * + PERIODIC_INT_UNIT_US); iso_meta->timestamp %= HAL_TICKER_TICKS_TO_US_64BIT(BIT64(HAL_TICKER_CNTR_MSBIT + 1U)); iso_meta->status = 1U;