Skip to content

Commit

Permalink
uptime: use timer from esp-idf
Browse files Browse the repository at this point in the history
  • Loading branch information
vooon committed Jan 27, 2019
1 parent de2fb4c commit 42b968c
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion lib/uptime/uptime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@

#include <Arduino.h>

#if 0

extern "C" {
#include <freertos/FreeRTOS.h>
#include <freertos/timers.h>
}


static volatile uint64_t m_uptime = 0;
static uint32_t m_last_millis = 0;

Expand All @@ -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

0 comments on commit 42b968c

Please sign in to comment.