Fixed ESP::getCycleCount for S2/C3 (#5075)

Fixes #5071
This commit is contained in:
lbernstone 2021-04-19 03:28:06 -06:00 committed by GitHub
parent fb0d63b576
commit b45cf11ff1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,6 +22,9 @@
#include <Arduino.h>
#include <esp_partition.h>
#ifndef CONFIG_IDF_TARGET_ESP32 // Broken in IDF 20210417
#include <hal/systimer_hal.h>
#endif
/**
* AVR macros for WDT managment
@ -111,7 +114,11 @@ public:
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;
}