From 6e1cd49f1737d0ffc885816e6b44bf8c5f08e3af Mon Sep 17 00:00:00 2001 From: Andrzej Kaczmarek Date: Thu, 21 Sep 2017 23:21:33 +0200 Subject: [PATCH] nimble/phy: Fix wfr time calculations Rewritten code works with new T_IFS control and fixes few issues: * delay of RX pipeline is included in calculation (time between access address in the air and EVENTS_ADDRESS) * delay of TX pipeline of preceding packet is also included * TX->RX transition should be adjusted by only 2 usecs for clock accuracy since jitter is intended for wake ups only * we do not need to adjust for jitter at all since this is covered by LL and included in wfr_time * strange workaround for LE Coded is not needed anymore since this is now covered by TX/RX pipelines delays which were missing pieces of the puzzle X-Original-Commit: c4bf3324d65e47aa5cd8510784c825344cdcafc9 --- nimble/controller/include/controller/ble_phy.h | 2 +- nimble/controller/src/ble_ll_conn.c | 2 +- nimble/controller/src/ble_ll_scan.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nimble/controller/include/controller/ble_phy.h b/nimble/controller/include/controller/ble_phy.h index e5267e4d5..b459f548c 100644 --- a/nimble/controller/include/controller/ble_phy.h +++ b/nimble/controller/include/controller/ble_phy.h @@ -134,7 +134,7 @@ void ble_phy_disable(void); #define BLE_PHY_WFR_ENABLE_TXRX (1) void ble_phy_stop_usec_timer(void); -void ble_phy_wfr_enable(int txrx, uint32_t wfr_usecs); +void ble_phy_wfr_enable(int txrx, uint8_t tx_phy_mode, uint32_t wfr_usecs); /* Starts rf clock */ void ble_phy_rfclk_enable(void); diff --git a/nimble/controller/src/ble_ll_conn.c b/nimble/controller/src/ble_ll_conn.c index 40c29ddf8..e26a9dfba 100644 --- a/nimble/controller/src/ble_ll_conn.c +++ b/nimble/controller/src/ble_ll_conn.c @@ -1533,7 +1533,7 @@ ble_ll_conn_event_start_cb(struct ble_ll_sched_item *sch) */ usecs = connsm->slave_cur_tx_win_usecs + 61 + (2 * connsm->slave_cur_window_widening); - ble_phy_wfr_enable(BLE_PHY_WFR_ENABLE_RX, usecs); + ble_phy_wfr_enable(BLE_PHY_WFR_ENABLE_RX, 0, usecs); /* Set next wakeup time to connection event end time */ rc = BLE_LL_SCHED_STATE_RUNNING; } diff --git a/nimble/controller/src/ble_ll_scan.c b/nimble/controller/src/ble_ll_scan.c index 069fc55bb..f48d146d9 100644 --- a/nimble/controller/src/ble_ll_scan.c +++ b/nimble/controller/src/ble_ll_scan.c @@ -200,7 +200,7 @@ ble_ll_aux_scan_cb(struct ble_ll_sched_item *sch) } STATS_INC(ble_ll_stats, aux_fired_for_read); - ble_phy_wfr_enable(BLE_PHY_WFR_ENABLE_RX, BLE_LL_SCHED_ADV_MAX_USECS); + ble_phy_wfr_enable(BLE_PHY_WFR_ENABLE_RX, 0, BLE_LL_SCHED_ADV_MAX_USECS); done: