blob: f4e3ce67fcc1670d309e7690052d61421410d1e2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#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 uint32_t time() {
return systime;
}
inline static void sleep(uint32_t ms) {
ms += systime;
while(systime < ms) {
Thread::yield();
}
}
};
#endif
|