Skip to content

Commit 5be51a5

Browse files
authored
Merge pull request #9960 from marcuschangarm/fix-no-rtos-wait
Use LP tickers for waiting in no RTOS builds when available
2 parents 5f36041 + 6aca51f commit 5be51a5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

platform/mbed_wait_api_no_rtos.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,23 @@
2323
// if the RTOS is not present.
2424
#ifndef MBED_CONF_RTOS_PRESENT
2525

26+
#include "hal/lp_ticker_api.h"
2627
#include "hal/us_ticker_api.h"
2728

2829
void wait(float s)
2930
{
30-
wait_us(s * 1000000.0f);
31+
wait_ms(s * 1000.0f);
3132
}
3233

3334
void wait_ms(int ms)
3435
{
36+
#if DEVICE_LPTICKER
37+
const ticker_data_t *const ticker = get_lp_ticker_data();
38+
uint32_t start = ticker_read(ticker);
39+
while ((ticker_read(ticker) - start) < (uint32_t)(ms * 1000));
40+
#else
3541
wait_us(ms * 1000);
42+
#endif
3643
}
3744

3845
void wait_us(int us)

0 commit comments

Comments
 (0)