From f036286a6fbbe13bb3dcdb8dfe5a14a7ed75eaa2 Mon Sep 17 00:00:00 2001 From: Larry Bernstone Date: Sat, 17 Apr 2021 11:43:24 -0600 Subject: [PATCH] Fixed ESP::getCycleCount for S2/C3 --- cores/esp32/Esp.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cores/esp32/Esp.h b/cores/esp32/Esp.h index 34643117a59..81684836e9d 100644 --- a/cores/esp32/Esp.h +++ b/cores/esp32/Esp.h @@ -22,6 +22,9 @@ #include #include +#ifndef CONFIG_IDF_TARGET_ESP32 // Broken in IDF 20210417 +#include +#endif /** * AVR macros for WDT managment @@ -111,7 +114,11 @@ class EspClass uint32_t ARDUINO_ISR_ATTR EspClass::getCycleCount() { uint32_t ccount; +#ifdef CONFIG_IDF_TARGET_ESP32 __asm__ __volatile__("esync; rsr %0,ccount":"=a" (ccount)); +#else // This should work on ESP32 once the hal is complete + ccount = systimer_hal_get_counter_value(SYSTIMER_COUNTER_0); +#endif return ccount; }