diff options
author | Levi Oliver <levio@google.com> | 2016-08-09 16:20:14 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-08-23 15:36:55 -0700 |
commit | 1e2148249a82a867b201d0689bdef1fa3d185569 (patch) | |
tree | a193c603c6617be133928ed46849161afc2fe5a6 /chip | |
parent | 6e866962a0ed5ffa7af96555e2855e4046e5ab7f (diff) | |
download | chrome-ec-1e2148249a82a867b201d0689bdef1fa3d185569.tar.gz |
btle: Accepts and maintains connections
Can now accept and maintain a single connection indefinitely by
sending empty packets at every connection interval to keep the
connection alive.
TEST=BTLE dongle sending connect requests and connecting to NRF51
running this code. Connection was established and ran for at least
48 hours until manual termination.
BUG=None
BRANCH=None
Change-Id: Iad4bd434ecd1edd6c5c8dfe8b72ca41fd82d0bb4
Signed-off-by: Levi Oliver <levio@google.com>
Reviewed-on: https://chromium-review.googlesource.com/370839
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'chip')
-rw-r--r-- | chip/nrf51/bluetooth_le.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/chip/nrf51/bluetooth_le.c b/chip/nrf51/bluetooth_le.c index 4b9adc4e60..831edd920c 100644 --- a/chip/nrf51/bluetooth_le.c +++ b/chip/nrf51/bluetooth_le.c @@ -6,6 +6,7 @@ #include "bluetooth_le.h" #include "include/bluetooth_le.h" #include "console.h" +#include "ppi.h" #include "radio.h" #include "registers.h" #include "timer.h" @@ -92,10 +93,13 @@ int ble_radio_init(uint32_t access_address, uint32_t crc_init_val) NRF51_RADIO_BASE0 = access_address << 8; NRF51_RADIO_PREFIX0 = access_address >> 24; + if (access_address != BLE_ADV_ACCESS_ADDRESS) + CPRINTF("Initializing radio for data packet.\n"); + NRF51_RADIO_TXADDRESS = 0; NRF51_RADIO_RXADDRESSES = 1; NRF51_RADIO_PCNF0 = NRF51_RADIO_PCNF0_ADV_DATA; - NRF51_RADIO_PCNF1 = NRF51_RADIO_PCNF0_ADV_DATA; + NRF51_RADIO_PCNF1 = NRF51_RADIO_PCNF1_ADV_DATA; return rv; @@ -140,6 +144,7 @@ int ble_rx(struct ble_pdu *pdu, int timeout, int adv) { uint32_t done; uint32_t timeout_time; + int ppi_channel_requested; /* Prevent illegal wait times */ if (timeout <= 0) { @@ -157,6 +162,19 @@ int ble_rx(struct ble_pdu *pdu, int timeout, int adv) NRF51_RADIO_SHORTS = NRF51_RADIO_SHORTS_READY_START | NRF51_RADIO_SHORTS_DISABLED_TXEN | NRF51_RADIO_SHORTS_END_DISABLE; + + /* + * This creates a shortcut that marks the time + * that the payload was received by the radio + * in NRF51_TIMER_CC(0,1) + */ + ppi_channel_requested = NRF51_PPI_CH_RADIO_ADDR__TIMER0CC1; + if (ppi_request_channel(&ppi_channel_requested) == EC_SUCCESS) { + NRF51_PPI_CHEN |= (1 << ppi_channel_requested); + NRF51_PPI_CHENSET |= (1 << ppi_channel_requested); + } + + NRF51_RADIO_RXEN = 1; timeout_time = get_time().val + RADIO_SETUP_TIMEOUT; |