Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7fe2812

Browse filesBrowse files
dok-netme-no-dev
authored andcommitted
Inline ESP::getCycleCount() to make it safe to call from ISRs (espressif#3165)
* Inline ESP::getCycleCount() to make it safe to call from ISRs * Attribute IRAM_ATTR ISR-safe function in addition to inlining.
1 parent 9710fed commit 7fe2812
Copy full SHA for 7fe2812

File tree

Expand file treeCollapse file tree

2 files changed

+8
-8
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+8
-8
lines changed

‎cores/esp32/Esp.cpp

Copy file name to clipboardExpand all lines: cores/esp32/Esp.cpp
-7Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,6 @@ void EspClass::deepSleep(uint32_t time_us)
9292
esp_deep_sleep(time_us);
9393
}
9494

95-
uint32_t EspClass::getCycleCount()
96-
{
97-
uint32_t ccount;
98-
__asm__ __volatile__("esync; rsr %0,ccount":"=a" (ccount));
99-
return ccount;
100-
}
101-
10295
void EspClass::restart(void)
10396
{
10497
esp_restart();

‎cores/esp32/Esp.h

Copy file name to clipboardExpand all lines: cores/esp32/Esp.h
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class EspClass
7676

7777
uint8_t getChipRevision();
7878
uint32_t getCpuFreqMHz(){ return getCpuFrequencyMhz(); }
79-
uint32_t getCycleCount();
79+
inline uint32_t getCycleCount() __attribute__((always_inline));
8080
const char * getSdkVersion();
8181

8282
void deepSleep(uint32_t time_us);
@@ -101,6 +101,13 @@ class EspClass
101101

102102
};
103103

104+
uint32_t IRAM_ATTR EspClass::getCycleCount()
105+
{
106+
uint32_t ccount;
107+
__asm__ __volatile__("esync; rsr %0,ccount":"=a" (ccount));
108+
return ccount;
109+
}
110+
104111
extern EspClass ESP;
105112

106113
#endif //ESP_H

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.