From 42b968c7ea96c4210cb38fcc94d1bae8d052b9ec Mon Sep 17 00:00:00 2001 From: Vladimir Ermakov Date: Sun, 27 Jan 2019 18:01:27 +0300 Subject: [PATCH] uptime: use timer from esp-idf --- lib/uptime/uptime.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/uptime/uptime.cpp b/lib/uptime/uptime.cpp index b37e532..f6a2c51 100644 --- a/lib/uptime/uptime.cpp +++ b/lib/uptime/uptime.cpp @@ -3,12 +3,13 @@ #include +#if 0 + extern "C" { #include #include } - static volatile uint64_t m_uptime = 0; static uint32_t m_last_millis = 0; @@ -34,3 +35,20 @@ uint64_t uptime::uptime_ms() { return m_uptime; } + +#else + +#include "esp_timer.h" + +void uptime::init() +{ +} + +uint64_t uptime::uptime_ms() +{ + auto uptime_us = esp_timer_get_time(); + + return uptime_us / 1000; +} + +#endif