mirror of https://github.com/ARMmbed/mbed-os.git
Test: update reset_reason driver test
Update the watchdog timing requirements: 1. The watchdog should trigger at, or after the timeout value. 2. The watchdog should trigger before twice the timeout value. Use a SERIAL_FLUSH_TIME_MS value consistent with other tests.pull/10902/head
parent
ee202dafd8
commit
94181a9930
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue