Repository: incubator-mynewt-core Updated Branches: refs/heads/develop fded8a353 -> fa73ce595
MYNEWT-542: Controller not working properly if os cputime not 1MHz The code was not correctly usecs to ticks in all cases. The changes to the code should now allow a cputime to be set differently than 1MHz. Note that nrf51 platforms will not work (but for other reasons). Read the jira ticket for more information. Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/fa73ce59 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/fa73ce59 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/fa73ce59 Branch: refs/heads/develop Commit: fa73ce5950bd7d52c3f743390c6884d89221ef06 Parents: fded8a3 Author: William San Filippo <[email protected]> Authored: Mon Jan 9 17:57:35 2017 -0800 Committer: William San Filippo <[email protected]> Committed: Mon Jan 9 17:57:35 2017 -0800 ---------------------------------------------------------------------- hw/drivers/nimble/nrf51/src/ble_phy.c | 4 ++-- hw/drivers/nimble/nrf52/src/ble_phy.c | 4 ++-- net/nimble/controller/src/ble_ll_adv.c | 3 ++- net/nimble/controller/src/ble_ll_conn.c | 9 ++++++--- 4 files changed, 12 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fa73ce59/hw/drivers/nimble/nrf51/src/ble_phy.c ---------------------------------------------------------------------- diff --git a/hw/drivers/nimble/nrf51/src/ble_phy.c b/hw/drivers/nimble/nrf51/src/ble_phy.c index 720659d..65a05ae 100644 --- a/hw/drivers/nimble/nrf51/src/ble_phy.c +++ b/hw/drivers/nimble/nrf51/src/ble_phy.c @@ -427,7 +427,7 @@ ble_phy_tx_end_isr(void) } wfr_time = txstart - BLE_TX_LEN_USECS_M(NRF_RX_START_OFFSET); wfr_time += BLE_TX_DUR_USECS_M(txlen); - wfr_time += os_cputime_usecs_to_ticks(BLE_LL_WFR_USECS); + wfr_time = os_cputime_usecs_to_ticks(BLE_LL_WFR_USECS + wfr_time); ble_ll_wfr_enable(wfr_time); } else { /* Disable automatic TXEN */ @@ -549,7 +549,7 @@ ble_phy_rx_start_isr(void) ble_hdr->rxinfo.channel = g_ble_phy_data.phy_chan; ble_hdr->rxinfo.handle = 0; ble_hdr->beg_cputime = NRF_TIMER0->CC[1] - - BLE_TX_LEN_USECS_M(NRF_RX_START_OFFSET); + os_cputime_usecs_to_ticks(BLE_TX_LEN_USECS_M(NRF_RX_START_OFFSET)); /* Call Link Layer receive start function */ rc = ble_ll_rx_start(g_ble_phy_data.rxdptr, g_ble_phy_data.phy_chan, http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fa73ce59/hw/drivers/nimble/nrf52/src/ble_phy.c ---------------------------------------------------------------------- diff --git a/hw/drivers/nimble/nrf52/src/ble_phy.c b/hw/drivers/nimble/nrf52/src/ble_phy.c index 92941f2..9b178e3 100644 --- a/hw/drivers/nimble/nrf52/src/ble_phy.c +++ b/hw/drivers/nimble/nrf52/src/ble_phy.c @@ -418,7 +418,7 @@ ble_phy_tx_end_isr(void) } wfr_time = txstart - BLE_TX_LEN_USECS_M(NRF_RX_START_OFFSET); wfr_time += BLE_TX_DUR_USECS_M(txlen); - wfr_time += os_cputime_usecs_to_ticks(BLE_LL_WFR_USECS); + wfr_time = os_cputime_usecs_to_ticks(BLE_LL_WFR_USECS + wfr_time); ble_ll_wfr_enable(wfr_time); } else { /* Disable automatic TXEN */ @@ -536,7 +536,7 @@ ble_phy_rx_start_isr(void) ble_hdr->rxinfo.channel = g_ble_phy_data.phy_chan; ble_hdr->rxinfo.handle = 0; ble_hdr->beg_cputime = NRF_TIMER0->CC[1] - - BLE_TX_LEN_USECS_M(NRF_RX_START_OFFSET); + os_cputime_usecs_to_ticks(BLE_TX_LEN_USECS_M(NRF_RX_START_OFFSET)); /* Call Link Layer receive start function */ rc = ble_ll_rx_start((uint8_t *)&g_ble_phy_rx_buf[0] + 3, http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fa73ce59/net/nimble/controller/src/ble_ll_adv.c ---------------------------------------------------------------------- diff --git a/net/nimble/controller/src/ble_ll_adv.c b/net/nimble/controller/src/ble_ll_adv.c index 0b7b470..bb1523f 100644 --- a/net/nimble/controller/src/ble_ll_adv.c +++ b/net/nimble/controller/src/ble_ll_adv.c @@ -1266,7 +1266,8 @@ ble_ll_adv_conn_req_rxd(uint8_t *rxbuf, struct ble_mbuf_hdr *hdr, /* Try to start slave connection. If successful, stop advertising */ pyld_len = rxbuf[1] & BLE_ADV_PDU_HDR_LEN_MASK; - endtime = hdr->beg_cputime + BLE_TX_DUR_USECS_M(pyld_len); + endtime = hdr->beg_cputime + + os_cputime_usecs_to_ticks(BLE_TX_DUR_USECS_M(pyld_len)); valid = ble_ll_conn_slave_start(rxbuf, endtime, addr_type, hdr); if (valid) { ble_ll_adv_sm_stop(advsm); http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fa73ce59/net/nimble/controller/src/ble_ll_conn.c ---------------------------------------------------------------------- diff --git a/net/nimble/controller/src/ble_ll_conn.c b/net/nimble/controller/src/ble_ll_conn.c index f5211e7..7ced9c0 100644 --- a/net/nimble/controller/src/ble_ll_conn.c +++ b/net/nimble/controller/src/ble_ll_conn.c @@ -2215,7 +2215,8 @@ ble_ll_init_rx_pkt_in(uint8_t *rxbuf, struct ble_mbuf_hdr *ble_hdr) g_ble_ll_conn_create_sm = NULL; ble_ll_scan_sm_stop(0); payload_len = rxbuf[1] & BLE_ADV_PDU_HDR_LEN_MASK; - endtime = ble_hdr->beg_cputime + BLE_TX_DUR_USECS_M(payload_len); + endtime = ble_hdr->beg_cputime + + os_cputime_usecs_to_ticks(BLE_TX_DUR_USECS_M(payload_len)); ble_ll_conn_created(connsm, endtime, NULL); } else { ble_ll_scan_chk_resume(); @@ -2366,7 +2367,8 @@ ble_ll_init_rx_isr_end(uint8_t *rxbuf, uint8_t crcok, } /* Attempt to schedule new connection. Possible that this might fail */ - endtime = ble_hdr->beg_cputime + BLE_TX_DUR_USECS_M(pyld_len); + endtime = ble_hdr->beg_cputime + + os_cputime_usecs_to_ticks(BLE_TX_DUR_USECS_M(pyld_len)); if (!ble_ll_sched_master_new(connsm, endtime, MYNEWT_VAL(BLE_LL_CONN_INIT_SLOTS))) { /* Setup to transmit the connect request */ @@ -2675,7 +2677,8 @@ ble_ll_conn_rx_isr_end(uint8_t *rxbuf, struct ble_mbuf_hdr *rxhdr) } /* Calculate the end time of the received PDU */ - endtime = rxhdr->beg_cputime + BLE_TX_DUR_USECS_M(rx_pyld_len); + endtime = rxhdr->beg_cputime + + os_cputime_usecs_to_ticks(BLE_TX_DUR_USECS_M(rx_pyld_len)); /* * Check the packet CRC. A connection event can continue even if the
