From e586c178073b9a0fee90d5fc8e795d266ebd7b7d Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Tue, 7 Aug 2012 16:50:46 +0200 Subject: Initial import. Most sources are split off from suzumebachi project revision 2fc77d2 as is with some path changes. New build rules introduced. --- os/time.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 os/time.h (limited to 'os/time.h') 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 -- cgit v1.2.3