@@ -90,18 +90,7 @@ struct testcase_data {
9090
9191testcase_data current_case;
9292
93- Thread wdg_kicking_thread (osPriorityNormal, 768 );
94- Semaphore kick_wdg_during_test_teardown (0 , 1 );
95-
96- void wdg_kicking_thread_fun ()
97- {
98- kick_wdg_during_test_teardown.acquire ();
99- Watchdog &watchdog = Watchdog::get_instance ();
100- while (true ) {
101- watchdog.kick ();
102- wait_us (20000 );
103- }
104- }
93+ Ticker wdg_kicking_ticker;
10594
10695bool send_reset_notification (testcase_data *tcdata, uint32_t delay_ms)
10796{
@@ -140,7 +129,8 @@ void test_simple_reset()
140129
141130 // Watchdog reset should have occurred during a wait above.
142131
143- kick_wdg_during_test_teardown.release (); // For testsuite failure handling.
132+ hal_watchdog_kick ();
133+ wdg_kicking_ticker.attach_us (mbed::callback (hal_watchdog_kick), 20000 ); // For testsuite failure handling.
144134 TEST_ASSERT_MESSAGE (0 , " Watchdog did not reset the device as expected." );
145135}
146136
@@ -174,7 +164,8 @@ void test_sleep_reset()
174164
175165 // Watchdog reset should have occurred during the sleep above.
176166
177- kick_wdg_during_test_teardown.release (); // For testsuite failure handling.
167+ hal_watchdog_kick ();
168+ wdg_kicking_ticker.attach_us (mbed::callback (hal_watchdog_kick), 20000 ); // For testsuite failure handling.
178169 TEST_ASSERT_MESSAGE (0 , " Watchdog did not reset the device as expected." );
179170}
180171
@@ -210,7 +201,8 @@ void test_deepsleep_reset()
210201
211202 // Watchdog reset should have occurred during the deepsleep above.
212203
213- kick_wdg_during_test_teardown.release (); // For testsuite failure handling.
204+ hal_watchdog_kick ();
205+ wdg_kicking_ticker.attach_us (mbed::callback (hal_watchdog_kick), 20000 ); // For testsuite failure handling.
214206 TEST_ASSERT_MESSAGE (0 , " Watchdog did not reset the device as expected." );
215207}
216208#endif
@@ -255,7 +247,8 @@ void test_restart_reset()
255247
256248 // Watchdog reset should have occurred during a wait above.
257249
258- kick_wdg_during_test_teardown.release (); // For testsuite failure handling.
250+ hal_watchdog_kick ();
251+ wdg_kicking_ticker.attach_us (mbed::callback (hal_watchdog_kick), 20000 ); // For testsuite failure handling.
259252 TEST_ASSERT_MESSAGE (0 , " Watchdog did not reset the device as expected." );
260253}
261254
@@ -288,7 +281,8 @@ void test_kick_reset()
288281
289282 // Watchdog reset should have occurred during a wait above.
290283
291- kick_wdg_during_test_teardown.release (); // For testsuite failure handling.
284+ hal_watchdog_kick ();
285+ wdg_kicking_ticker.attach_us (mbed::callback (hal_watchdog_kick), 20000 ); // For testsuite failure handling.
292286 TEST_ASSERT_MESSAGE (0 , " Watchdog did not reset the device as expected." );
293287}
294288
@@ -323,10 +317,6 @@ int testsuite_setup(const size_t number_of_cases)
323317 return utest::v1::STATUS_ABORT;
324318 }
325319
326- // The thread is started here, but feeding the watchdog will start
327- // when the semaphore is released during a test case teardown.
328- wdg_kicking_thread.start (mbed::callback (wdg_kicking_thread_fun));
329-
330320 utest_printf (" This test suite is composed of %i test cases. Starting at index %i.\n " , number_of_cases,
331321 current_case.start_index );
332322 return current_case.start_index ;
0 commit comments