summaryrefslogtreecommitdiff
path: root/os/time.h
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2012-08-07 16:50:46 +0200
committerVegard Storheil Eriksen <zyp@jvnv.net>2012-08-07 16:50:46 +0200
commite586c178073b9a0fee90d5fc8e795d266ebd7b7d (patch)
treeca9a9c40bab37d5af440c80833755223e2bdd946 /os/time.h
Initial import.
Most sources are split off from suzumebachi project revision 2fc77d2 as is with some path changes. New build rules introduced.
Diffstat (limited to 'os/time.h')
-rw-r--r--os/time.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/os/time.h b/os/time.h
new file mode 100644
index 0000000..3533967
--- /dev/null
+++ b/os/time.h
@@ -0,0 +1,32 @@
+#ifndef TIME_H
+#define TIME_H
+
+#include "thread.h"
+
+struct STK_t {
+ volatile uint32_t CTRL;
+ volatile uint32_t LOAD;
+ volatile uint32_t VAL;
+ volatile uint32_t CALIB;
+};
+
+static STK_t& STK = *(STK_t*)0xe000e010;
+
+class Time {
+ private:
+ static volatile uint32_t systime;
+
+ public:
+ inline static void tick() {
+ systime++;
+ }
+
+ inline static void sleep(uint32_t ms) {
+ ms += systime;
+ while(systime < ms) {
+ Thread::yield();
+ }
+ }
+};
+
+#endif