summaryrefslogtreecommitdiff
path: root/os/time.h
blob: eddba327e0a3aa783869d03fd85b304ad56f15e6 (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
#ifndef TIME_H
#define TIME_H

#include <cstdint>

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) {
			}
		}
};

#endif