MCPcopy Create free account
hub / github.com/SmingHub/Sming / hwTimerDelegate

Function hwTimerDelegate

samples/Basic_Tasks/app/application.cpp:40–64  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

38 * this has to be executed in task context.
39 */
40void 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
66void IRAM_ATTR hwTimerCallback()
67{

Callers

nothing calls this directly

Calls 6

elapsedTimeMethod · 0.80
getMaxTaskCountMethod · 0.80
getUtilisationMethod · 0.80
aliveMethod · 0.80
resetMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected