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.
This commit is contained in:
Dirk O. Kaar 2019-09-11 13:29:53 +02:00 committed by Me No Dev
parent 9710fedaf0
commit 7fe2812f7f
2 changed files with 8 additions and 8 deletions

View File

@ -92,13 +92,6 @@ void EspClass::deepSleep(uint32_t 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)
{
esp_restart();

View File

@ -76,7 +76,7 @@ public:
uint8_t getChipRevision();
uint32_t getCpuFreqMHz(){ return getCpuFrequencyMhz(); }
uint32_t getCycleCount();
inline uint32_t getCycleCount() __attribute__((always_inline));
const char * getSdkVersion();
void deepSleep(uint32_t time_us);
@ -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;
#endif //ESP_H