1414 * See the License for the specific language governing permissions and
1515 * limitations under the License.
1616 */
17- #if !defined(MBED_CONF_RTOS_PRESENT)
18- #error [NOT_SUPPORTED] Watchdog reset test cases require a RTOS to run.
19- #else
20-
2117#if !DEVICE_WATCHDOG
2218#error [NOT_SUPPORTED] Watchdog not supported for this target
2319#else
@@ -90,18 +86,7 @@ struct testcase_data {
9086
9187testcase_data current_case;
9288
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- }
89+ Ticker wdg_kicking_ticker;
10590
10691bool send_reset_notification (testcase_data *tcdata, uint32_t delay_ms)
10792{
@@ -140,7 +125,8 @@ void test_simple_reset()
140125
141126 // Watchdog reset should have occurred during a wait above.
142127
143- kick_wdg_during_test_teardown.release (); // For testsuite failure handling.
128+ hal_watchdog_kick ();
129+ wdg_kicking_ticker.attach_us (mbed::callback (hal_watchdog_kick), 20000 ); // For testsuite failure handling.
144130 TEST_ASSERT_MESSAGE (0 , " Watchdog did not reset the device as expected." );
145131}
146132
@@ -174,7 +160,8 @@ void test_sleep_reset()
174160
175161 // Watchdog reset should have occurred during the sleep above.
176162
177- kick_wdg_during_test_teardown.release (); // For testsuite failure handling.
163+ hal_watchdog_kick ();
164+ wdg_kicking_ticker.attach_us (mbed::callback (hal_watchdog_kick), 20000 ); // For testsuite failure handling.
178165 TEST_ASSERT_MESSAGE (0 , " Watchdog did not reset the device as expected." );
179166}
180167
@@ -210,7 +197,8 @@ void test_deepsleep_reset()
210197
211198 // Watchdog reset should have occurred during the deepsleep above.
212199
213- kick_wdg_during_test_teardown.release (); // For testsuite failure handling.
200+ hal_watchdog_kick ();
201+ wdg_kicking_ticker.attach_us (mbed::callback (hal_watchdog_kick), 20000 ); // For testsuite failure handling.
214202 TEST_ASSERT_MESSAGE (0 , " Watchdog did not reset the device as expected." );
215203}
216204#endif
@@ -255,7 +243,8 @@ void test_restart_reset()
255243
256244 // Watchdog reset should have occurred during a wait above.
257245
258- kick_wdg_during_test_teardown.release (); // For testsuite failure handling.
246+ hal_watchdog_kick ();
247+ wdg_kicking_ticker.attach_us (mbed::callback (hal_watchdog_kick), 20000 ); // For testsuite failure handling.
259248 TEST_ASSERT_MESSAGE (0 , " Watchdog did not reset the device as expected." );
260249}
261250
@@ -288,7 +277,8 @@ void test_kick_reset()
288277
289278 // Watchdog reset should have occurred during a wait above.
290279
291- kick_wdg_during_test_teardown.release (); // For testsuite failure handling.
280+ hal_watchdog_kick ();
281+ wdg_kicking_ticker.attach_us (mbed::callback (hal_watchdog_kick), 20000 ); // For testsuite failure handling.
292282 TEST_ASSERT_MESSAGE (0 , " Watchdog did not reset the device as expected." );
293283}
294284
@@ -323,10 +313,6 @@ int testsuite_setup(const size_t number_of_cases)
323313 return utest::v1::STATUS_ABORT;
324314 }
325315
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-
330316 utest_printf (" This test suite is composed of %i test cases. Starting at index %i.\n " , number_of_cases,
331317 current_case.start_index );
332318 return current_case.start_index ;
@@ -352,4 +338,3 @@ int main()
352338 return !Harness::run (specification);
353339}
354340#endif // !DEVICE_WATCHDOG
355- #endif // !defined(MBED_CONF_RTOS_PRESENT)
0 commit comments