rymanluk closed pull request #866: nimble/dtm: Couple of improvements helping 
in RF testing.
URL: https://github.com/apache/mynewt-core/pull/866
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/hw/drivers/nimble/nrf52/src/ble_phy.c 
b/hw/drivers/nimble/nrf52/src/ble_phy.c
index adae7f054..85909293a 100644
--- a/hw/drivers/nimble/nrf52/src/ble_phy.c
+++ b/hw/drivers/nimble/nrf52/src/ble_phy.c
@@ -1443,6 +1443,7 @@ ble_phy_tx_set_start_time(uint32_t cputime, uint8_t 
rem_usecs)
 int
 ble_phy_rx_set_start_time(uint32_t cputime, uint8_t rem_usecs)
 {
+    bool late = false;
     int rc = 0;
 
     /* XXX: This should not be necessary, but paranoia is good! */
@@ -1451,16 +1452,29 @@ ble_phy_rx_set_start_time(uint32_t cputime, uint8_t 
rem_usecs)
 
     if (ble_phy_set_start_time(cputime, rem_usecs, false) != 0) {
         STATS_INC(ble_phy_stats, rx_late);
+
+        /*
+         * Disable PPI so ble_phy_rx() will start RX immediately after
+         * configuring receiver.
+         */
         NRF_PPI->CHENCLR = PPI_CHEN_CH21_Msk;
-        NRF_RADIO->TASKS_RXEN = 1;
-        rc = BLE_PHY_ERR_RX_LATE;
+        late = true;
     } else {
         /* Enable PPI to automatically start RXEN */
         NRF_PPI->CHENSET = PPI_CHEN_CH21_Msk;
+    }
 
-        /* Start rx */
-        rc = ble_phy_rx();
+    /* Start rx */
+    rc = ble_phy_rx();
+
+    /*
+     * If we enabled receiver but were late, let's return proper error code so
+     * caller can handle this.
+     */
+    if (!rc && late) {
+        rc = BLE_PHY_ERR_RX_LATE;
     }
+
     return rc;
 }
 
diff --git a/net/nimble/controller/src/ble_ll_dtm.c 
b/net/nimble/controller/src/ble_ll_dtm.c
index 23a5cfcb2..e014d249e 100644
--- a/net/nimble/controller/src/ble_ll_dtm.c
+++ b/net/nimble/controller/src/ble_ll_dtm.c
@@ -311,7 +311,9 @@ ble_ll_dtm_rx_start(void)
 
     rc = ble_phy_setchan(channel_rf_to_index[g_ble_ll_dtm_ctx.rf_channel],
                          BLE_DTM_SYNC_WORD, BLE_DTM_CRC);
-    assert(rc == 0);
+    if (rc) {
+        return rc;
+    }
 
 #if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_2M_PHY) || 
MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_CODED_PHY))
     ble_phy_mode_set(g_ble_ll_dtm_ctx.phy_mode, g_ble_ll_dtm_ctx.phy_mode);
@@ -319,7 +321,9 @@ ble_ll_dtm_rx_start(void)
 
     rc = ble_phy_rx_set_start_time(os_cputime_get32() +
                                    g_ble_ll_sched_offset_ticks, 0);
-    assert(rc == 0);
+    if (rc && rc != BLE_PHY_ERR_RX_LATE) {
+        return rc;
+    }
 
     ble_ll_state_set(BLE_LL_STATE_DTM);
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to