Skip to content

use cortex-m-types in NVIC#654

Open
robamu wants to merge 1 commit intomasterfrom
use-cortex-m-types-in-nvic
Open

use cortex-m-types in NVIC#654
robamu wants to merge 1 commit intomasterfrom
use-cortex-m-types-in-nvic

Conversation

@robamu
Copy link
Copy Markdown

@robamu robamu commented Apr 26, 2026

The InterruptNumber blanket impl for cortex_m_types::InterruptNumber is not compatible with the one for all types implementing bare_metal::Nr . removing the other blanket impl is probably a breaking change? :/

@adamgreig
Copy link
Copy Markdown
Member

Hah, shame we can't add an impl of bare_metal's Nr to cortex-m-types. Can we keep using cortex-m's old InterruptNumber trait in NVIC, and add an impl of InterruptNumber for anything implementing either bare_metal's Nr or cortex-m-type's InterruptNumber?

@robamu
Copy link
Copy Markdown
Author

robamu commented Apr 26, 2026

maybe, but I do not know how with my current Rust foo. I get conflicting implementation errors when I try do add a blanket impl for both of these types. The fundamental problem probably is that this is a breaking change, right?

At this point I wonder whether we just have to accept some transition pain and move forward with the breaking change. then I have to merge into a different branch. At the very least, PACs will not break anymore in the future, as long as everybody agrees on the same trait crate, right?

@robamu
Copy link
Copy Markdown
Author

robamu commented Apr 26, 2026

do we have a branch for breaking changes? drafted until it is decided how to continue..

@robamu
Copy link
Copy Markdown
Author

robamu commented Apr 26, 2026

I think the current CI failure is fixed by #653

@robamu robamu marked this pull request as draft April 26, 2026 12:37
@robamu robamu marked this pull request as ready for review April 27, 2026 09:20
@robamu robamu force-pushed the use-cortex-m-types-in-nvic branch from a64de05 to 1992346 Compare April 27, 2026 12:03
@robamu robamu requested a review from Copilot April 27, 2026 14:36
Copy link
Copy Markdown

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 updates the cortex-m crate’s NVIC APIs to use the cortex-m-types InterruptNumber trait, and adjusts the legacy cortex_m::interrupt::InterruptNumber to be a deprecated compatibility layer over the new trait.

Changes:

  • Switch NVIC methods to accept cortex_m_types::InterruptNumber instead of cortex_m::interrupt::InterruptNumber.
  • Deprecate cortex_m::interrupt::InterruptNumber and provide a blanket impl for cortex_m_types::InterruptNumber.
  • Add a new dependency on the in-repo cortex-m-types crate.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
cortex-m/src/peripheral/nvic.rs Replaces the interrupt-number trait bound used by NVIC APIs and updates conversions/indexing accordingly.
cortex-m/src/interrupt.rs Deprecates the legacy trait and changes the compatibility blanket impl to target cortex_m_types::InterruptNumber.
cortex-m/Cargo.toml Adds cortex-m-types as a dependency to support the new NVIC/interrupt trait usage.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cortex-m/src/peripheral/nvic.rs
Comment thread cortex-m/src/interrupt.rs
Comment thread cortex-m/Cargo.toml
eh0 = { package = "embedded-hal", version = "0.2.4" }
eh1 = { package = "embedded-hal", version = "1.0.0" }
cortex-m-macros = { path = "macros", version = "=0.1.0" }
cortex-m-types = { path = "../cortex-m-types", version = "0.1" }
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

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

For in-repo path dependencies, this repo already pins some internal crates with an exact version (e.g. cortex-m-macros = { path = ..., version = "=0.1.0" }). Consider pinning cortex-m-types similarly (e.g. =0.1.0) to avoid accidentally publishing with a mismatched semver-compatible but API-incompatible internal version.

Suggested change
cortex-m-types = { path = "../cortex-m-types", version = "0.1" }
cortex-m-types = { path = "../cortex-m-types", version = "=0.1.0" }

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

wouldn't it make more sense to allow the widest compatible version range for this re-exported dependency?

Comment thread cortex-m/src/peripheral/nvic.rs Outdated
@robamu robamu force-pushed the use-cortex-m-types-in-nvic branch from 168018f to e827f54 Compare April 27, 2026 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants