timer tests with the STM32F303K8 nucleo board

Dependencies:   mbed

Revision:
0:e40146aa84f7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Jun 10 17:52:10 2016 +0000
@@ -0,0 +1,35 @@
+#include "mbed.h"
+
+Timer t;
+int rise_time = 0;
+int fall_time = 0;
+bool new_rise = false;
+bool new_fall = false;
+
+void pin_up(){
+    rise_time=t.read_us();
+    new_rise=true;
+}
+
+void pin_down(){
+    fall_time=t.read_us();
+    new_fall=true;
+}
+
+Serial pc(USBTX, USBRX);
+ 
+int main() {
+     pc.baud(230400);
+     t.start();
+     InterruptIn _interrupt(D1);
+     _interrupt.rise(&pin_up);
+     _interrupt.fall(&pin_down);
+    pc.printf("Hello World!");
+    while(1) {
+        if(new_rise && new_fall) {
+            pc.printf("%d\n\r", fall_time - rise_time);
+            new_rise=false;
+            new_fall=false;
+        }
+    }
+}
\ No newline at end of file