Watchdog example. Added fault coverage in all 3 threads.

Fork of Watchdog_sample_nocoverage by William Marsh

Revision:
6:0b769cc52024
Parent:
3:32a940251192
Child:
7:9def90a894b9
--- a/main.cpp	Tue Feb 27 10:29:30 2018 +0000
+++ b/main.cpp	Fri Mar 09 15:01:33 2018 +0000
@@ -19,9 +19,9 @@
 Ticker tick;
 
 // Threads
-Thread threadT ; // timer thread 
-Thread threadLED1 ; // thread LED1
-Thread threadLED2 ; // thread LED2
+Thread threadT(osPriorityNormal, 2000); // timer thread 
+Thread threadLED1(osPriorityNormal, 2000); // thread LED1
+Thread threadLED2(osPriorityNormal, 2000); // thread LED2
 
 // ------------Fault Injection Button-------------
 //  Wait while the button is down
@@ -41,8 +41,9 @@
         if (evt.status == osEventSignal) {
             if (evt.value.signals & 0x01) led1 = ON ;
             if (evt.value.signals & 0x02) led1 = OFF ;
+            wdt_kickA();
         } 
-        waitButton() ;  // POSSIBLE FAULT HERE
+        //waitButton() ;  // POSSIBLE FAULT HERE
     }
 }
 
@@ -56,8 +57,9 @@
         if (evt.status == osEventSignal) {
             if (evt.value.signals & 0x01) led2 = ON ;
             if (evt.value.signals & 0x02) led2 = OFF ;
+            wdt_kickB();
         } 
-        // 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,8 +87,7 @@
 // ----------------------------------------------
 
 int main(void) {
-    wdt_32ms() ; // initialise watchdog - 32ms timeout
-    tick.attach_us(callback(&wdt_kick_all), 20000); // ticks every 20ms    
+    wdt_1sec() ; // initialise watchdog - 1sec timeout
     
     // start threads
     threadT.start(&timer_thread) ; // start the timer thread