mbed-os5

Fork of mbed-os-example-blinky by richard misi

Revision:
77:d67966bc6494
Parent:
76:0d9524062816
Child:
78:aedfba031509
diff -r 0d9524062816 -r d67966bc6494 main.cpp
--- a/main.cpp	Thu Aug 30 08:39:36 2018 +0000
+++ b/main.cpp	Thu Aug 30 10:53:51 2018 +0000
@@ -1,17 +1,31 @@
 #include "mbed.h"
 
+#define TSample        0.001
+#define Periode        700
+#define onTime          10
+
 DigitalOut led(LED4);
 DigitalOut son(p8);
 
+int wdt = 0;
+
+Ticker TMainProcess;
+
+void MainProcess_Isr(){
+    --wdt; 
+    if((wdt< onTime)& (wdt> 0)){led= 1;};
+    if(wdt<= 0){led= 0; wdt= Periode;};
+    }
+
+void init(void){
+    son= 0;
+    TMainProcess.attach(&MainProcess_Isr, TSample); 
+    }
+
 
 // main() runs in its own thread in the OS
-int main() {
-    son= 0;
-    while (true) {
-        led = 1;
-        wait(0.05);
-        led = 0;
-        wait(0.9);
-    }
+void main() {
+     init();
+     while (true) {};
 }