wayne roberts / Mbed OS demo_TimeoutAbs

Dependencies:   TimeoutAbs

Files at this revision

API Documentation at this revision

Comitter:
Wayne Roberts
Date:
Mon Nov 26 14:37:06 2018 -0800
Commit message:
initial commit

Changed in this revision

TimeoutAbs.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TimeoutAbs.lib	Mon Nov 26 14:37:06 2018 -0800
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/dudmuck/code/TimeoutAbs/#900163d530ae
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Nov 26 14:37:06 2018 -0800
@@ -0,0 +1,40 @@
+#include "mbed.h"
+#include "LowPowerTimeoutAbs.h"
+
+volatile bool ev;
+Timer t;
+
+LowPowerTimeoutAbs tabs;
+
+void my_callback()
+{
+    ev = true;
+}
+
+us_timestamp_t tabs_started_at;
+
+int main()
+{
+    unsigned prev;
+    t.start();
+	tabs_started_at = tabs.read_us();
+    tabs.attach_us(my_callback, tabs_started_at + 100000);
+    prev = t.read_us();
+	printf("tabs_started_at:%llu prev:%u\r\n", tabs_started_at, prev);
+    for (;;) {
+        unsigned now;
+        if (ev) {
+            unsigned late;
+            now = t.read_us();
+			tabs_started_at += 1000000;
+            late = rand() % 200000;
+            printf("time %u\t", now - prev);
+            fflush(stdout);
+            wait_us(late);
+            printf("late:%u\r\n", late);
+            tabs.attach_us(my_callback, tabs_started_at);
+            prev = now;
+            ev = false;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Mon Nov 26 14:37:06 2018 -0800
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#2fd0c5cfbd83fce62da6308f9d64c0ab64e1f0d6