Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add steal() for each peripheral. #717

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
- Fix dangling implicit derives
- Fix escaping <> and & characters in doc attributes
- Add `interrupt_link_section` config parameter for controlling the `#[link_section = "..."]` attribute of `__INTERRUPTS`
- Add `steal()` for each peripheral

## [v0.28.0] - 2022-12-25

Expand Down
10 changes: 10 additions & 0 deletions src/generate/peripheral.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
pub const fn ptr() -> *const #base::RegisterBlock {
Self::PTR
}

///Steal an instance of this peripheral
pub unsafe fn steal(&self) -> Self {
Self { _marker: PhantomData }
}
}

#feature_attribute_n
Expand Down Expand Up @@ -150,6 +155,11 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
pub const fn ptr() -> *const #base::RegisterBlock {
Self::PTR
}

///Steal an instance of this peripheral
pub unsafe fn steal(&self) -> Self {
Self { _marker: PhantomData }
}
}

#feature_attribute
Expand Down