1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#ifndef TIME_H #define TIME_H #include "thread.h" 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