Skip to content

Add Watchdog trait#13

Open
williampMSFT wants to merge 3 commits intoOpenDevicePartnership:mainfrom
williampMSFT:user/williamp/watchdog
Open

Add Watchdog trait#13
williampMSFT wants to merge 3 commits intoOpenDevicePartnership:mainfrom
williampMSFT:user/williamp/watchdog

Conversation

@williampMSFT
Copy link
Contributor

This adds a trait to feed a watchdog timer

@williampMSFT williampMSFT marked this pull request as ready for review March 9, 2026 23:42
@williampMSFT williampMSFT requested a review from a team as a code owner March 9, 2026 23:42
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Watchdog trait with an associated Error type and a feed method
  • Added a blanket impl of Watchdog for &mut T where T: Watchdog
  • Registered the new watchdog module as a public module in lib.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.

kurtjd
kurtjd previously approved these changes Mar 10, 2026
jerrysxie
jerrysxie previously approved these changes Mar 11, 2026
@williampMSFT williampMSFT dismissed stale reviews from jerrysxie and kurtjd via e4205d9 March 16, 2026 18:33
@williampMSFT williampMSFT enabled auto-merge (squash) March 16, 2026 18:33
Copy link
Contributor

@jerrysxie jerrysxie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@felipebalbi @williampMSFT Are we aligned on implementing this for MCXA and IMXRT?

@williampMSFT
Copy link
Contributor Author

@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

@jerrysxie jerrysxie requested review from JamesHuard and gjpmsft March 16, 2026 20:19
@jerrysxie jerrysxie disabled auto-merge March 16, 2026 20:19
@jerrysxie jerrysxie requested a review from bramsdell-ms March 16, 2026 20:21
@jerrysxie
Copy link
Contributor

jerrysxie commented Mar 16, 2026

@gjpmsft @JamesHuard @bramsdell-ms @jamesmunns @diondokter Any feedback on this initial implementation of a MCU agnostic watchdog trait?

@jerrysxie jerrysxie added the enhancement New feature or request label Mar 16, 2026
@@ -0,0 +1,13 @@
//! Traits for interactions with a processor's watchdog timer.
/// Feeds an existing watchdog to ensure the processor isn't reset.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want a secondary trait for Watchdogs that are cancelable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

7 participants