Commit 7fe2812f authored by Dirk O. Kaar's avatar Dirk O. Kaar Committed by Me No Dev

Inline ESP::getCycleCount() to make it safe to call from ISRs (#3165)

* Inline ESP::getCycleCount() to make it safe to call from ISRs

* Attribute IRAM_ATTR ISR-safe function in addition to inlining.
parent 9710feda
...@@ -92,13 +92,6 @@ void EspClass::deepSleep(uint32_t time_us) ...@@ -92,13 +92,6 @@ void EspClass::deepSleep(uint32_t time_us)
esp_deep_sleep(time_us); esp_deep_sleep(time_us);
} }
uint32_t EspClass::getCycleCount()
{
uint32_t ccount;
__asm__ __volatile__("esync; rsr %0,ccount":"=a" (ccount));
return ccount;
}
void EspClass::restart(void) void EspClass::restart(void)
{ {
esp_restart(); esp_restart();
......
...@@ -76,7 +76,7 @@ public: ...@@ -76,7 +76,7 @@ public:
uint8_t getChipRevision(); uint8_t getChipRevision();
uint32_t getCpuFreqMHz(){ return getCpuFrequencyMhz(); } uint32_t getCpuFreqMHz(){ return getCpuFrequencyMhz(); }
uint32_t getCycleCount(); inline uint32_t getCycleCount() __attribute__((always_inline));
const char * getSdkVersion(); const char * getSdkVersion();
void deepSleep(uint32_t time_us); void deepSleep(uint32_t time_us);
...@@ -101,6 +101,13 @@ public: ...@@ -101,6 +101,13 @@ public:
}; };
uint32_t IRAM_ATTR EspClass::getCycleCount()
{
uint32_t ccount;
__asm__ __volatile__("esync; rsr %0,ccount":"=a" (ccount));
return ccount;
}
extern EspClass ESP; extern EspClass ESP;
#endif //ESP_H #endif //ESP_H
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment