Skip to content

Commit 051ff62

Browse files
committed
lp ticker tests: fix timeout usage
Using Timer should be better, as we stay in the current context meanwhile.
1 parent e0bc631 commit 051ff62

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

TESTS/mbed_drivers/lp_timeout/main.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,16 @@ void lp_timeout_1s_deepsleep(void)
4949
5050
* This should be replaced with a better function that checks if the
5151
* hardware buffers are empty. However, such an API does not exist now,
52-
* so we'll use the wait_ms() function for now.
52+
* so we'll use the Timer for now.
5353
*/
54-
wait_ms(10);
54+
{
55+
Timer timer;
56+
timer.start();
57+
int start = timer.read_ms();
58+
int end = start + 10;
59+
while (timer.read_ms() < end) {
60+
}
61+
}
5562

5663
/*
5764
* We use here lp_ticker_read() instead of us_ticker_read() for start and

TESTS/mbed_hal/lp_ticker/main.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,16 @@ void lp_ticker_1s_deepsleep()
7878
7979
* This should be replaced with a better function that checks if the
8080
* hardware buffers are empty. However, such an API does not exist now,
81-
* so we'll use the wait_ms() function for now.
81+
* so we'll use the Timer for now.
8282
*/
83-
wait_ms(10);
83+
{
84+
Timer timer;
85+
timer.start();
86+
int start = timer.read_ms();
87+
int end = start + 10;
88+
while (timer.read_ms() < end) {
89+
}
90+
}
8491

8592
ticker_set_handler(lp_ticker_data, cb_done_deepsleep);
8693
ticker_remove_event(lp_ticker_data, &delay_event);

0 commit comments

Comments
 (0)