diff --git a/subsys/bluetooth/controller/hci/hci.c b/subsys/bluetooth/controller/hci/hci.c index cd9d17c2ab5..5fa6d96c87f 100644 --- a/subsys/bluetooth/controller/hci/hci.c +++ b/subsys/bluetooth/controller/hci/hci.c @@ -5019,9 +5019,13 @@ static void le_ext_adv_report(struct pdu_data *pdu_data, sys_le16_to_cpu(si->offs), si->offs_units, sys_le16_to_cpu(si->interval), - (si->sca_chm[4] >> 5), + ((si->sca_chm[PDU_SYNC_INFO_SCA_CHM_SCA_BYTE_OFFSET] & + PDU_SYNC_INFO_SCA_CHM_SCA_BIT_MASK) >> + PDU_SYNC_INFO_SCA_CHM_SCA_BIT_POS), si->sca_chm[0], si->sca_chm[1], si->sca_chm[2], - si->sca_chm[3], (si->sca_chm[4] & 0x1F), + si->sca_chm[3], + (si->sca_chm[PDU_SYNC_INFO_SCA_CHM_SCA_BYTE_OFFSET] & + ~PDU_SYNC_INFO_SCA_CHM_SCA_BIT_MASK), sys_le32_to_cpu(si->aa), si->crc_init[0], si->crc_init[1], si->crc_init[2], sys_le16_to_cpu(si->evt_cntr)); diff --git a/subsys/bluetooth/controller/ll_sw/pdu.h b/subsys/bluetooth/controller/ll_sw/pdu.h index be1bc6afeeb..b9ab8188a9d 100644 --- a/subsys/bluetooth/controller/ll_sw/pdu.h +++ b/subsys/bluetooth/controller/ll_sw/pdu.h @@ -366,6 +366,11 @@ struct pdu_adv_sync_info { uint16_t evt_cntr; } __packed; +#define PDU_SYNC_INFO_SCA_CHM_SCA_BYTE_OFFSET 4 +#define PDU_SYNC_INFO_SCA_CHM_SCA_BIT_POS 5 +#define PDU_SYNC_INFO_SCA_CHM_SCA_BIT_MASK \ + (0x07 << (PDU_SYNC_INFO_SCA_CHM_SCA_BIT_POS)) + enum pdu_adv_type { PDU_ADV_TYPE_ADV_IND = 0x00, PDU_ADV_TYPE_DIRECT_IND = 0x01, diff --git a/subsys/bluetooth/controller/ll_sw/ull_adv_sync.c b/subsys/bluetooth/controller/ll_sw/ull_adv_sync.c index 72f2c4b23b4..291d0b21b13 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_adv_sync.c +++ b/subsys/bluetooth/controller/ll_sw/ull_adv_sync.c @@ -724,8 +724,12 @@ void ull_adv_sync_info_fill(struct ll_adv_sync_set *sync, lll_sync = &sync->lll; memcpy(si->sca_chm, lll_sync->data_chan_map, sizeof(si->sca_chm)); - si->sca_chm[4] &= 0x1f; - si->sca_chm[4] |= lll_clock_sca_local_get() << 5; + si->sca_chm[PDU_SYNC_INFO_SCA_CHM_SCA_BYTE_OFFSET] &= + ~PDU_SYNC_INFO_SCA_CHM_SCA_BIT_MASK; + si->sca_chm[PDU_SYNC_INFO_SCA_CHM_SCA_BYTE_OFFSET] |= + ((lll_clock_sca_local_get() << + PDU_SYNC_INFO_SCA_CHM_SCA_BIT_POS) & + PDU_SYNC_INFO_SCA_CHM_SCA_BIT_MASK); memcpy(&si->aa, lll_sync->access_addr, sizeof(si->aa)); memcpy(si->crc_init, lll_sync->crc_init, sizeof(si->crc_init)); diff --git a/subsys/bluetooth/controller/ll_sw/ull_sync.c b/subsys/bluetooth/controller/ll_sw/ull_sync.c index 418110cd52d..8420007ead2 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_sync.c +++ b/subsys/bluetooth/controller/ll_sw/ull_sync.c @@ -383,8 +383,13 @@ void ull_sync_setup(struct ll_scan_set *scan, struct ll_scan_aux_set *aux, } lll = &sync->lll; + + /* Copy channel map from sca_chm field in sync_info structure, and + * clear the SCA bits. + */ memcpy(lll->data_chan_map, si->sca_chm, sizeof(lll->data_chan_map)); - lll->data_chan_map[4] &= ~0xE0; + lll->data_chan_map[PDU_SYNC_INFO_SCA_CHM_SCA_BYTE_OFFSET] &= + ~PDU_SYNC_INFO_SCA_CHM_SCA_BIT_MASK; lll->data_chan_count = util_ones_count_get(&lll->data_chan_map[0], sizeof(lll->data_chan_map)); if (lll->data_chan_count < 2) { @@ -397,7 +402,13 @@ void ull_sync_setup(struct ll_scan_set *scan, struct ll_scan_aux_set *aux, lll->event_counter = si->evt_cntr; lll->phy = aux->lll.phy; - sca = si->sca_chm[4] >> 5; + /* Extract the SCA value from the sca_chm field of the sync_info + * structure. + */ + sca = (si->sca_chm[PDU_SYNC_INFO_SCA_CHM_SCA_BYTE_OFFSET] & + PDU_SYNC_INFO_SCA_CHM_SCA_BIT_MASK) >> + PDU_SYNC_INFO_SCA_CHM_SCA_BIT_POS; + interval = sys_le16_to_cpu(si->interval); interval_us = interval * CONN_INT_UNIT_US;