* Demonstration of a simple delegate callback for the hardware timer. * Note that a callback function is faster, but as we're doing printing, etc. * this has to be executed in task context. */
| 38 | * this has to be executed in task context. |
| 39 | */ |
| 40 | void hwTimerDelegate(uint32_t count) |
| 41 | { |
| 42 | static unsigned lastCount; |
| 43 | auto diff = count - lastCount; |
| 44 | |
| 45 | static ElapseTimer timer; |
| 46 | auto elapsed = timer.elapsedTime(); |
| 47 | |
| 48 | Serial << _F("count = ") << count << _F(", hwTimerCount = ") << hwTimerCount << _F(", av. interval = ") |
| 49 | << (diff ? (elapsed / diff) : 0) << _F(", maxTasks = ") << System.getMaxTaskCount() << _F(", CPU usage = ") |
| 50 | << cpuUsage.getUtilisation() / 100.0 << '%' << endl; |
| 51 | |
| 52 | cpuUsage.reset(); |
| 53 | |
| 54 | lastCount = count; |
| 55 | timer.start(); |
| 56 | |
| 57 | #ifdef ARCH_ESP32 |
| 58 | /* |
| 59 | * The task queue gets hammered very hard, with no idle time. |
| 60 | * We need to occasionally reset the watchdog timer just to let the system know everything's OK. |
| 61 | */ |
| 62 | WDT.alive(); |
| 63 | #endif |
| 64 | } |
| 65 | |
| 66 | void IRAM_ATTR hwTimerCallback() |
| 67 | { |
nothing calls this directly
no test coverage detected