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:
parent
9710fedaf0
commit
7fe2812f7f
@ -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:
|
|||||||
|
|
||||||
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:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user