Skip to content

Commit 64c527e

Browse files
authored
Merge pull request #3017 from bridadan/wait-before-deepsleep-test
[tests] Waiting before call to deepsleep to allow buffers to flush
2 parents 2ae7177 + 9a4aeec commit 64c527e

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

TESTS/mbed_drivers/lp_timeout/main.cpp

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

46-
/*
47-
* We use here lp_ticker_read() instead of us_ticker_read() for start and
46+
/*
47+
* Since deepsleep() may shut down the UART peripheral, we wait for 10ms
48+
* to allow for hardware serial buffers to completely flush.
49+
50+
* This should be replaced with a better function that checks if the
51+
* hardware buffers are empty. However, such an API does not exist now,
52+
* so we'll use the wait_ms() function for now.
53+
*/
54+
wait_ms(10);
55+
56+
/*
57+
* We use here lp_ticker_read() instead of us_ticker_read() for start and
4858
* end because the microseconds timer might be disable during deepsleep.
4959
*/
5060
timestamp_t start = lp_ticker_read();

TESTS/mbed_hal/lp_ticker/main.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,22 @@ void lp_ticker_1s_deepsleep()
6565
complete = false;
6666
uint32_t delay_ts;
6767

68+
/*
69+
* Since deepsleep() may shut down the UART peripheral, we wait for 10ms
70+
* to allow for hardware serial buffers to completely flush.
71+
72+
* This should be replaced with a better function that checks if the
73+
* hardware buffers are empty. However, such an API does not exist now,
74+
* so we'll use the wait_ms() function for now.
75+
*/
76+
wait_ms(10);
77+
6878
ticker_set_handler(lp_ticker_data, cb_done);
6979
ticker_remove_event(lp_ticker_data, &delay_event);
7080
delay_ts = lp_ticker_read() + 1000000;
7181

72-
/*
73-
* We use here lp_ticker_read() instead of us_ticker_read() for start and
82+
/*
83+
* We use here lp_ticker_read() instead of us_ticker_read() for start and
7484
* end because the microseconds timer might be disable during deepsleep.
7585
*/
7686
timestamp_t start = lp_ticker_read();

0 commit comments

Comments
 (0)