summaryrefslogtreecommitdiff
path: root/include/arch/esp8266/driver/uptime.h
blob: 21740c94ba93e306335a944c52e66654cd67217b (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
#ifndef UPTIME_H
#define UPTIME_H

extern "C" {
#include "osapi.h"
#include "user_interface.h"
}
#include "c_types.h"

class Uptime {
	private:
		Uptime(const Uptime &copy);

	public:
		Uptime () {}
		inline uint32_t get_us() { return system_get_time(); }

		inline uint32_t get_cycles()
		{
			uint32_t ccount;
			asm volatile ("esync; rsr %0,ccount":"=a" (ccount));
			return ccount;
		}
};

extern Uptime uptime;

#endif