First-init helper, used by ScopedWatchdog's constructor. Runs only once per process. Single-threaded loop() is the canonical caller — no atomics are needed for the guard byte on supported MCUs.
| 127 | // per process. Single-threaded loop() is the canonical caller — no atomics |
| 128 | // are needed for the guard byte on supported MCUs. |
| 129 | inline void scopedWatchdogFirstInit(fl::u32 timeout_ms) FL_NOEXCEPT { |
| 130 | Watchdog& wdt = Watchdog::instance(); |
| 131 | wdt.begin(timeout_ms); |
| 132 | |
| 133 | ResetInfo info = wdt.lastResetInfo(); |
| 134 | if (info.cause == ResetCause::WATCHDOG || |
| 135 | info.cause == ResetCause::PANIC || |
| 136 | info.cause == ResetCause::LOCKUP) { |
| 137 | char buf[128]; |
| 138 | fl::size n = info.describe(fl::span<char>(buf, sizeof(buf)), /*verbose=*/true); |
| 139 | scopedWatchdogPrintLine(fl::string_view("[FastLED.watchdog] recovered from:")); |
| 140 | scopedWatchdogPrintLine(fl::string_view(buf, n)); |
| 141 | |
| 142 | if (wdt.hasCrashReport()) { |
| 143 | // Hook for Tier 2 platforms. Future revision: also emit a |
| 144 | // multi-line CrashReport::describe() result here. For now the |
| 145 | // bare cause + raw register is the documented contract. |
| 146 | } |
| 147 | scopedWatchdogPause3s(); |
| 148 | } |
| 149 | scopedWatchdogPrintLine(fl::string_view("[FastLED.watchdog] armed via FL_WATCHDOG_AUTO()")); |
| 150 | } |
| 151 | |
| 152 | } // namespace platforms |
| 153 |
no test coverage detected