Skip to content

Commit 7dd1b04

Browse files
authored
Merge pull request #2651 from svastm/fix_lp_timer_test
Use lp_timer to count time in the deepsleep tests
2 parents 14f5647 + cc55173 commit 7dd1b04

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

TESTS/mbed_drivers/lp_timeout/main.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,15 @@ void lp_timeout_1s_deepsleep(void)
4343
{
4444
complete = false;
4545

46-
timestamp_t start = us_ticker_read();
46+
/*
47+
* We use here lp_ticker_read() instead of us_ticker_read() for start and
48+
* end because the microseconds timer might be disable during deepsleep.
49+
*/
50+
timestamp_t start = lp_ticker_read();
4751
lpt.attach(&cb_done, 1);
4852
deepsleep();
4953
while (!complete);
50-
timestamp_t end = us_ticker_read();
54+
timestamp_t end = lp_ticker_read();
5155

5256
/* It takes longer to wake up from deep sleep */
5357
TEST_ASSERT_UINT32_WITHIN(LONG_TIMEOUT, 1000000, end - start);

TESTS/mbed_hal/lp_ticker/main.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,15 @@ void lp_ticker_1s_deepsleep()
6969
ticker_remove_event(lp_ticker_data, &delay_event);
7070
delay_ts = lp_ticker_read() + 1000000;
7171

72-
timestamp_t start = us_ticker_read();
72+
/*
73+
* We use here lp_ticker_read() instead of us_ticker_read() for start and
74+
* end because the microseconds timer might be disable during deepsleep.
75+
*/
76+
timestamp_t start = lp_ticker_read();
7377
ticker_insert_event(lp_ticker_data, &delay_event, delay_ts, (uint32_t)&delay_event);
7478
deepsleep();
7579
while (!complete);
76-
timestamp_t end = us_ticker_read();
80+
timestamp_t end = lp_ticker_read();
7781

7882
TEST_ASSERT_UINT32_WITHIN(LONG_TIMEOUT, 1000000, end - start);
7983
TEST_ASSERT_TRUE(complete);

0 commit comments

Comments
 (0)