14
14
* See the License for the specific language governing permissions and
15
15
* limitations under the License.
16
16
*/
17
- #if !defined(MBED_CONF_RTOS_PRESENT)
18
- #error [NOT_SUPPORTED] Watchdog reset test cases require a RTOS to run.
19
- #else
20
-
21
17
#if !DEVICE_WATCHDOG
22
18
#error [NOT_SUPPORTED] Watchdog not supported for this target
23
19
#else
@@ -90,18 +86,7 @@ struct testcase_data {
90
86
91
87
testcase_data current_case;
92
88
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;
105
90
106
91
bool send_reset_notification (testcase_data *tcdata, uint32_t delay_ms)
107
92
{
@@ -140,7 +125,8 @@ void test_simple_reset()
140
125
141
126
// Watchdog reset should have occurred during a wait above.
142
127
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.
144
130
TEST_ASSERT_MESSAGE (0 , " Watchdog did not reset the device as expected." );
145
131
}
146
132
@@ -174,7 +160,8 @@ void test_sleep_reset()
174
160
175
161
// Watchdog reset should have occurred during the sleep above.
176
162
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.
178
165
TEST_ASSERT_MESSAGE (0 , " Watchdog did not reset the device as expected." );
179
166
}
180
167
@@ -210,7 +197,8 @@ void test_deepsleep_reset()
210
197
211
198
// Watchdog reset should have occurred during the deepsleep above.
212
199
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.
214
202
TEST_ASSERT_MESSAGE (0 , " Watchdog did not reset the device as expected." );
215
203
}
216
204
#endif
@@ -255,7 +243,8 @@ void test_restart_reset()
255
243
256
244
// Watchdog reset should have occurred during a wait above.
257
245
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.
259
248
TEST_ASSERT_MESSAGE (0 , " Watchdog did not reset the device as expected." );
260
249
}
261
250
@@ -288,7 +277,8 @@ void test_kick_reset()
288
277
289
278
// Watchdog reset should have occurred during a wait above.
290
279
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.
292
282
TEST_ASSERT_MESSAGE (0 , " Watchdog did not reset the device as expected." );
293
283
}
294
284
@@ -323,10 +313,6 @@ int testsuite_setup(const size_t number_of_cases)
323
313
return utest::v1::STATUS_ABORT;
324
314
}
325
315
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
-
330
316
utest_printf (" This test suite is composed of %i test cases. Starting at index %i.\n " , number_of_cases,
331
317
current_case.start_index );
332
318
return current_case.start_index ;
@@ -352,4 +338,3 @@ int main()
352
338
return !Harness::run (specification);
353
339
}
354
340
#endif // !DEVICE_WATCHDOG
355
- #endif // !defined(MBED_CONF_RTOS_PRESENT)
0 commit comments