Watchdog version 1

Dependencies:   mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
greenroshks
Date:
Mon Dec 01 06:40:13 2014 +0000
Commit message:
Watchdog IITMSAT

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Dec 01 06:40:13 2014 +0000
@@ -0,0 +1,57 @@
+#include "mbed.h"
+#include "rtos.h"
+
+
+// The trigger D4 is connected to Watchdog input and WD output is connected to interrupt button D3. The ISR thus evoked will trigger reset. Alternately, D3 can be connected to reset as well 
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+DigitalOut trigger(D2);             //triggering watchdog
+DigitalOut reset(D4);             //D4 is connected to uC reset
+Serial pc(USBTX,USBRX);
+InterruptIn button(D3);             //ISR initialize
+
+void led2_thread(void const *args) {
+    while (true) {
+        led2 = !led2;
+        Thread::wait(1000);
+    }
+}
+ 
+void led1_thread(void const *args)
+{
+    while(true)
+    {
+        led1!=led1;
+        Thread::wait(500);
+    }
+}
+
+void WDT(void const *args)
+{
+    trigger=1;
+    while(true)
+    {
+        trigger=!trigger;
+        Thread::wait(5000);
+    }
+}
+void fault()
+{
+    printf("\n Watchdog triggered... Saving parameters\n");
+    reset=1;
+}
+
+int main() {
+    button.rise(&fault);
+    Thread thread1(led1_thread);
+    Thread thread2(led2_thread);
+    Thread watchdog(WDT);
+    
+    thread1.set_priority(osPriorityRealtime);
+    thread2.set_priority(osPriorityHigh);
+    watchdog.set_priority(osPriorityIdle);
+    
+    while (true) {
+       Thread::wait(8000);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Mon Dec 01 06:40:13 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#a3452b867ec3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Dec 01 06:40:13 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/031413cf7a89
\ No newline at end of file