diff --git a/TESTS/mbed_drivers/reset_reason/main.cpp b/TESTS/mbed_drivers/reset_reason/main.cpp index a72796f879..6299d86937 100644 --- a/TESTS/mbed_drivers/reset_reason/main.cpp +++ b/TESTS/mbed_drivers/reset_reason/main.cpp @@ -29,7 +29,6 @@ #define MSG_VALUE_WATCHDOG_STATUS "wdg_present" #define WDG_TIMEOUT_MS 50UL -#define WDG_TIMEOUT_DELTA_MS 50UL #else #define MSG_VALUE_WATCHDOG_STATUS "no_wdg" @@ -50,6 +49,8 @@ #define MSG_KEY_RESET_REASON "reason" #define MSG_KEY_DEVICE_RESET "reset" +#define SERIAL_FLUSH_TIME_MS 20 + typedef enum { CMD_STATUS_CONTINUE, CMD_STATUS_ERROR @@ -91,7 +92,7 @@ static cmd_status_t handle_command(const char *key, const char *value) if (strcmp(key, MSG_KEY_DEVICE_RESET) == 0 && strcmp(value, MSG_VALUE_DEVICE_RESET_NVIC) == 0) { greentea_send_kv(MSG_KEY_DEVICE_RESET, MSG_VALUE_DEVICE_RESET_ACK); - wait_ms(10); // Wait for the serial buffers to flush. + wait_ms(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush. NVIC_SystemReset(); TEST_ASSERT_MESSAGE(0, "NVIC_SystemReset did not reset the device as expected."); return CMD_STATUS_ERROR; @@ -100,13 +101,13 @@ static cmd_status_t handle_command(const char *key, const char *value) #if DEVICE_WATCHDOG if (strcmp(key, MSG_KEY_DEVICE_RESET) == 0 && strcmp(value, MSG_VALUE_DEVICE_RESET_WATCHDOG) == 0) { greentea_send_kv(MSG_KEY_DEVICE_RESET, MSG_VALUE_DEVICE_RESET_ACK); - wait_ms(10); // Wait for the serial buffers to flush. + wait_ms(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush. watchdog_config_t config = { .timeout_ms = WDG_TIMEOUT_MS }; if (hal_watchdog_init(&config) != WATCHDOG_STATUS_OK) { TEST_ASSERT_MESSAGE(0, "hal_watchdog_init() error."); return CMD_STATUS_ERROR; } - wait_ms(WDG_TIMEOUT_MS + WDG_TIMEOUT_DELTA_MS); + wait_ms(2 * WDG_TIMEOUT_MS); // Watchdog should fire before twice the timeout value. TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected."); return CMD_STATUS_ERROR; }