Lab 6 Code 1 Watchdog Fault Coverage
Fork of Watchdog_sample_nocoverage by
Diff: main.cpp
- Revision:
- 6:0da8649c011b
- Parent:
- 3:32a940251192
diff -r 9817756efc34 -r 0da8649c011b main.cpp --- a/main.cpp Tue Feb 27 10:29:30 2018 +0000 +++ b/main.cpp Fri Mar 09 23:04:34 2018 +0000 @@ -1,5 +1,5 @@ #include "mbed.h" -#include "rtos.h" +//#include "rtos.h" #include "wdt.h" // Sample program using the Watchdog @@ -37,12 +37,13 @@ void led1_thread() { // method to run in thread osEvent evt ; while (true) { +wdt_kickA(); //write the value 0x55 to the Watchdog Register evt = Thread::signal_wait(0x0); // wait for any signal if (evt.status == osEventSignal) { if (evt.value.signals & 0x01) led1 = ON ; if (evt.value.signals & 0x02) led1 = OFF ; } - waitButton() ; // POSSIBLE FAULT HERE + // waitButton() ; // POSSIBLE FAULT HERE } } @@ -52,12 +53,13 @@ void led2_thread() { // method to run in thread osEvent evt ; while (true) { + wdt_kickB(); //write the value 0xAA to the Watchdog Register evt = Thread::signal_wait(0x0); // wait for any signal if (evt.status == osEventSignal) { if (evt.value.signals & 0x01) led2 = ON ; if (evt.value.signals & 0x02) led2 = OFF ; } - // waitButton() ; // POSSIBLE FAULT HERE + // waitButton() ; // POSSIBLE FAULT HERE } } @@ -72,7 +74,7 @@ Thread::wait(250) ; threadLED1.signal_set(0x2) ; threadLED2.signal_set(0x2) ; - // waitButton() ; // POSSIBLE FAULT HERE + waitButton() ; // POSSIBLE FAULT HERE } } @@ -85,9 +87,8 @@ // ---------------------------------------------- int main(void) { - wdt_32ms() ; // initialise watchdog - 32ms timeout - tick.attach_us(callback(&wdt_kick_all), 20000); // ticks every 20ms - + wdt_1sec() ; // initialise watchdog - 1 second timeout + // start threads threadT.start(&timer_thread) ; // start the timer thread threadLED1.start(&led1_thread) ; // start the LED1 control thread