Skip to content

Fix Greentea test code with wakeup from deepsleep #7288

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
Jun 21, 2018
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
20 changes: 18 additions & 2 deletions TESTS/mbed_hal/sleep/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@

#define US_PER_S 1000000

/* Flush serial buffer before deep sleep
*
* Since deepsleep() may shut down the UART peripheral, we wait for some time
* to allow for hardware serial buffers to completely flush.
*
* Take NUMAKER_PFM_NUC472 as an example:
* Its UART peripheral has 16-byte Tx FIFO. With baud rate set to 9600, flush
* Tx FIFO would take: 16 * 8 * 1000 / 9600 = 13.3 (ms). So set wait time to
* 20ms here for safe.
*
* This should be replaced with a better function that checks if the
* hardware buffers are empty. However, such an API does not exist now,
* so we'll use the wait_ms() function for now.
*/
#define SERIAL_FLUSH_TIME_MS 20

using namespace utest::v1;

/* The following ticker frequencies are possible:
Expand Down Expand Up @@ -167,7 +183,7 @@ void deepsleep_lpticker_test()
/* Give some time Green Tea to finish UART transmission before entering
* deep-sleep mode.
*/
wait_ms(10);
wait_ms(SERIAL_FLUSH_TIME_MS);

TEST_ASSERT_TRUE_MESSAGE(sleep_manager_can_deep_sleep(), "deep sleep should not be locked");

Expand Down Expand Up @@ -202,7 +218,7 @@ void deepsleep_high_speed_clocks_turned_off_test()
/* Give some time Green Tea to finish UART transmission before entering
* deep-sleep mode.
*/
wait_ms(10);
wait_ms(SERIAL_FLUSH_TIME_MS);

TEST_ASSERT_TRUE_MESSAGE(sleep_manager_can_deep_sleep(), "deep sleep should not be locked");

Expand Down