66
66
* flushing the Tx FIFO would take: 16 * 8 * 1000 / 9600 = 13.3 ms.
67
67
* To be on the safe side, set the wait time to 20 ms.
68
68
*/
69
- #define SERIAL_FLUSH_TIME_MS 20
69
+ #define SERIAL_FLUSH_TIME_MS 20
70
+
71
+ #define TIMEOUT_US (1000 * (TIMEOUT_MS))
72
+ #define KICK_ADVANCE_US (1000 * (KICK_ADVANCE_MS))
73
+ #define SERIAL_FLUSH_TIME_US (1000 * (SERIAL_FLUSH_TIME_MS))
70
74
71
75
using utest::v1::Case;
72
76
using utest::v1::Specification;
@@ -128,9 +132,9 @@ void test_simple_reset()
128
132
}
129
133
TEST_ASSERT_EQUAL (WATCHDOG_STATUS_OK, hal_watchdog_init (&config));
130
134
// Watchdog should fire before twice the timeout value.
131
- wait_ms (2 * TIMEOUT_MS ); // Device reset expected.
135
+ wait_us (2 * TIMEOUT_US ); // Device reset expected.
132
136
133
- // Watchdog reset should have occurred during wait_ms() above;
137
+ // Watchdog reset should have occurred during a wait above.
134
138
135
139
kick_wdg_during_test_teardown.release (); // For testsuite failure handling.
136
140
TEST_ASSERT_MESSAGE (0 , " Watchdog did not reset the device as expected." );
@@ -162,10 +166,10 @@ void test_sleep_reset()
162
166
TEST_ASSERT_MESSAGE (0 , " Deepsleep should be disallowed." );
163
167
return ;
164
168
}
165
- sem.wait (); // Device reset expected.
169
+ sem.acquire (); // Device reset expected.
166
170
sleep_manager_unlock_deep_sleep ();
167
171
168
- // Watchdog reset should have occurred during sem.wait () (sleep) above;
172
+ // Watchdog reset should have occurred during sem.acquire () (sleep) above.
169
173
170
174
kick_wdg_during_test_teardown.release (); // For testsuite failure handling.
171
175
TEST_ASSERT_MESSAGE (0 , " Watchdog did not reset the device as expected." );
@@ -192,13 +196,13 @@ void test_deepsleep_reset()
192
196
TEST_ASSERT_EQUAL (WATCHDOG_STATUS_OK, hal_watchdog_init (&config));
193
197
// Watchdog should fire before twice the timeout value.
194
198
lp_timeout.attach_us (mbed::callback (release_sem, &sem), 1000ULL * (2 * TIMEOUT_MS));
195
- wait_ms (SERIAL_FLUSH_TIME_MS ); // Wait for the serial buffers to flush.
199
+ wait_us (SERIAL_FLUSH_TIME_US ); // Wait for the serial buffers to flush.
196
200
if (!sleep_manager_can_deep_sleep ()) {
197
201
TEST_ASSERT_MESSAGE (0 , " Deepsleep should be allowed." );
198
202
}
199
- sem.wait (); // Device reset expected.
203
+ sem.acquire (); // Device reset expected.
200
204
201
- // Watchdog reset should have occurred during sem.wait () (deepsleep) above;
205
+ // Watchdog reset should have occurred during sem.acquire () (deepsleep) above.
202
206
203
207
kick_wdg_during_test_teardown.release (); // For testsuite failure handling.
204
208
TEST_ASSERT_MESSAGE (0 , " Watchdog did not reset the device as expected." );
@@ -224,22 +228,22 @@ void test_restart_reset()
224
228
// Phase 1. -- run the test code.
225
229
watchdog_config_t config = { TIMEOUT_MS };
226
230
TEST_ASSERT_EQUAL (WATCHDOG_STATUS_OK, hal_watchdog_init (&config));
227
- wait_ms (TIMEOUT_MS / 2UL );
231
+ wait_us (TIMEOUT_US / 2 );
228
232
TEST_ASSERT_EQUAL (WATCHDOG_STATUS_OK, hal_watchdog_stop ());
229
233
// Check that stopping the Watchdog prevents a device reset.
230
234
// The watchdog should trigger at, or after the timeout value.
231
235
// The watchdog should trigger before twice the timeout value.
232
- wait_ms (TIMEOUT_MS / 2UL + TIMEOUT_MS );
236
+ wait_us (TIMEOUT_US / 2 + TIMEOUT_US );
233
237
234
238
if (send_reset_notification (¤t_case, 2 * TIMEOUT_MS) == false ) {
235
239
TEST_ASSERT_MESSAGE (0 , " Dev-host communication error." );
236
240
return ;
237
241
}
238
242
TEST_ASSERT_EQUAL (WATCHDOG_STATUS_OK, hal_watchdog_init (&config));
239
243
// Watchdog should fire before twice the timeout value.
240
- wait_ms (2 * TIMEOUT_MS ); // Device reset expected.
244
+ wait_us (2 * TIMEOUT_US ); // Device reset expected.
241
245
242
- // Watchdog reset should have occurred during that wait() above;
246
+ // Watchdog reset should have occurred during a wait above.
243
247
244
248
kick_wdg_during_test_teardown.release (); // For testsuite failure handling.
245
249
TEST_ASSERT_MESSAGE (0 , " Watchdog did not reset the device as expected." );
@@ -260,17 +264,17 @@ void test_kick_reset()
260
264
for (int i = 3 ; i; i--) {
261
265
// The reset is prevented as long as the watchdog is kicked
262
266
// anytime before the timeout.
263
- wait_ms (TIMEOUT_MS - KICK_ADVANCE_MS );
267
+ wait_us (TIMEOUT_US - KICK_ADVANCE_US );
264
268
hal_watchdog_kick ();
265
269
}
266
270
if (send_reset_notification (¤t_case, 2 * TIMEOUT_MS) == false ) {
267
271
TEST_ASSERT_MESSAGE (0 , " Dev-host communication error." );
268
272
return ;
269
273
}
270
274
// Watchdog should fire before twice the timeout value.
271
- wait_ms (2 * TIMEOUT_MS ); // Device reset expected.
275
+ wait_us (2 * TIMEOUT_US ); // Device reset expected.
272
276
273
- // Watchdog reset should have occurred during that wait() above;
277
+ // Watchdog reset should have occurred during a wait above.
274
278
275
279
kick_wdg_during_test_teardown.release (); // For testsuite failure handling.
276
280
TEST_ASSERT_MESSAGE (0 , " Watchdog did not reset the device as expected." );
0 commit comments