ENSMM / Mbed 2 deprecated TIMER

Dependencies:   mbed

Fork of TIMER by Joël Imbaud

Files at this revision

API Documentation at this revision

Comitter:
jimbaud
Date:
Tue Jan 08 10:10:00 2019 +0000
Commit message:
Use the Timer interface to create, start, stop and read a timer for measuring small times (between microseconds and seconds). ; You can independently create, start and stop any number of Timer objects.

Changed in this revision

Main.cpp 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
diff -r 000000000000 -r 5e0d72de5692 Main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Main.cpp	Tue Jan 08 10:10:00 2019 +0000
@@ -0,0 +1,25 @@
+/* https://os.mbed.com/docs/v5.7/reference/timer.html
+
+Use the Timer interface to create, start, stop and read a timer for measuring small times (between microseconds and seconds). 
+You can independently create, start and stop any number of Timer objects.
+*/
+
+// Count the time to toggle a LED
+
+#include "mbed.h"
+
+Timer timer;
+DigitalOut led(LED1);
+int begin, end;
+
+int main() {
+
+    while(1) {
+                timer.start();
+                begin = timer.read_us();
+                led = !led;
+                end = timer.read_us();
+                printf("Toggle the led takes %d us \n", end - begin);
+                wait(1);
+             }
+           }
\ No newline at end of file
diff -r 000000000000 -r 5e0d72de5692 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Jan 08 10:10:00 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc
\ No newline at end of file