Skip to content

Commit 7d575af

Browse files
author
Filip Jagodzinski
committed
Test: Watchdog: Increase the UART flush wait
1 parent 0fd8bb6 commit 7d575af

File tree

4 files changed

+37
-28
lines changed

4 files changed

+37
-28
lines changed

TESTS/mbed_drivers/watchdog/main.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@
5151
* are empty. However, it is possible to determine the time required for the
5252
* buffers to flush.
5353
*
54-
* Take NUMAKER_PFM_NUC472 as an example:
55-
* The UART peripheral has 16-byte Tx FIFO. With a baud rate set to 9600,
56-
* flushing the Tx FIFO would take: 16 * 8 * 1000 / 9600 = 13.3 ms.
57-
* To be on the safe side, set the wait time to 20 ms.
54+
* Assuming the biggest Tx FIFO of 128 bytes (as for CY8CPROTO_062_4343W)
55+
* and a default UART config (9600, 8N1), flushing the Tx FIFO wold take:
56+
* (1 start_bit + 8 data_bits + 1 stop_bit) * 128 * 1000 / 9600 = 133.3 ms.
57+
* To be on the safe side, set the wait time to 150 ms.
5858
*/
59-
#define SERIAL_FLUSH_TIME_MS 20
59+
#define SERIAL_FLUSH_TIME_MS 150
6060

6161
int CASE_INDEX_START;
6262
int CASE_INDEX_CURRENT;

TESTS/mbed_drivers/watchdog_reset/main.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@
6161
* are empty. However, it is possible to determine the time required for the
6262
* buffers to flush.
6363
*
64-
* Take NUMAKER_PFM_NUC472 as an example:
65-
* The UART peripheral has 16-byte Tx FIFO. With a baud rate set to 9600,
66-
* flushing the Tx FIFO would take: 16 * 8 * 1000 / 9600 = 13.3 ms.
67-
* To be on the safe side, set the wait time to 20 ms.
64+
* Assuming the biggest Tx FIFO of 128 bytes (as for CY8CPROTO_062_4343W)
65+
* and a default UART config (9600, 8N1), flushing the Tx FIFO wold take:
66+
* (1 start_bit + 8 data_bits + 1 stop_bit) * 128 * 1000 / 9600 = 133.3 ms.
67+
* To be on the safe side, set the wait time to 150 ms.
6868
*/
69-
#define SERIAL_FLUSH_TIME_MS 20
69+
#define SERIAL_FLUSH_TIME_MS 150
7070

7171
#define TIMEOUT_US (1000 * (TIMEOUT_MS))
7272
#define KICK_ADVANCE_US (1000 * (KICK_ADVANCE_MS))
@@ -112,10 +112,11 @@ void test_simple_reset()
112112

113113
// Phase 1. -- run the test code.
114114
// Init the watchdog and wait for a device reset.
115-
if (send_reset_notification(&current_case, 2 * TIMEOUT_MS) == false) {
115+
if (send_reset_notification(&current_case, 2 * TIMEOUT_MS + SERIAL_FLUSH_TIME_MS) == false) {
116116
TEST_ASSERT_MESSAGE(0, "Dev-host communication error.");
117117
return;
118118
}
119+
wait_us(SERIAL_FLUSH_TIME_US); // Wait for the serial buffers to flush.
119120
Watchdog &watchdog = Watchdog::get_instance();
120121
TEST_ASSERT_FALSE(watchdog.is_running());
121122
TEST_ASSERT_TRUE(watchdog.start(TIMEOUT_MS));
@@ -141,10 +142,11 @@ void test_sleep_reset()
141142
}
142143

143144
// Phase 1. -- run the test code.
144-
if (send_reset_notification(&current_case, 2 * TIMEOUT_MS) == false) {
145+
if (send_reset_notification(&current_case, 2 * TIMEOUT_MS + SERIAL_FLUSH_TIME_MS) == false) {
145146
TEST_ASSERT_MESSAGE(0, "Dev-host communication error.");
146147
return;
147148
}
149+
wait_us(SERIAL_FLUSH_TIME_US); // Wait for the serial buffers to flush.
148150
Watchdog &watchdog = Watchdog::get_instance();
149151
TEST_ASSERT_FALSE(watchdog.is_running());
150152
TEST_ASSERT_TRUE(watchdog.start(TIMEOUT_MS));
@@ -232,10 +234,11 @@ void test_restart_reset()
232234
// The watchdog should trigger before twice the timeout value.
233235
wait_us(TIMEOUT_US / 2 + TIMEOUT_US);
234236

235-
if (send_reset_notification(&current_case, 2 * TIMEOUT_MS) == false) {
237+
if (send_reset_notification(&current_case, 2 * TIMEOUT_MS + SERIAL_FLUSH_TIME_MS) == false) {
236238
TEST_ASSERT_MESSAGE(0, "Dev-host communication error.");
237239
return;
238240
}
241+
wait_us(SERIAL_FLUSH_TIME_US); // Wait for the serial buffers to flush.
239242
TEST_ASSERT_TRUE(watchdog.start(TIMEOUT_MS));
240243
TEST_ASSERT_TRUE(watchdog.is_running());
241244
// Watchdog should fire before twice the timeout value.
@@ -268,10 +271,11 @@ void test_kick_reset()
268271
wait_us(TIMEOUT_US - KICK_ADVANCE_US);
269272
watchdog.kick();
270273
}
271-
if (send_reset_notification(&current_case, 2 * TIMEOUT_MS) == false) {
274+
if (send_reset_notification(&current_case, 2 * TIMEOUT_MS + SERIAL_FLUSH_TIME_MS) == false) {
272275
TEST_ASSERT_MESSAGE(0, "Dev-host communication error.");
273276
return;
274277
}
278+
wait_us(SERIAL_FLUSH_TIME_US); // Wait for the serial buffers to flush.
275279
// Watchdog should fire before twice the timeout value.
276280
wait_us(2 * TIMEOUT_US); // Device reset expected.
277281

TESTS/mbed_hal/watchdog/main.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@
5252
* are empty. However, it is possible to determine the time required for the
5353
* buffers to flush.
5454
*
55-
* Take NUMAKER_PFM_NUC472 as an example:
56-
* The UART peripheral has 16-byte Tx FIFO. With a baud rate set to 9600,
57-
* flushing the Tx FIFO would take: 16 * 8 * 1000 / 9600 = 13.3 ms.
58-
* To be on the safe side, set the wait time to 20 ms.
55+
* Assuming the biggest Tx FIFO of 128 bytes (as for CY8CPROTO_062_4343W)
56+
* and a default UART config (9600, 8N1), flushing the Tx FIFO wold take:
57+
* (1 start_bit + 8 data_bits + 1 stop_bit) * 128 * 1000 / 9600 = 133.3 ms.
58+
* To be on the safe side, set the wait time to 150 ms.
5959
*/
60-
#define SERIAL_FLUSH_TIME_MS 20
60+
#define SERIAL_FLUSH_TIME_MS 150
6161

6262
int CASE_INDEX_START;
6363
int CASE_INDEX_CURRENT;

TESTS/mbed_hal/watchdog_reset/main.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@
6161
* are empty. However, it is possible to determine the time required for the
6262
* buffers to flush.
6363
*
64-
* Take NUMAKER_PFM_NUC472 as an example:
65-
* The UART peripheral has 16-byte Tx FIFO. With a baud rate set to 9600,
66-
* flushing the Tx FIFO would take: 16 * 8 * 1000 / 9600 = 13.3 ms.
67-
* To be on the safe side, set the wait time to 20 ms.
64+
* Assuming the biggest Tx FIFO of 128 bytes (as for CY8CPROTO_062_4343W)
65+
* and a default UART config (9600, 8N1), flushing the Tx FIFO wold take:
66+
* (1 start_bit + 8 data_bits + 1 stop_bit) * 128 * 1000 / 9600 = 133.3 ms.
67+
* To be on the safe side, set the wait time to 150 ms.
6868
*/
69-
#define SERIAL_FLUSH_TIME_MS 20
69+
#define SERIAL_FLUSH_TIME_MS 150
7070

7171
#define TIMEOUT_US (1000 * (TIMEOUT_MS))
7272
#define KICK_ADVANCE_US (1000 * (KICK_ADVANCE_MS))
@@ -111,10 +111,11 @@ void test_simple_reset()
111111
// Phase 1. -- run the test code.
112112
// Init the watchdog and wait for a device reset.
113113
watchdog_config_t config = { TIMEOUT_MS };
114-
if (send_reset_notification(&current_case, 2 * TIMEOUT_MS) == false) {
114+
if (send_reset_notification(&current_case, 2 * TIMEOUT_MS + SERIAL_FLUSH_TIME_MS) == false) {
115115
TEST_ASSERT_MESSAGE(0, "Dev-host communication error.");
116116
return;
117117
}
118+
wait_us(SERIAL_FLUSH_TIME_US); // Wait for the serial buffers to flush.
118119
TEST_ASSERT_EQUAL(WATCHDOG_STATUS_OK, hal_watchdog_init(&config));
119120
// Watchdog should fire before twice the timeout value.
120121
wait_us(2 * TIMEOUT_US); // Device reset expected.
@@ -138,10 +139,11 @@ void test_sleep_reset()
138139

139140
// Phase 1. -- run the test code.
140141
watchdog_config_t config = { TIMEOUT_MS };
141-
if (send_reset_notification(&current_case, 2 * TIMEOUT_MS) == false) {
142+
if (send_reset_notification(&current_case, 2 * TIMEOUT_MS + SERIAL_FLUSH_TIME_MS) == false) {
142143
TEST_ASSERT_MESSAGE(0, "Dev-host communication error.");
143144
return;
144145
}
146+
wait_us(SERIAL_FLUSH_TIME_US); // Wait for the serial buffers to flush.
145147
TEST_ASSERT_EQUAL(WATCHDOG_STATUS_OK, hal_watchdog_init(&config));
146148
sleep_manager_lock_deep_sleep();
147149
if (sleep_manager_can_deep_sleep()) {
@@ -176,6 +178,7 @@ void test_deepsleep_reset()
176178
return;
177179
}
178180
wait_us(SERIAL_FLUSH_TIME_US); // Wait for the serial buffers to flush.
181+
wait_us(SERIAL_FLUSH_TIME_US); // Wait for the serial buffers to flush.
179182
TEST_ASSERT_EQUAL(WATCHDOG_STATUS_OK, hal_watchdog_init(&config));
180183
if (!sleep_manager_can_deep_sleep()) {
181184
TEST_ASSERT_MESSAGE(0, "Deepsleep should be allowed.");
@@ -221,10 +224,11 @@ void test_restart_reset()
221224
// The watchdog should trigger before twice the timeout value.
222225
wait_us(TIMEOUT_US / 2 + TIMEOUT_US);
223226

224-
if (send_reset_notification(&current_case, 2 * TIMEOUT_MS) == false) {
227+
if (send_reset_notification(&current_case, 2 * TIMEOUT_MS + SERIAL_FLUSH_TIME_MS) == false) {
225228
TEST_ASSERT_MESSAGE(0, "Dev-host communication error.");
226229
return;
227230
}
231+
wait_us(SERIAL_FLUSH_TIME_US); // Wait for the serial buffers to flush.
228232
TEST_ASSERT_EQUAL(WATCHDOG_STATUS_OK, hal_watchdog_init(&config));
229233
// Watchdog should fire before twice the timeout value.
230234
wait_us(2 * TIMEOUT_US); // Device reset expected.
@@ -254,10 +258,11 @@ void test_kick_reset()
254258
wait_us(TIMEOUT_US - KICK_ADVANCE_US);
255259
hal_watchdog_kick();
256260
}
257-
if (send_reset_notification(&current_case, 2 * TIMEOUT_MS) == false) {
261+
if (send_reset_notification(&current_case, 2 * TIMEOUT_MS + SERIAL_FLUSH_TIME_MS) == false) {
258262
TEST_ASSERT_MESSAGE(0, "Dev-host communication error.");
259263
return;
260264
}
265+
wait_us(SERIAL_FLUSH_TIME_US); // Wait for the serial buffers to flush.
261266
// Watchdog should fire before twice the timeout value.
262267
wait_us(2 * TIMEOUT_US); // Device reset expected.
263268

0 commit comments

Comments
 (0)