Commit 4149e391 authored by Vinayak Kariappa Chettimada's avatar Vinayak Kariappa Chettimada Committed by Carles Cufi
Browse files

Bluetooth: controller: Use the CSA#2 function for SubEvents



Use the CSA#2 functions for SubEvent channel selection.

Signed-off-by: default avatarVinayak Kariappa Chettimada <vich@nordicsemi.no>
parent 46e9679c
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -10,10 +10,10 @@ struct lll_adv_iso {

	uint8_t seed_access_addr[4];
	uint8_t base_crc_init[2];

	uint16_t latency_prepare;
	uint16_t latency_event;
	uint16_t data_chan_id;
	uint16_t data_chan_prn_s;
	uint16_t data_chan_remap_idx;

	uint64_t payload_count:39;
	uint64_t framing:1;
+2 −1
Original line number Diff line number Diff line
@@ -12,7 +12,8 @@ struct lll_sync_iso {

	uint16_t latency_prepare;
	uint16_t latency_event;
	uint16_t data_chan_id;
	uint16_t data_chan_prn_s;
	uint16_t data_chan_remap_idx;

	uint64_t payload_count:39;

+11 −5
Original line number Diff line number Diff line
@@ -165,6 +165,7 @@ static int prepare_cb_common(struct lll_prepare_param *p)
	uint32_t ticks_at_start;
	uint16_t event_counter;
	uint8_t access_addr[4];
	uint16_t data_chan_id;
	uint8_t data_chan_use;
	uint8_t crc_init[3];
	struct pdu_bis *pdu;
@@ -182,7 +183,8 @@ static int prepare_cb_common(struct lll_prepare_param *p)
	lll->latency_event = lll->latency_prepare - 1;

	/* Calculate the current event counter value */
	event_counter = (lll->payload_count & 0xFFFF) + lll->latency_event;
	event_counter = ((lll->payload_count / lll->bn) & 0xFFFF) +
			(lll->latency_event * lll->bn);

	/* Update BIS packet counter to next value */
	lll->payload_count += (lll->latency_prepare * lll->bn);
@@ -190,14 +192,11 @@ static int prepare_cb_common(struct lll_prepare_param *p)
	/* Reset accumulated latencies */
	lll->latency_prepare = 0;

	/* Calculate the radio channel to use */
	data_chan_use = lll_chan_sel_2(event_counter, lll->data_chan_id,
				       &lll->data_chan_map[0],
				       lll->data_chan_count);

	/* Calculate the Access Address for the BIS event */
	bis = 1U;
	util_bis_aa_le32(bis, lll->seed_access_addr, access_addr);
	data_chan_id = lll_chan_id(access_addr);

	/* Calculate the CRC init value for the BIS event,
	 * preset with the BaseCRCInit value from the BIGInfo data the most
@@ -207,6 +206,13 @@ static int prepare_cb_common(struct lll_prepare_param *p)
	memcpy(&crc_init[1], lll->base_crc_init, sizeof(uint16_t));
	crc_init[0] = bis;

	/* Calculate the radio channel to use for ISO event */
	data_chan_use = lll_chan_iso_event(event_counter, data_chan_id,
					   &lll->data_chan_map[0],
					   lll->data_chan_count,
					   &lll->data_chan_prn_s,
					   &lll->data_chan_remap_idx);

	/* Start setting up of Radio h/w */
	radio_reset();

+11 −6
Original line number Diff line number Diff line
@@ -170,6 +170,7 @@ static int prepare_cb_common(struct lll_prepare_param *p)
	uint32_t ticks_at_start;
	uint16_t event_counter;
	uint8_t access_addr[4];
	uint16_t data_chan_id;
	uint8_t data_chan_use;
	uint32_t remainder_us;
	uint8_t crc_init[3];
@@ -187,7 +188,8 @@ static int prepare_cb_common(struct lll_prepare_param *p)
	lll->latency_event = lll->latency_prepare - 1;

	/* Calculate the current event counter value */
	event_counter = (lll->payload_count & 0xFFFF) + lll->latency_event;
	event_counter = ((lll->payload_count / lll->bn) & 0xFFFF) +
			(lll->latency_event * lll->bn);

	/* Update BIS packet counter to next value */
	lll->payload_count += (lll->latency_prepare * lll->bn);
@@ -202,14 +204,10 @@ static int prepare_cb_common(struct lll_prepare_param *p)
		lll->window_widening_event_us =	lll->window_widening_max_us;
	}

	/* Calculate the radio channel to use */
	data_chan_use = lll_chan_sel_2(event_counter, lll->data_chan_id,
				       &lll->data_chan_map[0],
				       lll->data_chan_count);

	/* Calculate the Access Address for the BIS event */
	bis = 1U;
	util_bis_aa_le32(bis, lll->seed_access_addr, access_addr);
	data_chan_id = lll_chan_id(access_addr);

	/* Calculate the CRC init value for the BIS event,
	 * preset with the BaseCRCInit value from the BIGInfo data the most
@@ -219,6 +217,13 @@ static int prepare_cb_common(struct lll_prepare_param *p)
	memcpy(&crc_init[1], lll->base_crc_init, sizeof(uint16_t));
	crc_init[0] = bis;

	/* Calculate the radio channel to use for ISO event */
	data_chan_use = lll_chan_iso_event(event_counter, data_chan_id,
					   &lll->data_chan_map[0],
					   lll->data_chan_count,
					   &lll->data_chan_prn_s,
					   &lll->data_chan_remap_idx);

	/* Start setting up of Radio h/w */
	radio_reset();

+2 −1
Original line number Diff line number Diff line
@@ -202,14 +202,15 @@ uint8_t ll_big_create(uint8_t big_handle, uint8_t adv_handle, uint8_t num_bis,
						      phy) +
					   EVENT_MSS_US;
	}

	util_saa_le32(lll_adv_iso->seed_access_addr, big_handle);

	lll_adv_iso->sdu_interval = sdu_interval;
	lll_adv_iso->max_sdu = max_sdu;
	lll_csrand_get(lll_adv_iso->base_crc_init,
		       sizeof(lll_adv_iso->base_crc_init));
	lll_adv_iso->data_chan_count =
		ull_chan_map_get(lll_adv_iso->data_chan_map);
	lll_adv_iso->data_chan_id = 0;
	lll_adv_iso->phy = phy;
	lll_adv_iso->latency_prepare = 0;
	lll_adv_iso->latency_event = 0;
Loading