rust-embedded / rust-embedded/cortex-m
Clarify / Document / Redesign the `Peripherals::{take, steal}` API
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1k
- Forks
- 202
- Avg merge
- 6d 2h
- Merged PRs (30d)
- 2
Description
In https://github.com/rust-embedded/cortex-m/pull/169, I wanted to add a function SCB::steal that unsafely obtains an instance of the SCB peripheral. While this API isn't really necessary since Peripherals::steal().SCB does the same, it is slightly more convenient.
One issue that came up was that Peripherals::steal() is not documented to have any relationship with Peripherals::take(). In reality, calling steal() will cause take() to return None, and this is relied on by RTFM for soundness! We definitely need to document this, but it might also be useful to have an unsafe steal()-like API that does not affect the "taken flag" at all (this is what my SCB::steal() would've been, for example).
Another possible improvement on this API would be to move it to a trait, which could help with https://github.com/rust-embedded/cortex-m-rt/issues/180. If we had that, we could have cortex-m-rt steal and pass arbitrary implementors of that trait to the #[entry] point of the app, moving one nice pattern enabled by RTFM to the non-RTFM embedded world.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the Peripherals::take() and Peripherals::steal() APIs, then review pull request #169 and the linked cortex-m-rt issue #180. Determine whether the project wants documentation, a separate SCB::steal-style API, or a trait-based redesign; done requires an agreed direction and corresponding documented behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- embedded-iot
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100