Jiajun Zhang / Mbed OS Watchdog_sample_nocoverage

Fork of Watchdog_sample_nocoverage by William Marsh

Files at this revision

API Documentation at this revision

Comitter:
Bossman
Date:
Fri Mar 09 18:41:01 2018 +0000
Parent:
5:9817756efc34
Commit message:
Version 1

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Feb 27 10:29:30 2018 +0000
+++ b/main.cpp	Fri Mar 09 18:41:01 2018 +0000
@@ -19,9 +19,10 @@
 Ticker tick;
 
 // Threads
-Thread threadT ; // timer thread 
-Thread threadLED1 ; // thread LED1
-Thread threadLED2 ; // thread LED2
+
+Thread threadT(osPriorityNormal,1000) ; // timer thread 
+Thread threadLED1(osPriorityNormal,1000) ; // thread LED1
+Thread threadLED2(osPriorityNormal,1000) ; // thread LED2
 
 // ------------Fault Injection Button-------------
 //  Wait while the button is down
@@ -37,12 +38,13 @@
 void led1_thread() {  // method to run in thread
     osEvent evt ;
     while (true) {
+        wdt_kickA();
         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,6 +54,7 @@
 void led2_thread() {  // method to run in thread
     osEvent evt ;
     while (true) {
+        wdt_kickB();
         evt = Thread::signal_wait(0x0); // wait for any signal
         if (evt.status == osEventSignal) {
             if (evt.value.signals & 0x01) led2 = ON ;
@@ -72,7 +75,7 @@
         Thread::wait(250) ;
         threadLED1.signal_set(0x2) ;
         threadLED2.signal_set(0x2) ;
-        // waitButton() ; // POSSIBLE FAULT HERE
+         waitButton() ; // POSSIBLE FAULT HERE
     }
 }
 
@@ -85,8 +88,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 - 32ms timeout
+//    tick.attach_us(callback(&wdt_kick_all), 20000); // ticks every 20ms    
     
     // start threads
     threadT.start(&timer_thread) ; // start the timer thread 
@@ -97,4 +100,6 @@
     led_red = OFF;
     Thread::wait(1000) ;
     led_red = ON;
+    
+
 }
\ No newline at end of file