mirror of https://github.com/ARMmbed/mbed-os.git
Docs: Watchdog: Update code comments
* capitalize driver class name, * reword test docs for the driver & HAL, * capitalize Mbed name, * reword the comments explaining the SERIAL_FLUSH_TIME_MS macro.pull/11023/head
parent
5b0259dbd1
commit
f5e61b99a1
|
@ -1,4 +1,4 @@
|
||||||
/* mbed Microcontroller Library
|
/* Mbed Microcontroller Library
|
||||||
* Copyright (c) 2018 ARM Limited
|
* Copyright (c) 2018 ARM Limited
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* mbed Microcontroller Library
|
/* Mbed Microcontroller Library
|
||||||
* Copyright (c) 2018 ARM Limited
|
* Copyright (c) 2018 ARM Limited
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
|
@ -25,79 +25,84 @@
|
||||||
|
|
||||||
#if DEVICE_WATCHDOG
|
#if DEVICE_WATCHDOG
|
||||||
|
|
||||||
/** Test max_timeout is valid
|
/** Test Watchdog max_timeout validity
|
||||||
*
|
*
|
||||||
* Given a device supporting Watchdog driver API
|
* Given a device supporting Watchdog driver API,
|
||||||
* When @a Watchdog::max_timeout() is called
|
* when @a Watchdog::max_timeout() is called,
|
||||||
* Then the returned value is greater than 1
|
* then the returned value is greater than 1.
|
||||||
*/
|
*/
|
||||||
void test_max_timeout_is_valid();
|
void test_max_timeout_is_valid();
|
||||||
|
|
||||||
/** Test watchdog can be stopped
|
/** Test Watchdog stop
|
||||||
*
|
*
|
||||||
* Given a platform with a support for disabling a running watchdog
|
* Given the Watchdog is *NOT* running,
|
||||||
* When watchdog is not running and @a Watchdog::stop() is called
|
* when @a Watchdog::stop() is called,
|
||||||
* Then WATCHDOG_STATUS_OK is returned
|
* then WATCHDOG_STATUS_OK is returned.
|
||||||
* When watchdog is running
|
*
|
||||||
* and @a Watchdog::stop() is called before timeout
|
* Given the Watchdog is running,
|
||||||
* Then WATCHDOG_STATUS_OK is returned
|
* when @a Watchdog::stop() is called before the timeout expires,
|
||||||
* and watchdog does not reset the device
|
* then WATCHDOG_STATUS_OK is returned and the device is not restarted.
|
||||||
* When watchdog has already been stopped and @a Watchdog::stop() is called
|
*
|
||||||
* Then WATCHDOG_STATUS_OK is returned
|
* Given the Watchdog is *NOT* running (it has already been stopped),
|
||||||
|
* when @a Watchdog::stop() is called,
|
||||||
|
* then WATCHDOG_STATUS_OK is returned.
|
||||||
*/
|
*/
|
||||||
void test_stop();
|
void test_stop();
|
||||||
|
|
||||||
/** Test restart watchdog multiple times
|
/** Test Watchdog start multiple times
|
||||||
*
|
*
|
||||||
* Given @a max_timeout value returned by @a Watchdog::max_timeout()
|
* Given @a max_timeout value returned by @a Watchdog::max_timeout(),
|
||||||
* and @a Watchdog::start() called multiple times
|
*
|
||||||
* When @a timeout is set to max_timeout - delta
|
* when @a Watchdog::start(max_timeout - delta) is called,
|
||||||
* Then return value of @a Watchdog::start() is @a WATCHDOG_STATUS_OK
|
* then @a WATCHDOG_STATUS_OK is returned
|
||||||
* and @a Watchdog::reload_value() returns max_timeout - delta
|
* and @a Watchdog::reload_value() returns max_timeout - delta;
|
||||||
* When @a timeout is set to max_timeout
|
*
|
||||||
* Then return value of @a Watchdog::start() is @a WATCHDOG_STATUS_OK
|
* when @a Watchdog::start(max_timeout) is called,
|
||||||
* and @a Watchdog::reload_value() returns max_timeout
|
* then @a WATCHDOG_STATUS_OK is returned
|
||||||
* When @a timeout is set to max_timeout + delta
|
* and @a Watchdog::reload_value() returns max_timeout;
|
||||||
* Then return value of @a Watchdog::start() is @a WATCHDOG_STATUS_INVALID_ARGUMENT
|
*
|
||||||
* and @a Watchdog::reload_value() returns previously set value (max_timeout)
|
* when @a Watchdog::start(max_timeout + delta) is called,
|
||||||
* When @a timeout is set to 0
|
* then @a WATCHDOG_STATUS_INVALID_ARGUMENT is returned
|
||||||
* Then return value of @a Watchdog::start() is @a WATCHDOG_STATUS_INVALID_ARGUMENT
|
* and @a Watchdog::reload_value() returns previously set value (max_timeout);
|
||||||
* and @a Watchdog::reload_value() returns previously set value (max_timeout)
|
*
|
||||||
|
* when @a Watchdog::start(0) is called,
|
||||||
|
* then @a WATCHDOG_STATUS_INVALID_ARGUMENT is returned
|
||||||
|
* and @a Watchdog::reload_value() returns previously set value (max_timeout).
|
||||||
*/
|
*/
|
||||||
void test_restart();
|
void test_restart();
|
||||||
|
|
||||||
/** Test start with 0 ms
|
/** Test Watchdog start with 0 ms timeout
|
||||||
*
|
*
|
||||||
* Given a device supporting Watchdog driver API
|
* Given a device supporting Watchdog driver API,
|
||||||
* When @a timeout is set to 0 ms
|
* when @a Watchdog::start() is called with @a timeout set to 0 ms,
|
||||||
* Then return value of Watchdog::start() is @a WATCHDOG_STATUS_INVALID_ARGUMENT
|
* then @a WATCHDOG_STATUS_INVALID_ARGUMENT is returned.
|
||||||
*/
|
*/
|
||||||
void test_start_zero();
|
void test_start_zero();
|
||||||
|
|
||||||
/** Test start with a valid config
|
/** Test Watchdog start
|
||||||
*
|
*
|
||||||
* Given a device supporting Watchdog driver API
|
* Given a value of X ms which is within supported Watchdog timeout range,
|
||||||
* When @a timeout is set to value X within platform's timeout range
|
* when @a Watchdog::start() is called with @a timeout set to X ms,
|
||||||
* Then return value of Watchdog::start() is @a WATCHDOG_STATUS_OK
|
* then @a WATCHDOG_STATUS_OK is returned
|
||||||
* and @a Watchdog::reload_value() returns X
|
* and @a Watchdog::reload_value() returns X.
|
||||||
*/
|
*/
|
||||||
template<uint32_t timeout_ms>
|
template<uint32_t timeout_ms>
|
||||||
void test_start();
|
void test_start();
|
||||||
|
|
||||||
/** Test start with a max_timeout
|
/** Test Watchdog start with max_timeout
|
||||||
*
|
*
|
||||||
* Given @a max_timeout value returned by @a Watchdog::max_timeout()
|
* Given @a max_timeout value returned by @a Watchdog::max_timeout(),
|
||||||
* When @a timeout is set to max_timeout
|
* when @a Watchdog::start() is called with @a timeout set to max_timeout,
|
||||||
* Then return value of Watchdog::start() is @a WATCHDOG_STATUS_OK
|
* then @a WATCHDOG_STATUS_OK is returned
|
||||||
* and @a Watchdog::reload_value() returns max_timeout
|
* and @a Watchdog::reload_value() returns max_timeout.
|
||||||
*/
|
*/
|
||||||
void test_start_max_timeout();
|
void test_start_max_timeout();
|
||||||
|
|
||||||
/** Test start with a timeout value exceeding max_timeout
|
/** Test Watchdog start with a timeout value greater than max_timeout
|
||||||
*
|
*
|
||||||
* Given a device supporting Watchdog driver API
|
* Given @a max_timeout value returned by @a Watchdog::max_timeout(),
|
||||||
* When @a timeout is set to max_timeout + 1
|
* when @a Watchdog::start() is called with @a timeout set to max_timeout + 1,
|
||||||
* Then return value of Watchdog::start() is @a WATCHDOG_STATUS_INVALID_ARGUMENT
|
* then @a WATCHDOG_STATUS_INVALID_ARGUMENT is retuned.
|
||||||
*/
|
*/
|
||||||
void test_start_max_timeout_exceeded();
|
void test_start_max_timeout_exceeded();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* mbed Microcontroller Library
|
/* Mbed Microcontroller Library
|
||||||
* Copyright (c) 2018 ARM Limited
|
* Copyright (c) 2018 ARM Limited
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* mbed Microcontroller Library
|
/* Mbed Microcontroller Library
|
||||||
* Copyright (c) 2018 ARM Limited
|
* Copyright (c) 2018 ARM Limited
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
|
@ -25,48 +25,47 @@
|
||||||
|
|
||||||
#if DEVICE_WATCHDOG
|
#if DEVICE_WATCHDOG
|
||||||
|
|
||||||
/** Test watchdog reset
|
/** Test Watchdog reset
|
||||||
*
|
*
|
||||||
* Given a device with a watchdog started
|
* Given a device with a Watchdog started,
|
||||||
* When a watchdog timeout expires
|
* when the Watchdog timeout expires,
|
||||||
* Then the device is restarted
|
* then the device is restarted.
|
||||||
*/
|
*/
|
||||||
void test_simple_reset();
|
void test_simple_reset();
|
||||||
|
|
||||||
/** Test watchdog reset in sleep mode
|
/** Test Watchdog reset in sleep mode
|
||||||
*
|
*
|
||||||
* Given a device supporting sleep mode, with a watchdog started
|
* Given a device with a Watchdog started,
|
||||||
* When the device is in sleep mode and watchdog timeout expires
|
* when the Watchdog timeout expires while the device is in sleep mode,
|
||||||
* Then the device is restarted
|
* then the device is restarted.
|
||||||
*/
|
*/
|
||||||
void test_sleep_reset();
|
void test_sleep_reset();
|
||||||
|
|
||||||
/** Test watchdog reset in deepsleep mode
|
/** Test Watchdog reset in deepsleep mode
|
||||||
*
|
*
|
||||||
* Given a device supporting deepsleep mode, with watchdog started
|
* Given a device with a Watchdog started,
|
||||||
* When the device is in deepsleep mode and watchdog timeout expires
|
* when the Watchdog timeout expires while the device is in deepsleep mode,
|
||||||
* Then the device is restarted
|
* then the device is restarted.
|
||||||
*/
|
*/
|
||||||
void test_deepsleep_reset();
|
void test_deepsleep_reset();
|
||||||
|
|
||||||
/** Test stopped watchdog can be started again and reset the device
|
/** Test Watchdog reset after Watchdog restart
|
||||||
*
|
*
|
||||||
* Given a device supporting 'disable_watchdog' feature, with watchdog started
|
* Given a device with a Watchdog started,
|
||||||
* When the watchdog is stopped before timeout expires
|
* when the Watchdog is stopped before its timeout expires,
|
||||||
* Then the device is not restarted
|
* then the device is not restarted.
|
||||||
* When the watchdog is started again and it's timeout expires
|
* When the Watchdog is started again and its timeout expires,
|
||||||
* Then the device is restarted
|
* then the device is restarted.
|
||||||
*/
|
*/
|
||||||
void test_restart_reset();
|
void test_restart_reset();
|
||||||
|
|
||||||
/** Test kicking the watchdog prevents reset
|
/** Test Watchdog kick
|
||||||
*
|
|
||||||
* Given a device with watchdog started
|
|
||||||
* When the watchdog is kicked before timeout expires
|
|
||||||
* Then the device restart is prevented
|
|
||||||
* When the watchdog is *NOT* kicked again before next timeout expires
|
|
||||||
* Then the device is restarted
|
|
||||||
*
|
*
|
||||||
|
* Given a device with a Watchdog started,
|
||||||
|
* when the Watchdog is kicked before its timeout expires,
|
||||||
|
* then the device restart is prevented.
|
||||||
|
* When the Watchdog is *NOT* kicked again before next timeout expires,
|
||||||
|
* then the device is restarted.
|
||||||
*/
|
*/
|
||||||
void test_kick_reset();
|
void test_kick_reset();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* mbed Microcontroller Library
|
/* Mbed Microcontroller Library
|
||||||
* Copyright (c) 2018 ARM Limited
|
* Copyright (c) 2018 ARM Limited
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* mbed Microcontroller Library
|
/* Mbed Microcontroller Library
|
||||||
* Copyright (c) 2018 ARM Limited
|
* Copyright (c) 2018 ARM Limited
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
|
@ -50,19 +50,18 @@
|
||||||
#define MSG_KEY_RESET_REASON "reason"
|
#define MSG_KEY_RESET_REASON "reason"
|
||||||
#define MSG_KEY_DEVICE_RESET "reset"
|
#define MSG_KEY_DEVICE_RESET "reset"
|
||||||
|
|
||||||
/* Flush serial buffer before deep sleep/reset
|
/* To prevent a loss of Greentea data, the serial buffers have to be flushed
|
||||||
|
* before the UART peripheral shutdown. The UART shutdown happens when the
|
||||||
|
* device is entering the deepsleep mode or performing a reset.
|
||||||
*
|
*
|
||||||
* Since deepsleep()/reset would shut down the UART peripheral, we wait for some time
|
* With the current API, it is not possible to check if the hardware buffers
|
||||||
* to allow for hardware serial buffers to completely flush.
|
* are empty. However, it is possible to determine the time required for the
|
||||||
|
* buffers to flush.
|
||||||
*
|
*
|
||||||
* Take NUMAKER_PFM_NUC472 as an example:
|
* Take NUMAKER_PFM_NUC472 as an example:
|
||||||
* Its UART peripheral has 16-byte Tx FIFO. With baud rate set to 9600, flush
|
* The UART peripheral has 16-byte Tx FIFO. With a baud rate set to 9600,
|
||||||
* Tx FIFO would take: 16 * 8 * 1000 / 9600 = 13.3 (ms). So set wait time to
|
* flushing the Tx FIFO would take: 16 * 8 * 1000 / 9600 = 13.3 ms.
|
||||||
* 20ms here for safe.
|
* To be on the safe side, set the wait time to 20 ms.
|
||||||
*
|
|
||||||
* 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
|
#define SERIAL_FLUSH_TIME_MS 20
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* mbed Microcontroller Library
|
/* Mbed Microcontroller Library
|
||||||
* Copyright (c) 2018 ARM Limited
|
* Copyright (c) 2018 ARM Limited
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
|
@ -31,9 +31,9 @@ extern "C" {
|
||||||
|
|
||||||
/** Test the Reset Reason HAL API
|
/** Test the Reset Reason HAL API
|
||||||
*
|
*
|
||||||
* Given a device supporting a Reset Reason API
|
* Given a device supporting a Reset Reason API,
|
||||||
* When the device is restarted using various methods
|
* when the device is restarted,
|
||||||
* Then the device returns a correct reset reason for every restart
|
* then the device returns a correct reset reason for every restart.
|
||||||
*/
|
*/
|
||||||
void test_reset_reason();
|
void test_reset_reason();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* mbed Microcontroller Library
|
/* Mbed Microcontroller Library
|
||||||
* Copyright (c) 2018 ARM Limited
|
* Copyright (c) 2018 ARM Limited
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
|
@ -45,19 +45,18 @@
|
||||||
#define MSG_KEY_START_CASE "start_case"
|
#define MSG_KEY_START_CASE "start_case"
|
||||||
#define MSG_KEY_DEVICE_RESET "reset_on_case_teardown"
|
#define MSG_KEY_DEVICE_RESET "reset_on_case_teardown"
|
||||||
|
|
||||||
/* Flush serial buffer before deep sleep/reset
|
/* To prevent a loss of Greentea data, the serial buffers have to be flushed
|
||||||
|
* before the UART peripheral shutdown. The UART shutdown happens when the
|
||||||
|
* device is entering the deepsleep mode or performing a reset.
|
||||||
*
|
*
|
||||||
* Since deepsleep()/reset would shut down the UART peripheral, we wait for some time
|
* With the current API, it is not possible to check if the hardware buffers
|
||||||
* to allow for hardware serial buffers to completely flush.
|
* are empty. However, it is possible to determine the time required for the
|
||||||
|
* buffers to flush.
|
||||||
*
|
*
|
||||||
* Take NUMAKER_PFM_NUC472 as an example:
|
* Take NUMAKER_PFM_NUC472 as an example:
|
||||||
* Its UART peripheral has 16-byte Tx FIFO. With baud rate set to 9600, flush
|
* The UART peripheral has 16-byte Tx FIFO. With a baud rate set to 9600,
|
||||||
* Tx FIFO would take: 16 * 8 * 1000 / 9600 = 13.3 (ms). So set wait time to
|
* flushing the Tx FIFO would take: 16 * 8 * 1000 / 9600 = 13.3 ms.
|
||||||
* 20ms here for safe.
|
* To be on the safe side, set the wait time to 20 ms.
|
||||||
*
|
|
||||||
* 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
|
#define SERIAL_FLUSH_TIME_MS 20
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* mbed Microcontroller Library
|
/* Mbed Microcontroller Library
|
||||||
* Copyright (c) 2018 ARM Limited
|
* Copyright (c) 2018 ARM Limited
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
|
@ -25,72 +25,83 @@
|
||||||
|
|
||||||
#if DEVICE_WATCHDOG
|
#if DEVICE_WATCHDOG
|
||||||
|
|
||||||
/** Test max_timeout is valid
|
/** Test max_timeout validity
|
||||||
*
|
*
|
||||||
* Given a device supporting watchdog HAL API
|
* Given a device supporting watchdog HAL API,
|
||||||
* When @a hal_watchdog_get_platform_features() is called
|
* when @a hal_watchdog_get_platform_features() is called,
|
||||||
* Then max_timeout member of returned watchdog_features_t struct is greater than 1
|
* then max_timeout member of returned watchdog_features_t struct is greater than 1.
|
||||||
*/
|
*/
|
||||||
void test_max_timeout_is_valid();
|
void test_max_timeout_is_valid();
|
||||||
|
|
||||||
/** Test stopped watchdog can be started again
|
/** Test watchdog features if a stopped watchdog can be started again
|
||||||
*
|
*
|
||||||
* Given a device supporting watchdog HAL API
|
* Given a device supporting watchdog HAL API,
|
||||||
* When the device supports the @a disable_watchdog feature
|
* when the device supports the @a disable_watchdog feature,
|
||||||
* Then the device also supports @a update_config feature
|
* then the device also supports @a update_config feature.
|
||||||
*/
|
*/
|
||||||
void test_restart_is_possible();
|
void test_restart_is_possible();
|
||||||
|
|
||||||
/** Test watchdog can be stopped
|
/** Test watchdog stop
|
||||||
*
|
*
|
||||||
* Given a device without a support for the @a disable_watchdog feature
|
* Given a device without a support for the @a disable_watchdog feature,
|
||||||
* When @a hal_watchdog_stop() is called
|
* when @a hal_watchdog_stop() is called,
|
||||||
* Then WATCHDOG_STATUS_NOT_SUPPORTED is returned
|
* then WATCHDOG_STATUS_NOT_SUPPORTED is returned.
|
||||||
*
|
*
|
||||||
* Given a device supporting @a disable_watchdog feature
|
* Otherwise, given the device with @a disable_watchdog feature support:
|
||||||
* When watchdog is not running and @a hal_watchdog_stop() is called
|
*
|
||||||
* Then WATCHDOG_STATUS_OK is returned
|
* Given the watchdog is *NOT* running,
|
||||||
* When watchdog is running
|
* when @a hal_watchdog_stop() is called,
|
||||||
* and @a hal_watchdog_stop() is called before timeout
|
* then WATCHDOG_STATUS_OK is returned.
|
||||||
* Then WATCHDOG_STATUS_OK is returned
|
*
|
||||||
* and watchdog does not reset the device
|
* Given the watchdog is running,
|
||||||
* When watchdog has already been stopped and @a hal_watchdog_stop() is called
|
* when @a hal_watchdog_stop() is called before the timeout expires,
|
||||||
* Then WATCHDOG_STATUS_OK is returned
|
* then WATCHDOG_STATUS_OK is returned and the device is not restarted.
|
||||||
|
*
|
||||||
|
* Given the watchdog is *NOT* running (it has already been stopped),
|
||||||
|
* when @a hal_watchdog_stop() is called,
|
||||||
|
* then WATCHDOG_STATUS_OK is returned.
|
||||||
*/
|
*/
|
||||||
void test_stop();
|
void test_stop();
|
||||||
|
|
||||||
/** Test update config with multiple init calls
|
/** Test watchdog init multiple times
|
||||||
*
|
*
|
||||||
* Given @a max_timeout value returned by @a hal_watchdog_get_platform_features()
|
* Given @a max_timeout value returned by @a hal_watchdog_get_platform_features():
|
||||||
* and @a hal_watchdog_init() called multiple times with same @a config
|
*
|
||||||
* When @a config.timeout_ms is set to WDG_CONFIG_DEFAULT
|
* Given @a config.timeout_ms is set to WDG_TIMEOUT_MS,
|
||||||
* Then return value of hal_watchdog_init() is @a WATCHDOG_STATUS_OK
|
* when @a hal_watchdog_init() is called,
|
||||||
* and @a hal_watchdog_get_reload_value() returns WDG_CONFIG_DEFAULT
|
* then @a WATCHDOG_STATUS_OK is returned
|
||||||
* When @a config.timeout_ms is set to max_timeout-delta
|
* and @a hal_watchdog_get_reload_value() returns WDG_TIMEOUT_MS.
|
||||||
* Then return value of hal_watchdog_init() is @a WATCHDOG_STATUS_OK
|
*
|
||||||
* and @a hal_watchdog_get_reload_value() returns max_timeout-delta
|
* Given @a config.timeout_ms is set to max_timeout-delta,
|
||||||
* When @a config.timeout_ms is set to max_timeout
|
* when @a hal_watchdog_init() is called,
|
||||||
* Then return value of hal_watchdog_init() is @a WATCHDOG_STATUS_OK
|
* then @a WATCHDOG_STATUS_OK is returned
|
||||||
* and @a hal_watchdog_get_reload_value() returns max_timeout
|
* and @a hal_watchdog_get_reload_value() returns max_timeout-delta.
|
||||||
|
*
|
||||||
|
* Given @a config.timeout_ms is set to max_timeout,
|
||||||
|
* when @a hal_watchdog_init() is called,
|
||||||
|
* then @a WATCHDOG_STATUS_OK is returned
|
||||||
|
* and @a hal_watchdog_get_reload_value() returns max_timeout.
|
||||||
*/
|
*/
|
||||||
void test_update_config();
|
void test_update_config();
|
||||||
|
|
||||||
/** Test init with a valid config
|
/** Test watchdog init with a valid config
|
||||||
*
|
*
|
||||||
* Given a device supporting watchdog HAL API
|
* Given @a config.timeout_ms is set to X ms,
|
||||||
* When @a config.timeout_ms is set to value X within platform's timeout range
|
* which is within supported watchdog timeout range,
|
||||||
* Then return value of hal_watchdog_init() is @a WATCHDOG_STATUS_OK
|
* when @a hal_watchdog_init() is called,
|
||||||
* and @a hal_watchdog_get_reload_value() returns X
|
* then @a WATCHDOG_STATUS_OK is returned
|
||||||
|
* and @a hal_watchdog_get_reload_value() returns X.
|
||||||
*/
|
*/
|
||||||
template<uint32_t timeout_ms>
|
template<uint32_t timeout_ms>
|
||||||
void test_init();
|
void test_init();
|
||||||
|
|
||||||
/** Test init with a max_timeout
|
/** Test watchdog init with a max_timeout
|
||||||
*
|
*
|
||||||
* Given @a max_timeout value returned by @a hal_watchdog_get_platform_features()
|
* Given @a config.timeout_ms is set to max_timeout,
|
||||||
* When @a config.timeout_ms is set to max_timeout
|
* which is a value returned by @a hal_watchdog_get_platform_features(),
|
||||||
* Then return value of hal_watchdog_init() is @a WATCHDOG_STATUS_OK
|
* when @a hal_watchdog_init() is called,
|
||||||
* and @a hal_watchdog_get_reload_value() returns max_timeout
|
* then @a WATCHDOG_STATUS_OK is returned
|
||||||
|
* and @a hal_watchdog_get_reload_value() returns max_timeout.
|
||||||
*/
|
*/
|
||||||
void test_init_max_timeout();
|
void test_init_max_timeout();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* mbed Microcontroller Library
|
/* Mbed Microcontroller Library
|
||||||
* Copyright (c) 2018 ARM Limited
|
* Copyright (c) 2018 ARM Limited
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
|
@ -45,19 +45,18 @@
|
||||||
#define MSG_KEY_START_CASE "start_case"
|
#define MSG_KEY_START_CASE "start_case"
|
||||||
#define MSG_KEY_DEVICE_RESET "dev_reset"
|
#define MSG_KEY_DEVICE_RESET "dev_reset"
|
||||||
|
|
||||||
/* Flush serial buffer before deep sleep/reset
|
/* To prevent a loss of Greentea data, the serial buffers have to be flushed
|
||||||
|
* before the UART peripheral shutdown. The UART shutdown happens when the
|
||||||
|
* device is entering the deepsleep mode or performing a reset.
|
||||||
*
|
*
|
||||||
* Since deepsleep()/reset would shut down the UART peripheral, we wait for some time
|
* With the current API, it is not possible to check if the hardware buffers
|
||||||
* to allow for hardware serial buffers to completely flush.
|
* are empty. However, it is possible to determine the time required for the
|
||||||
|
* buffers to flush.
|
||||||
*
|
*
|
||||||
* Take NUMAKER_PFM_NUC472 as an example:
|
* Take NUMAKER_PFM_NUC472 as an example:
|
||||||
* Its UART peripheral has 16-byte Tx FIFO. With baud rate set to 9600, flush
|
* The UART peripheral has 16-byte Tx FIFO. With a baud rate set to 9600,
|
||||||
* Tx FIFO would take: 16 * 8 * 1000 / 9600 = 13.3 (ms). So set wait time to
|
* flushing the Tx FIFO would take: 16 * 8 * 1000 / 9600 = 13.3 ms.
|
||||||
* 20ms here for safe.
|
* To be on the safe side, set the wait time to 20 ms.
|
||||||
*
|
|
||||||
* 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
|
#define SERIAL_FLUSH_TIME_MS 20
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* mbed Microcontroller Library
|
/* Mbed Microcontroller Library
|
||||||
* Copyright (c) 2018 ARM Limited
|
* Copyright (c) 2018 ARM Limited
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
|
@ -27,46 +27,45 @@
|
||||||
|
|
||||||
/** Test watchdog reset
|
/** Test watchdog reset
|
||||||
*
|
*
|
||||||
* Given a device with a watchdog started
|
* Given a device with a watchdog started,
|
||||||
* When a watchdog timeout expires
|
* when a watchdog timeout expires,
|
||||||
* Then the device is restarted
|
* then the device is restarted.
|
||||||
*/
|
*/
|
||||||
void test_simple_reset();
|
void test_simple_reset();
|
||||||
|
|
||||||
/** Test watchdog reset in sleep mode
|
/** Test watchdog reset in sleep mode
|
||||||
*
|
*
|
||||||
* Given a device supporting sleep mode, with a watchdog started
|
* Given a device with a watchdog started,
|
||||||
* When the device is in sleep mode and watchdog timeout expires
|
* when the watchdog timeout expires while the device is in sleep mode,
|
||||||
* Then the device is restarted
|
* then the device is restarted.
|
||||||
*/
|
*/
|
||||||
void test_sleep_reset();
|
void test_sleep_reset();
|
||||||
|
|
||||||
/** Test watchdog reset in deepsleep mode
|
/** Test watchdog reset in deepsleep mode
|
||||||
*
|
*
|
||||||
* Given a device supporting deepsleep mode, with watchdog started
|
* Given a device with a watchdog started,
|
||||||
* When the device is in deepsleep mode and watchdog timeout expires
|
* when the watchdog timeout expires while the device is in deepsleep mode,
|
||||||
* Then the device is restarted
|
* then the device is restarted.
|
||||||
*/
|
*/
|
||||||
void test_deepsleep_reset();
|
void test_deepsleep_reset();
|
||||||
|
|
||||||
/** Test stopped watchdog can be started again and reset the device
|
/** Test watchdog reset after watchdog restart
|
||||||
*
|
*
|
||||||
* Given a device supporting 'disable_watchdog' feature, with watchdog started
|
* Given a device with a watchdog started,
|
||||||
* When the watchdog is stopped before timeout expires
|
* when the watchdog is stopped before its timeout expires,
|
||||||
* Then the device is not restarted
|
* then the device is not restarted.
|
||||||
* When the watchdog is started again and it's timeout expires
|
* When the watchdog is started again and its timeout expires,
|
||||||
* Then the device is restarted
|
* then the device is restarted.
|
||||||
*/
|
*/
|
||||||
void test_restart_reset();
|
void test_restart_reset();
|
||||||
|
|
||||||
/** Test kicking the watchdog prevents reset
|
/** Test watchdog kick
|
||||||
*
|
|
||||||
* Given a device with watchdog started
|
|
||||||
* When the watchdog is kicked before timeout expires
|
|
||||||
* Then the device restart is prevented
|
|
||||||
* When the watchdog is *NOT* kicked again before next timeout expires
|
|
||||||
* Then the device is restarted
|
|
||||||
*
|
*
|
||||||
|
* Given a device with a watchdog started,
|
||||||
|
* when the watchdog is kicked before its timeout expires,
|
||||||
|
* then the device restart is prevented.
|
||||||
|
* When the watchdog is *NOT* kicked again before next timeout expires,
|
||||||
|
* then the device is restarted.
|
||||||
*/
|
*/
|
||||||
void test_kick_reset();
|
void test_kick_reset();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* mbed Microcontroller Library
|
/* Mbed Microcontroller Library
|
||||||
* Copyright (c) 2018 ARM Limited
|
* Copyright (c) 2018 ARM Limited
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* mbed Microcontroller Library
|
/* Mbed Microcontroller Library
|
||||||
* Copyright (c) 2018 ARM Limited
|
* Copyright (c) 2018 ARM Limited
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
|
@ -28,14 +28,14 @@
|
||||||
/** Test watchdog timing accuracy
|
/** Test watchdog timing accuracy
|
||||||
*
|
*
|
||||||
* Phase 1.
|
* Phase 1.
|
||||||
* Given a watchdog timer started with a timeout value of X ms
|
* Given a watchdog timer started with a timeout value of X ms,
|
||||||
* When given time of X ms elapses
|
* when the time of X ms elapses,
|
||||||
* Then the device is restarted by the watchdog
|
* then the device is restarted by the watchdog.
|
||||||
*
|
*
|
||||||
* Phase 2.
|
* Phase 2.
|
||||||
* Given a device restarted by the watchdog timer
|
* Given a device restarted by the watchdog timer,
|
||||||
* When the device receives time measurement from the host
|
* when the device receives time measurement from the host,
|
||||||
* Then time measured by host equals X ms
|
* then time measured by host equals X ms.
|
||||||
*/
|
*/
|
||||||
template<uint32_t timeout_ms, uint32_t delta_ms>
|
template<uint32_t timeout_ms, uint32_t delta_ms>
|
||||||
void test_timing();
|
void test_timing();
|
||||||
|
|
Loading…
Reference in New Issue