From 18c5e74249f2fcf6912d9e767f799dc75e27e8b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Kopy=C5=9Bci=C5=84ski?= Date: Mon, 23 Oct 2023 11:33:16 +0200 Subject: [PATCH] nimble/ll: add BLE_LL_PHY config This config infers value from PHY flags and replaces BLE_LL_BT5_PHY_SUPPORTED define. --- nimble/controller/include/controller/ble_ll.h | 6 --- .../include/controller/ble_ll_conn.h | 2 +- nimble/controller/src/ble_ll_adv.c | 6 +-- nimble/controller/src/ble_ll_conn.c | 38 +++++++++---------- nimble/controller/src/ble_ll_conn_hci.c | 2 +- nimble/controller/src/ble_ll_ctrl.c | 14 +++---- nimble/controller/src/ble_ll_hci.c | 4 +- nimble/controller/src/ble_ll_hci_ev.c | 2 +- nimble/controller/src/ble_ll_hci_supp_cmd.c | 2 +- nimble/controller/src/ble_ll_iso_big.c | 4 +- nimble/controller/src/ble_ll_scan.c | 4 +- nimble/controller/src/ble_ll_scan_aux.c | 4 +- nimble/controller/src/ble_ll_sync.c | 4 +- nimble/controller/syscfg.yml | 3 ++ nimble/drivers/dialog_cmac/src/ble_phy.c | 12 +++--- nimble/drivers/nrf5x/src/ble_phy.c | 18 ++++----- 16 files changed, 61 insertions(+), 64 deletions(-) diff --git a/nimble/controller/include/controller/ble_ll.h b/nimble/controller/include/controller/ble_ll.h index 7247f31df4..0b5e1d52cb 100644 --- a/nimble/controller/include/controller/ble_ll.h +++ b/nimble/controller/include/controller/ble_ll.h @@ -53,12 +53,6 @@ void ble_ll_assert(const char *file, unsigned line) __attribute((noreturn)); #define BLE_LL_ASSERT(cond) assert(cond) #endif -#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_2M_PHY) || MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_CODED_PHY) -#define BLE_LL_BT5_PHY_SUPPORTED (1) -#else -#define BLE_LL_BT5_PHY_SUPPORTED (0) -#endif - /* Controller revision. */ #define BLE_LL_SUB_VERS_NR (0x0000) diff --git a/nimble/controller/include/controller/ble_ll_conn.h b/nimble/controller/include/controller/ble_ll_conn.h index cb7ad60ae6..f5a5672e23 100644 --- a/nimble/controller/include/controller/ble_ll_conn.h +++ b/nimble/controller/include/controller/ble_ll_conn.h @@ -233,7 +233,7 @@ struct ble_ll_conn_sm uint16_t host_req_max_rx_time; #endif -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) struct ble_ll_conn_phy_data phy_data; uint16_t phy_instant; uint8_t phy_tx_transition; diff --git a/nimble/controller/src/ble_ll_adv.c b/nimble/controller/src/ble_ll_adv.c index db07f8965b..e2ac3f8579 100644 --- a/nimble/controller/src/ble_ll_adv.c +++ b/nimble/controller/src/ble_ll_adv.c @@ -1123,7 +1123,7 @@ ble_ll_adv_tx_start_cb(struct ble_ll_sched_item *sch) rc = ble_phy_setchan(advsm->adv_chan, BLE_ACCESS_ADDR_ADV, BLE_LL_CRCINIT_ADV); BLE_LL_ASSERT(rc == 0); -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) /* Set phy mode */ #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV) if (advsm->props & BLE_HCI_LE_SET_EXT_ADV_PROP_LEGACY) { @@ -1269,7 +1269,7 @@ ble_ll_adv_secondary_tx_start_cb(struct ble_ll_sched_item *sch) BLE_LL_CRCINIT_ADV); BLE_LL_ASSERT(rc == 0); -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) /* Set phy mode */ ble_phy_mode_set(advsm->sec_phy, advsm->sec_phy); #endif @@ -2264,7 +2264,7 @@ ble_ll_adv_sync_tx_start_cb(struct ble_ll_sched_item *sch) BLE_LL_ASSERT(rc == 0); -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) /* Set phy mode */ ble_phy_mode_set(advsm->sec_phy, advsm->sec_phy); #endif diff --git a/nimble/controller/src/ble_ll_conn.c b/nimble/controller/src/ble_ll_conn.c index 3565e10424..6ad4603131 100644 --- a/nimble/controller/src/ble_ll_conn.c +++ b/nimble/controller/src/ble_ll_conn.c @@ -554,7 +554,7 @@ ble_ll_conn_find_by_peer_addr(const uint8_t *addr, uint8_t addr_type) return NULL; } -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) static inline int ble_ll_conn_phy_should_update(uint8_t pref_mask, uint8_t curr_mask) { @@ -1003,7 +1003,7 @@ ble_ll_conn_chk_csm_flags(struct ble_ll_conn_sm *connsm) } /* Check if we need to send PHY update complete event */ -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) if (connsm->flags.phy_update_host_w4event) { if (!ble_ll_hci_ev_phy_update(connsm, BLE_ERR_SUCCESS)) { /* Sent event. Clear flag */ @@ -1040,7 +1040,7 @@ ble_ll_conn_adjust_pyld_len(struct ble_ll_conn_sm *connsm, uint16_t pyld_len) uint16_t max_pyld_len; uint16_t ret; -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) uint8_t phy_mode; if (connsm->phy_tx_transition) { @@ -1268,7 +1268,7 @@ ble_ll_conn_tx_pdu(struct ble_ll_conn_sm *connsm) * now. This is not the most accurate especially if we have * received a frame and we are replying to it. */ -#if BLE_LL_BT5_PHY_SUPPORTED +#if MYNEWT_VAL(BLE_LL_PHY) tx_phy_mode = connsm->phy_data.tx_phy_mode; #else tx_phy_mode = BLE_PHY_MODE_1M; @@ -1522,7 +1522,7 @@ ble_ll_conn_event_start_cb(struct ble_ll_sched_item *sch) ble_phy_resolv_list_disable(); #endif -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) ble_phy_mode_set(connsm->phy_data.tx_phy_mode, connsm->phy_data.rx_phy_mode); #endif @@ -1659,7 +1659,7 @@ ble_ll_conn_can_send_next_pdu(struct ble_ll_conn_sm *connsm, uint32_t begtime, uint32_t allowed_usecs; int tx_phy_mode; -#if BLE_LL_BT5_PHY_SUPPORTED +#if MYNEWT_VAL(BLE_LL_PHY) tx_phy_mode = connsm->phy_data.tx_phy_mode; #else tx_phy_mode = BLE_PHY_MODE_1M; @@ -1868,7 +1868,7 @@ ble_ll_conn_set_data_len(struct ble_ll_conn_sm *connsm, } #endif -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) static void ble_ll_conn_set_phy(struct ble_ll_conn_sm *connsm, int tx_phy, int rx_phy) @@ -2005,7 +2005,7 @@ ble_ll_conn_sm_new(struct ble_ll_conn_sm *connsm) #endif /* XXX: TODO set these based on PHY that started connection */ -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) connsm->phy_data.cur_tx_phy = BLE_PHY_1M; connsm->phy_data.cur_rx_phy = BLE_PHY_1M; connsm->phy_data.tx_phy_mode = BLE_PHY_MODE_1M; @@ -2136,7 +2136,7 @@ ble_ll_conn_update_eff_data_len(struct ble_ll_conn_sm *connsm) * connection events timings. */ if (ota_max_rx_time_calc) { -#if BLE_LL_BT5_PHY_SUPPORTED +#if MYNEWT_VAL(BLE_LL_PHY) phy_mode = ble_ll_phy_to_phy_mode(connsm->phy_data.cur_rx_phy, BLE_HCI_LE_PHY_CODED_S8_PREF); #else @@ -2639,7 +2639,7 @@ ble_ll_conn_next_event(struct ble_ll_conn_sm *connsm) } #endif -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) if (connsm->flags.phy_update_sched && (connsm->event_cntr == connsm->phy_instant)) { @@ -2846,7 +2846,7 @@ ble_ll_conn_created(struct ble_ll_conn_sm *connsm, struct ble_mbuf_hdr *rxhdr) /* Send connection complete event to inform host of connection */ if (rc) { -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) && MYNEWT_VAL(BLE_LL_CONN_PHY_INIT_UPDATE) +#if (MYNEWT_VAL(BLE_LL_PHY)) && MYNEWT_VAL(BLE_LL_CONN_PHY_INIT_UPDATE) /* * If we have default phy preferences and they are different than * the current PHY's in use, start update procedure. @@ -3216,7 +3216,7 @@ ble_ll_conn_send_connect_req(struct os_mbuf *rxpdu, #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV) if (ext) { -#if BLE_LL_BT5_PHY_SUPPORTED +#if MYNEWT_VAL(BLE_LL_PHY) phy = rxhdr->rxinfo.phy; #else phy = BLE_PHY_1M; @@ -3240,7 +3240,7 @@ ble_ll_conn_send_connect_req(struct os_mbuf *rxpdu, return -1; } -#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV) && BLE_LL_BT5_PHY_SUPPORTED +#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV) && MYNEWT_VAL(BLE_LL_PHY) if (ext) { ble_ll_conn_init_phy(connsm, phy); } @@ -3288,7 +3288,7 @@ ble_ll_conn_central_start(uint8_t phy, uint8_t csa, #endif ble_ll_conn_set_csa(connsm, csa); -#if BLE_LL_BT5_PHY_SUPPORTED +#if MYNEWT_VAL(BLE_LL_PHY) ble_ll_conn_init_phy(connsm, phy); #endif ble_ll_conn_created(connsm, NULL); @@ -3316,12 +3316,12 @@ ble_ll_conn_created_on_aux(struct os_mbuf *rxpdu, struct ble_ll_scan_addr_data *addrd, uint8_t *targeta) { -#if BLE_LL_BT5_PHY_SUPPORTED +#if MYNEWT_VAL(BLE_LL_PHY) struct ble_mbuf_hdr *rxhdr; #endif uint8_t phy; -#if BLE_LL_BT5_PHY_SUPPORTED +#if MYNEWT_VAL(BLE_LL_PHY) rxhdr = BLE_MBUF_HDR_PTR(rxpdu); phy = rxhdr->rxinfo.phy; #else @@ -3698,7 +3698,7 @@ ble_ll_conn_rx_isr_end(uint8_t *rxbuf, struct ble_mbuf_hdr *rxhdr) * to the 'additional usecs' field to save some calculations. */ begtime = rxhdr->beg_cputime; -#if BLE_LL_BT5_PHY_SUPPORTED +#if MYNEWT_VAL(BLE_LL_PHY) rx_phy_mode = connsm->phy_data.rx_phy_mode; #else rx_phy_mode = BLE_PHY_MODE_1M; @@ -3834,7 +3834,7 @@ ble_ll_conn_rx_isr_end(uint8_t *rxbuf, struct ble_mbuf_hdr *rxhdr) rem_bytes = OS_MBUF_PKTLEN(txpdu) - txhdr->txinfo.offset; /* Adjust payload for max TX time and octets */ -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) if (BLE_LL_LLID_IS_CTRL(hdr_byte) && CONN_IS_PERIPHERAL(connsm) && (opcode == BLE_LL_CTRL_PHY_UPDATE_IND)) { @@ -4167,7 +4167,7 @@ ble_ll_conn_periph_start(uint8_t *rxbuf, uint8_t pat, struct ble_mbuf_hdr *rxhdr connsm->conn_role = BLE_LL_CONN_ROLE_PERIPHERAL; ble_ll_conn_sm_new(connsm); -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) /* Use the same PHY as we received CONNECT_REQ on */ ble_ll_conn_init_phy(connsm, rxhdr->rxinfo.phy); #endif diff --git a/nimble/controller/src/ble_ll_conn_hci.c b/nimble/controller/src/ble_ll_conn_hci.c index 7f5ab699bf..e5fc9ae7c8 100644 --- a/nimble/controller/src/ble_ll_conn_hci.c +++ b/nimble/controller/src/ble_ll_conn_hci.c @@ -1917,7 +1917,7 @@ ble_ll_conn_hci_wr_auth_pyld_tmo(const uint8_t *cmdbuf, uint8_t len, } #endif -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) /** * Read current phy for connection (OGF=8, OCF==0x0030) * diff --git a/nimble/controller/src/ble_ll_ctrl.c b/nimble/controller/src/ble_ll_ctrl.c index 053c62881a..a30bbdc88d 100644 --- a/nimble/controller/src/ble_ll_ctrl.c +++ b/nimble/controller/src/ble_ll_ctrl.c @@ -184,7 +184,7 @@ ble_ll_ctrl_rej_ext_ind_make(uint8_t rej_opcode, uint8_t err, uint8_t *ctrdata) ctrdata[1] = err; } -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) /** * Called to cancel a phy update procedure. * @@ -546,7 +546,7 @@ ble_ll_ctrl_proc_unk_rsp(struct ble_ll_conn_sm *connsm, uint8_t *dptr, uint8_t * ctrl_proc = BLE_LL_CTRL_PROC_LE_PING; BLE_LL_CONN_CLEAR_FEATURE(connsm, BLE_LL_FEAT_LE_PING); break; -#if (BLE_LL_BT5_PHY_SUPPORTED ==1) +#if (MYNEWT_VAL(BLE_LL_PHY)) case BLE_LL_CTRL_PHY_REQ: ble_ll_ctrl_phy_update_cancel(connsm, BLE_ERR_UNSUPP_REM_FEATURE); ctrl_proc = BLE_LL_CTRL_PROC_PHY_UPDATE; @@ -656,7 +656,7 @@ ble_ll_ctrl_phy_from_phy_mask(uint8_t phy_mask) return phy; } -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) uint8_t ble_ll_ctrl_phy_tx_transition_get(uint8_t phy_mask) { @@ -1970,7 +1970,7 @@ ble_ll_ctrl_rx_reject_ind(struct ble_ll_conn_sm *connsm, uint8_t *dptr, connsm->enc_data.enc_state = CONN_ENC_S_UNENCRYPTED; break; #endif -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) case BLE_LL_CTRL_PROC_PHY_UPDATE: ble_ll_ctrl_phy_update_cancel(connsm, ble_error); ble_ll_ctrl_proc_stop(connsm, BLE_LL_CTRL_PROC_PHY_UPDATE); @@ -2502,7 +2502,7 @@ ble_ll_ctrl_proc_init(struct ble_ll_conn_sm *connsm, int ctrl_proc, void *data) } break; #endif -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) case BLE_LL_CTRL_PROC_PHY_UPDATE: opcode = BLE_LL_CTRL_PHY_REQ; ble_ll_ctrl_phy_req_rsp_make(connsm, ctrdata); @@ -2957,7 +2957,7 @@ ble_ll_ctrl_rx_pdu(struct ble_ll_conn_sm *connsm, struct os_mbuf *om) /* Sometimes reject triggers sending other LL CTRL msg */ rsp_opcode = ble_ll_ctrl_rx_reject_ind(connsm, dptr, opcode, rspdata); break; -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) case BLE_LL_CTRL_PHY_REQ: rsp_opcode = ble_ll_ctrl_rx_phy_req(connsm, dptr, rspdata); break; @@ -3177,7 +3177,7 @@ ble_ll_ctrl_tx_done(struct os_mbuf *txpdu, struct ble_ll_conn_sm *connsm) break; #endif #endif -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) #if MYNEWT_VAL(BLE_LL_ROLE_PERIPHERAL) case BLE_LL_CTRL_PHY_REQ: if (connsm->conn_role == BLE_LL_CONN_ROLE_PERIPHERAL) { diff --git a/nimble/controller/src/ble_ll_hci.c b/nimble/controller/src/ble_ll_hci.c index 1be14ceeec..e0a64abb0f 100644 --- a/nimble/controller/src/ble_ll_hci.c +++ b/nimble/controller/src/ble_ll_hci.c @@ -365,7 +365,7 @@ ble_ll_hci_le_read_bufsize_v2(uint8_t *rspbuf, uint8_t *rsplen) } #endif -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) /** * Checks the preferred phy masks for validity and places the preferred masks * in the input phy masks @@ -1110,7 +1110,7 @@ ble_ll_hci_le_cmd_proc(const uint8_t *cmdbuf, uint8_t len, uint16_t ocf, } break; #endif -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) #if MYNEWT_VAL(BLE_LL_ROLE_PERIPHERAL) || MYNEWT_VAL(BLE_LL_ROLE_CENTRAL) case BLE_HCI_OCF_LE_RD_PHY: rc = ble_ll_conn_hci_le_rd_phy(cmdbuf, len, rspbuf, rsplen); diff --git a/nimble/controller/src/ble_ll_hci_ev.c b/nimble/controller/src/ble_ll_hci_ev.c index dc74806258..69a27cc2cb 100644 --- a/nimble/controller/src/ble_ll_hci_ev.c +++ b/nimble/controller/src/ble_ll_hci_ev.c @@ -432,7 +432,7 @@ ble_ll_hci_ev_send_adv_set_terminated(uint8_t status, uint8_t adv_handle, * @param connsm Pointer to connection state machine * @param status error status of event */ -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) int ble_ll_hci_ev_phy_update(struct ble_ll_conn_sm *connsm, uint8_t status) { diff --git a/nimble/controller/src/ble_ll_hci_supp_cmd.c b/nimble/controller/src/ble_ll_hci_supp_cmd.c index f10c89890d..ab51becfd1 100644 --- a/nimble/controller/src/ble_ll_hci_supp_cmd.c +++ b/nimble/controller/src/ble_ll_hci_supp_cmd.c @@ -161,7 +161,7 @@ static const uint8_t octet_35 = OCTET( BIT(2) /* HCI LE Set Resolvable Private Address Timeout */ #endif BIT(3) /* HCI LE Read Maximum Data Length */ -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) #if MYNEWT_VAL(BLE_LL_ROLE_PERIPHERAL) || MYNEWT_VAL(BLE_LL_ROLE_CENTRAL) BIT(4) /* HCI LE Read PHY */ BIT(5) /* HCI LE Set Default PHY */ diff --git a/nimble/controller/src/ble_ll_iso_big.c b/nimble/controller/src/ble_ll_iso_big.c index 6725f30ab9..671beef219 100644 --- a/nimble/controller/src/ble_ll_iso_big.c +++ b/nimble/controller/src/ble_ll_iso_big.c @@ -741,7 +741,7 @@ ble_ll_iso_big_event_sched_cb(struct ble_ll_sched_item *sch) { struct ble_ll_iso_big *big; struct ble_ll_iso_bis *bis; -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) uint8_t phy_mode; #endif int rc; @@ -755,7 +755,7 @@ ble_ll_iso_big_event_sched_cb(struct ble_ll_sched_item *sch) #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) ble_phy_resolv_list_disable(); #endif -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) phy_mode = ble_ll_phy_to_phy_mode(big->phy, 0); ble_phy_mode_set(phy_mode, phy_mode); #endif diff --git a/nimble/controller/src/ble_ll_scan.c b/nimble/controller/src/ble_ll_scan.c index 445cbb58f6..79da595b57 100644 --- a/nimble/controller/src/ble_ll_scan.c +++ b/nimble/controller/src/ble_ll_scan.c @@ -749,7 +749,7 @@ ble_ll_scan_start(struct ble_ll_scan_sm *scansm) int rc; struct ble_ll_scan_phy *scanp = scansm->scanp; uint8_t chan; -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) uint8_t phy_mode; int phy; #endif @@ -779,7 +779,7 @@ ble_ll_scan_start(struct ble_ll_scan_sm *scansm) } #endif -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) phy = scanp->phy; phy_mode = ble_ll_phy_to_phy_mode(phy, BLE_HCI_LE_PHY_CODED_ANY); ble_phy_mode_set(phy_mode, phy_mode); diff --git a/nimble/controller/src/ble_ll_scan_aux.c b/nimble/controller/src/ble_ll_scan_aux.c index 3d5f27753a..7b3b0a168f 100644 --- a/nimble/controller/src/ble_ll_scan_aux.c +++ b/nimble/controller/src/ble_ll_scan_aux.c @@ -111,7 +111,7 @@ static int ble_ll_scan_aux_sched_cb(struct ble_ll_sched_item *sch) { struct ble_ll_scan_aux_data *aux = sch->cb_arg; -#if BLE_LL_BT5_PHY_SUPPORTED +#if MYNEWT_VAL(BLE_LL_PHY) uint8_t phy_mode; #endif uint8_t lls; @@ -137,7 +137,7 @@ ble_ll_scan_aux_sched_cb(struct ble_ll_sched_item *sch) } #endif -#if BLE_LL_BT5_PHY_SUPPORTED +#if MYNEWT_VAL(BLE_LL_PHY) phy_mode = ble_ll_phy_to_phy_mode(aux->sec_phy, BLE_HCI_LE_PHY_CODED_ANY); ble_phy_mode_set(phy_mode, phy_mode); #endif diff --git a/nimble/controller/src/ble_ll_sync.c b/nimble/controller/src/ble_ll_sync.c index 8aef8e2c82..71e1ffb2e6 100644 --- a/nimble/controller/src/ble_ll_sync.c +++ b/nimble/controller/src/ble_ll_sync.c @@ -228,7 +228,7 @@ ble_ll_sync_sm_clear(struct ble_ll_sync_sm *sm) static uint8_t ble_ll_sync_phy_mode_to_hci(int8_t phy_mode) { -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) switch (phy_mode) { case BLE_PHY_MODE_1M: return BLE_HCI_LE_PHY_1M; @@ -475,7 +475,7 @@ ble_ll_sync_event_start_cb(struct ble_ll_sched_item *sch) ble_phy_encrypt_disable(); #endif -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) ble_phy_mode_set(sm->phy_mode, sm->phy_mode); #endif diff --git a/nimble/controller/syscfg.yml b/nimble/controller/syscfg.yml index 5988e807f2..045cd50c5e 100644 --- a/nimble/controller/syscfg.yml +++ b/nimble/controller/syscfg.yml @@ -564,6 +564,9 @@ syscfg.defs: This is the stack size for LL task. value: 120 +syscfg.defs.'BLE_LL_CFG_FEAT_LE_2M_PHY || BLE_LL_CFG_FEAT_LE_CODED_PHY': + BLE_LL_PHY: 1 + syscfg.vals.BLE_LL_CFG_FEAT_LL_EXT_ADV: BLE_LL_CFG_FEAT_LE_CSA2: 1 BLE_HW_WHITELIST_ENABLE: 0 diff --git a/nimble/drivers/dialog_cmac/src/ble_phy.c b/nimble/drivers/dialog_cmac/src/ble_phy.c index d146e07e39..4e07a7c5aa 100644 --- a/nimble/drivers/dialog_cmac/src/ble_phy.c +++ b/nimble/drivers/dialog_cmac/src/ble_phy.c @@ -639,7 +639,7 @@ ble_phy_irq_frame_tx_exc_bs_stop(void) (void)CMAC->CM_TS1_REG; if (g_ble_phy_data.end_transition == BLE_PHY_TRANSITION_TX_RX) { -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) ble_phy_mode_apply(g_ble_phy_data.phy_mode_rx); #endif ble_phy_rx_setup_fields(); @@ -895,7 +895,7 @@ ble_phy_irq_frame_rx_exc_phy_to_idle_4this(void) CMAC->CM_EXC_STAT_REG = CMAC_CM_EXC_STAT_REG_EXC_PHY_TO_IDLE_4THIS_Msk; /* We are here only on transition, so switch to TX */ -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) ble_phy_mode_apply(g_ble_phy_data.phy_mode_tx); #endif rf_chan = g_ble_phy_chan_to_rf[g_ble_phy_data.channel]; @@ -1016,7 +1016,7 @@ ble_phy_mode_set(uint8_t tx_phy_mode, uint8_t rx_phy_mode) static int ble_phy_get_cur_phy(void) { -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) switch (g_ble_phy_data.phy_mode_cur) { case BLE_PHY_MODE_1M: return BLE_PHY_1M; @@ -1357,7 +1357,7 @@ ble_phy_rx_set_start_time(uint32_t cputime, uint8_t rem_usecs) MCU_DIAG_SER('r'); -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) ble_phy_mode_apply(g_ble_phy_data.phy_mode_rx); #endif @@ -1485,7 +1485,7 @@ ble_phy_tx_set_start_time(uint32_t cputime, uint8_t rem_usecs) MCU_DIAG_SER('t'); -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) ble_phy_mode_apply(g_ble_phy_data.phy_mode_tx); #endif @@ -1712,7 +1712,7 @@ ble_phy_restart_rx(void) ble_phy_disable(); /* Apply mode before starting RX */ -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) ble_phy_mode_apply(g_ble_phy_data.phy_mode_rx); #endif diff --git a/nimble/drivers/nrf5x/src/ble_phy.c b/nimble/drivers/nrf5x/src/ble_phy.c index 0c37f2aa76..2a10271d81 100644 --- a/nimble/drivers/nrf5x/src/ble_phy.c +++ b/nimble/drivers/nrf5x/src/ble_phy.c @@ -183,7 +183,7 @@ static const uint8_t g_ble_phy_chan_freq[BLE_PHY_NUM_CHANS] = { 66, 68, 70, 72, 74, 76, 78, 2, 26, 80, /* 30-39 */ }; -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) /* packet start offsets (in usecs) */ static const uint16_t g_ble_phy_mode_pkt_start_off[BLE_PHY_NUM_MODE] = { [BLE_PHY_MODE_1M] = 40, @@ -338,7 +338,7 @@ struct nrf_ccm_data struct nrf_ccm_data g_nrf_ccm_data; #endif -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) /* Packet start offset (in usecs). This is the preamble plus access address. * For LE Coded PHY this also includes CI and TERM1. */ @@ -451,7 +451,7 @@ ble_phy_mode_pdu_start_off(int phy_mode) static int ble_phy_get_cur_phy(void) { -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) switch (g_ble_phy_data.phy_cur_phy_mode) { case BLE_PHY_MODE_1M: return BLE_PHY_1M; @@ -904,7 +904,7 @@ ble_phy_wfr_enable(int txrx, uint8_t tx_phy_mode, uint32_t wfr_usecs) static uint32_t ble_phy_get_ccm_datarate(void) { -#if BLE_LL_BT5_PHY_SUPPORTED +#if MYNEWT_VAL(BLE_LL_PHY) switch (g_ble_phy_data.phy_cur_phy_mode) { case BLE_PHY_MODE_1M: return CCM_MODE_DATARATE_1Mbit << CCM_MODE_DATARATE_Pos; @@ -981,7 +981,7 @@ ble_phy_rx_xcvr_setup(void) g_ble_phy_data.phy_rx_started = 0; g_ble_phy_data.phy_state = BLE_PHY_STATE_RX; -#if BLE_LL_BT5_PHY_SUPPORTED +#if MYNEWT_VAL(BLE_LL_PHY) /* * On Coded PHY there are CI and TERM1 fields before PDU starts so we need * to take this into account when setting up BCC. @@ -1067,7 +1067,7 @@ ble_phy_tx_end_isr(void) } if (transition == BLE_PHY_TRANSITION_TX_RX) { -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) ble_phy_mode_apply(g_ble_phy_data.phy_rx_phy_mode); #endif @@ -1244,7 +1244,7 @@ ble_phy_rx_end_isr(void) #endif } -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) ble_phy_mode_apply(g_ble_phy_data.phy_tx_phy_mode); #endif @@ -1812,7 +1812,7 @@ ble_phy_tx_set_start_time(uint32_t cputime, uint8_t rem_usecs) ble_phy_trace_u32x2(BLE_PHY_TRACE_ID_START_TX, cputime, rem_usecs); -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) ble_phy_mode_apply(g_ble_phy_data.phy_tx_phy_mode); #endif @@ -1854,7 +1854,7 @@ ble_phy_rx_set_start_time(uint32_t cputime, uint8_t rem_usecs) ble_phy_trace_u32x2(BLE_PHY_TRACE_ID_START_RX, cputime, rem_usecs); -#if (BLE_LL_BT5_PHY_SUPPORTED == 1) +#if (MYNEWT_VAL(BLE_LL_PHY)) ble_phy_mode_apply(g_ble_phy_data.phy_rx_phy_mode); #endif