Watchdog
A hardware watchdog resets the MCU when the firmware stops feeding it in time, recovering the keyboard from a hang without a physical unplug. RMK feeds the watchdog from a dedicated Embassy task.
Because all Runnable tasks are joined cooperatively, a tight-loop stall in any
sibling task (for instance: matrix scan, USB, BLE) blocks the watchdog task from
feeding, so the timeout expires and the hardware resets the MCU.
The watchdog feature is enabled by default, no user configuration is
required.
Supported chips: RP2040, nRF52, ESP32 (see
rmk/src/watchdog).
STM32 has no automatic watchdog codegen.
How it works
WatchdogFeedis a small trait each chip implements to feed its hardware timer.WatchdogRunner<W>wraps aWatchdogFeedand callsfeed()on a fixed interval.rmk-macrogenerates chip-specific init code and joins awatchdog_runner.run()task alongside the keyboard and matrix tasks.- Each chip module provides a
default_runner()with a timeout/feed interval pair:
Adding support for other chips
WatchdogFeed and WatchdogRunner are public, so downstream consumers
using the Rust API aren't limited to the chips rmk-macro generates code
for. Implement WatchdogFeed for your chip's watchdog peripheral, build a
WatchdogRunner around it, and join its .run() alongside your other
tasks.