diff options
Diffstat (limited to 'include/esp8266/driver')
-rw-r--r-- | include/esp8266/driver/uptime.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/include/esp8266/driver/uptime.h b/include/esp8266/driver/uptime.h index 7da10cb..21740c9 100644 --- a/include/esp8266/driver/uptime.h +++ b/include/esp8266/driver/uptime.h @@ -1,6 +1,10 @@ #ifndef UPTIME_H #define UPTIME_H +extern "C" { +#include "osapi.h" +#include "user_interface.h" +} #include "c_types.h" class Uptime { @@ -9,7 +13,14 @@ class Uptime { public: Uptime () {} - uint32_t get(); + 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; |