Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync with ArduinoBLE #10

Merged
merged 4 commits into from
Dec 3, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/utility/HCICordioTransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,20 @@ extern "C" void wsf_mbed_ble_signal_event(void)
}
#endif //CORDIO_ZERO_COPY_HCI

#define CORDIO_TRANSPORT_WSF_MS_PER_TICK 10

static void bleLoop()
{
#if CORDIO_ZERO_COPY_HCI
uint64_t last_update_us = 0;
mbed::LowPowerTimer timer;

timer.start();

while (true) {
last_update_us += (uint64_t) timer.read_high_resolution_us();
timer.reset();

uint64_t last_update_ms = (last_update_us / 1000);
wsfTimerTicks_t wsf_ticks = (last_update_ms / CORDIO_TRANSPORT_WSF_MS_PER_TICK);
wsfTimerTicks_t wsf_ticks = (last_update_ms / WSF_MS_PER_TICK);

if (wsf_ticks > 0) {
WsfTimerUpdate(wsf_ticks);
Expand All @@ -137,9 +137,9 @@ static void bleLoop()
uint64_t time_spent = (uint64_t) timer.read_high_resolution_us();

/* don't bother sleeping if we're already past tick */
if (sleep && (CORDIO_TRANSPORT_WSF_MS_PER_TICK * 1000 > time_spent)) {
if (sleep && (WSF_MS_PER_TICK * 1000 > time_spent)) {
/* sleep to maintain constant tick rate */
uint64_t wait_time_us = CORDIO_TRANSPORT_WSF_MS_PER_TICK * 1000 - time_spent;
uint64_t wait_time_us = WSF_MS_PER_TICK * 1000 - time_spent;
uint64_t wait_time_ms = wait_time_us / 1000;

wait_time_us = wait_time_us % 1000;
Expand Down