diff options
author | Levi Oliver <levio@google.com> | 2016-08-12 09:08:23 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-08-12 20:49:45 -0700 |
commit | 31f297da0b9cb3b4e6fb1cc2f044f71df1c830c2 (patch) | |
tree | e2ee09fd2bd8c1d30cb5d1b930748ea43d46b9c8 /chip/nrf51 | |
parent | f1951ce3a76781f2c3a311342651dc827828d722 (diff) | |
download | chrome-ec-31f297da0b9cb3b4e6fb1cc2f044f71df1c830c2.tar.gz |
btle: Timeout of ble_rx now based on chip time
Previously, timeout meant the number of attempts taken to receive. Now,
it means the number of microseconds before timing out.
TEST=printouts displaying time before and after rx attempt. Not included
in CL.
BUG=None
BRANCH=None
Change-Id: I00ccfc4bbf15f77c2777f35c911dceacaff98e4f
Signed-off-by: Levi Oliver <levio@google.com>
Reviewed-on: https://chromium-review.googlesource.com/368471
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'chip/nrf51')
-rw-r--r-- | chip/nrf51/bluetooth_le.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/chip/nrf51/bluetooth_le.c b/chip/nrf51/bluetooth_le.c index 08a4a26b5f..1f681a3e30 100644 --- a/chip/nrf51/bluetooth_le.c +++ b/chip/nrf51/bluetooth_le.c @@ -119,16 +119,18 @@ static struct nrf51_ble_packet_t rx_packet; int ble_rx(struct ble_pdu *pdu, int timeout, int adv) { uint32_t done; + uint32_t timeout_time; NRF51_RADIO_PACKETPTR = (uint32_t)&rx_packet; NRF51_RADIO_END = NRF51_RADIO_PAYLOAD = NRF51_RADIO_ADDRESS = 0; NRF51_RADIO_SHORTS = NRF51_RADIO_SHORTS_READY_START | NRF51_RADIO_SHORTS_END_DISABLE; NRF51_RADIO_RXEN = 1; + timeout_time = get_time().val + timeout; do { - if (timeout-- <= 0) { - radio_disable(); + if (get_time().val >= timeout_time) { + NRF51_RADIO_DISABLE = 1; return EC_ERROR_TIMEOUT; } done = NRF51_RADIO_END; @@ -138,6 +140,9 @@ int ble_rx(struct ble_pdu *pdu, int timeout, int adv) nrf2ble_packet(pdu, &rx_packet, adv); + if (NRF51_RADIO_DISABLED != 1) + return EC_ERROR_UNKNOWN; + return EC_SUCCESS; } |