Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a new Watchdog trait to the embedded-mcu-hal crate, providing an abstraction for feeding a processor's watchdog timer to prevent resets. It includes a blanket implementation for &mut T references.
Changes:
- Added a new
Watchdogtrait with an associatedErrortype and afeedmethod - Added a blanket impl of
Watchdogfor&mut TwhereT: Watchdog - Registered the new
watchdogmodule as a public module inlib.rs
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
embedded-mcu-hal/src/watchdog.rs |
New file defining the Watchdog trait with a feed method and a blanket impl for &mut T |
embedded-mcu-hal/src/lib.rs |
Adds pub mod watchdog; to expose the new module |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
jerrysxie
left a comment
There was a problem hiding this comment.
@felipebalbi @williampMSFT Are we aligned on implementing this for MCXA and IMXRT?
I think so, yeah. There are a couple catches, though - we need to publish this crate to crates.io with semver versions, and we need to hide the implementation and linkage to embedded-mcu on the MCXA HAL behind a feature flag |
|
@gjpmsft @JamesHuard @bramsdell-ms @jamesmunns @diondokter Any feedback on this initial implementation of a MCU agnostic watchdog trait? |
| @@ -0,0 +1,13 @@ | |||
| //! Traits for interactions with a processor's watchdog timer. | |||
| /// Feeds an existing watchdog to ensure the processor isn't reset. | |||
There was a problem hiding this comment.
Do we want a secondary trait for Watchdogs that are cancelable?
There was a problem hiding this comment.
Yeah, I thought about this a bit but I think right now we're targeting embassy-imxrt and embassy-mcxa, and I know that at least the imxrt board doesn't support cancellation of watchdogs; haven't looked at the sheet for mcxa yet, though.
I figured if we need to publish to crates.io, it's a breaking change to get it wrong and need to modify the trait, but adding a new 'CancelableWatchdog : Watchdog' trait is just a minor version, so I thought we might defer that until we have a hardware platform that actually has cancellation support to implement against.
This adds a trait to feed a watchdog timer