Conversation
|
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? |
|
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? |
|
do we have a branch for breaking changes? drafted until it is decided how to continue.. |
|
I think the current CI failure is fixed by #653 |
a64de05 to
1992346
Compare
There was a problem hiding this comment.
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
NVICmethods to acceptcortex_m_types::InterruptNumberinstead ofcortex_m::interrupt::InterruptNumber. - Deprecate
cortex_m::interrupt::InterruptNumberand provide a blanket impl forcortex_m_types::InterruptNumber. - Add a new dependency on the in-repo
cortex-m-typescrate.
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.
| 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" } |
There was a problem hiding this comment.
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.
| cortex-m-types = { path = "../cortex-m-types", version = "0.1" } | |
| cortex-m-types = { path = "../cortex-m-types", version = "=0.1.0" } |
There was a problem hiding this comment.
wouldn't it make more sense to allow the widest compatible version range for this re-exported dependency?
168018f to
e827f54
Compare
The InterruptNumber blanket impl for
cortex_m_types::InterruptNumberis not compatible with the one for all types implementing bare_metal::Nr . removing the other blanket impl is probably a breaking change? :/