Watchdog_Step-2_Edwin_Kadavy

Fork of Watchdog_sample_nocoverage by William Marsh

Revision:
6:554f0a4b681b
Parent:
3:32a940251192
--- a/main.cpp	Tue Feb 27 10:29:30 2018 +0000
+++ b/main.cpp	Fri Mar 09 23:15:14 2018 +0000
@@ -23,6 +23,8 @@
 Thread threadLED1 ; // thread LED1
 Thread threadLED2 ; // thread LED2
 
+enum wState {Working, Stopped} ;
+
 // ------------Fault Injection Button-------------
 //  Wait while the button is down
 //     Use this to simulate a STUCK fault
@@ -37,6 +39,7 @@
 void led1_thread() {  // method to run in thread
     osEvent evt ;
     while (true) {
+        wdt_kickA();    // second part
         evt = Thread::signal_wait(0x0); // wait for any signal
         if (evt.status == osEventSignal) {
             if (evt.value.signals & 0x01) led1 = ON ;
@@ -52,12 +55,13 @@
 void led2_thread() {  // method to run in thread
     osEvent evt ;
     while (true) {
+        wdt_kickB();    // second part
         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
     }
 }
 
@@ -67,12 +71,14 @@
 void timer_thread() {  // method to run in thread
     while (true) {
         Thread::wait(250) ;
+        //wdt_kickA();    // first part
         threadLED1.signal_set(0x1) ;
         threadLED2.signal_set(0x1) ;
         Thread::wait(250) ;
+        //wdt_kickA();    // first part
         threadLED1.signal_set(0x2) ;
         threadLED2.signal_set(0x2) ;
-        // waitButton() ; // POSSIBLE FAULT HERE
+         //waitButton() ; // POSSIBLE FAULT HERE
     }
 }
 
@@ -85,8 +91,9 @@
 // ----------------------------------------------
 
 int main(void) {
-    wdt_32ms() ; // initialise watchdog - 32ms timeout
-    tick.attach_us(callback(&wdt_kick_all), 20000); // ticks every 20ms    
+    wdt_256ms() ; // initialise watchdog - 256ms timeout
+    //wdt_kick_all;
+    //tick.attach_us(callback(&wdt_kick_all), 20000); // ticks every 20ms    
     
     // start threads
     threadT.start(&timer_thread) ; // start the timer thread