6666 * flushing the Tx FIFO would take: 16 * 8 * 1000 / 9600 = 13.3 ms.
6767 * To be on the safe side, set the wait time to 20 ms.
6868 */
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))
7074
7175using utest::v1::Case;
7276using utest::v1::Specification;
@@ -128,9 +132,9 @@ void test_simple_reset()
128132 }
129133 TEST_ASSERT_EQUAL (WATCHDOG_STATUS_OK, hal_watchdog_init (&config));
130134 // 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.
132136
133- // Watchdog reset should have occurred during wait_ms() above;
137+ // Watchdog reset should have occurred during a wait above.
134138
135139 kick_wdg_during_test_teardown.release (); // For testsuite failure handling.
136140 TEST_ASSERT_MESSAGE (0 , " Watchdog did not reset the device as expected." );
@@ -162,10 +166,10 @@ void test_sleep_reset()
162166 TEST_ASSERT_MESSAGE (0 , " Deepsleep should be disallowed." );
163167 return ;
164168 }
165- sem.wait (); // Device reset expected.
169+ sem.acquire (); // Device reset expected.
166170 sleep_manager_unlock_deep_sleep ();
167171
168- // Watchdog reset should have occurred during sem.wait () (sleep) above;
172+ // Watchdog reset should have occurred during sem.acquire () (sleep) above.
169173
170174 kick_wdg_during_test_teardown.release (); // For testsuite failure handling.
171175 TEST_ASSERT_MESSAGE (0 , " Watchdog did not reset the device as expected." );
@@ -192,13 +196,13 @@ void test_deepsleep_reset()
192196 TEST_ASSERT_EQUAL (WATCHDOG_STATUS_OK, hal_watchdog_init (&config));
193197 // Watchdog should fire before twice the timeout value.
194198 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.
196200 if (!sleep_manager_can_deep_sleep ()) {
197201 TEST_ASSERT_MESSAGE (0 , " Deepsleep should be allowed." );
198202 }
199- sem.wait (); // Device reset expected.
203+ sem.acquire (); // Device reset expected.
200204
201- // Watchdog reset should have occurred during sem.wait () (deepsleep) above;
205+ // Watchdog reset should have occurred during sem.acquire () (deepsleep) above.
202206
203207 kick_wdg_during_test_teardown.release (); // For testsuite failure handling.
204208 TEST_ASSERT_MESSAGE (0 , " Watchdog did not reset the device as expected." );
@@ -224,22 +228,22 @@ void test_restart_reset()
224228 // Phase 1. -- run the test code.
225229 watchdog_config_t config = { TIMEOUT_MS };
226230 TEST_ASSERT_EQUAL (WATCHDOG_STATUS_OK, hal_watchdog_init (&config));
227- wait_ms (TIMEOUT_MS / 2UL );
231+ wait_us (TIMEOUT_US / 2 );
228232 TEST_ASSERT_EQUAL (WATCHDOG_STATUS_OK, hal_watchdog_stop ());
229233 // Check that stopping the Watchdog prevents a device reset.
230234 // The watchdog should trigger at, or after the timeout value.
231235 // 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 );
233237
234238 if (send_reset_notification (¤t_case, 2 * TIMEOUT_MS) == false ) {
235239 TEST_ASSERT_MESSAGE (0 , " Dev-host communication error." );
236240 return ;
237241 }
238242 TEST_ASSERT_EQUAL (WATCHDOG_STATUS_OK, hal_watchdog_init (&config));
239243 // 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.
241245
242- // Watchdog reset should have occurred during that wait() above;
246+ // Watchdog reset should have occurred during a wait above.
243247
244248 kick_wdg_during_test_teardown.release (); // For testsuite failure handling.
245249 TEST_ASSERT_MESSAGE (0 , " Watchdog did not reset the device as expected." );
@@ -260,17 +264,17 @@ void test_kick_reset()
260264 for (int i = 3 ; i; i--) {
261265 // The reset is prevented as long as the watchdog is kicked
262266 // anytime before the timeout.
263- wait_ms (TIMEOUT_MS - KICK_ADVANCE_MS );
267+ wait_us (TIMEOUT_US - KICK_ADVANCE_US );
264268 hal_watchdog_kick ();
265269 }
266270 if (send_reset_notification (¤t_case, 2 * TIMEOUT_MS) == false ) {
267271 TEST_ASSERT_MESSAGE (0 , " Dev-host communication error." );
268272 return ;
269273 }
270274 // 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.
272276
273- // Watchdog reset should have occurred during that wait() above;
277+ // Watchdog reset should have occurred during a wait above.
274278
275279 kick_wdg_during_test_teardown.release (); // For testsuite failure handling.
276280 TEST_ASSERT_MESSAGE (0 , " Watchdog did not reset the device as expected." );
0 commit comments