Skip to content

Commit 361804b

Browse files
author
Filip Jagodzinski
committed
Test: Watchdog: Fix deepsleep wait
Wait for the serial buffers flush before starting the watchdog.
1 parent e3f8711 commit 361804b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

TESTS/mbed_drivers/watchdog_reset/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,17 +195,17 @@ void test_deepsleep_reset()
195195
// Phase 1. -- run the test code.
196196
Semaphore sem(0, 1);
197197
LowPowerTimeout lp_timeout;
198-
if (send_reset_notification(&current_case, 2 * TIMEOUT_MS) == false) {
198+
if (send_reset_notification(&current_case, 2 * TIMEOUT_MS + SERIAL_FLUSH_TIME_MS) == false) {
199199
TEST_ASSERT_MESSAGE(0, "Dev-host communication error.");
200200
return;
201201
}
202+
wait_us(SERIAL_FLUSH_TIME_US); // Wait for the serial buffers to flush.
202203
Watchdog &watchdog = Watchdog::get_instance();
203204
TEST_ASSERT_FALSE(watchdog.is_running());
204205
TEST_ASSERT_TRUE(watchdog.start(TIMEOUT_MS));
205206
TEST_ASSERT_TRUE(watchdog.is_running());
206207
// Watchdog should fire before twice the timeout value.
207208
lp_timeout.attach_us(mbed::callback(release_sem, &sem), 1000ULL * (2 * TIMEOUT_MS));
208-
wait_us(SERIAL_FLUSH_TIME_US); // Wait for the serial buffers to flush.
209209
if (!sleep_manager_can_deep_sleep()) {
210210
TEST_ASSERT_MESSAGE(0, "Deepsleep should be allowed.");
211211
}

TESTS/mbed_hal/watchdog_reset/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,14 @@ void test_deepsleep_reset()
189189
watchdog_config_t config = { TIMEOUT_MS };
190190
Semaphore sem(0, 1);
191191
LowPowerTimeout lp_timeout;
192-
if (send_reset_notification(&current_case, 2 * TIMEOUT_MS) == false) {
192+
if (send_reset_notification(&current_case, 2 * TIMEOUT_MS + SERIAL_FLUSH_TIME_MS) == false) {
193193
TEST_ASSERT_MESSAGE(0, "Dev-host communication error.");
194194
return;
195195
}
196+
wait_us(SERIAL_FLUSH_TIME_US); // Wait for the serial buffers to flush.
196197
TEST_ASSERT_EQUAL(WATCHDOG_STATUS_OK, hal_watchdog_init(&config));
197198
// Watchdog should fire before twice the timeout value.
198199
lp_timeout.attach_us(mbed::callback(release_sem, &sem), 1000ULL * (2 * TIMEOUT_MS));
199-
wait_us(SERIAL_FLUSH_TIME_US); // Wait for the serial buffers to flush.
200200
if (!sleep_manager_can_deep_sleep()) {
201201
TEST_ASSERT_MESSAGE(0, "Deepsleep should be allowed.");
202202
}

0 commit comments

Comments
 (0)