Skip to content

Use LP tickers for waiting in no RTOS builds when available #9960

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

Merged
merged 1 commit into from
May 21, 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
9 changes: 8 additions & 1 deletion platform/mbed_wait_api_no_rtos.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,23 @@
// if the RTOS is not present.
#ifndef MBED_CONF_RTOS_PRESENT

#include "hal/lp_ticker_api.h"
#include "hal/us_ticker_api.h"

void wait(float s)
{
wait_us(s * 1000000.0f);
wait_ms(s * 1000.0f);
}

void wait_ms(int ms)
{
#if DEVICE_LPTICKER
const ticker_data_t *const ticker = get_lp_ticker_data();
uint32_t start = ticker_read(ticker);
while ((ticker_read(ticker) - start) < (uint32_t)(ms * 1000));
#else
wait_us(ms * 1000);
#endif
}

void wait_us(int us)
Expand Down