Skip to content

Commit a504b64

Browse files
committed
Add a .reset() method as a short-hand for .write(|w| w).
This is only done for Access::ReadWrite because writing the reset value to write-only registers does not seem like it has any potential use at all. Fixes #19.
1 parent fa5868a commit a504b64

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/generate.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,18 @@ pub fn register(
518518
);
519519
}
520520

521+
if access == Access::ReadWrite {
522+
reg_impl_items.push(
523+
quote! {
524+
/// Writes the reset value to the register
525+
#[inline(always)]
526+
pub fn reset(&self) {
527+
self.write(|w| w)
528+
}
529+
}
530+
)
531+
}
532+
521533
mod_items.push(
522534
quote! {
523535
impl super::#name_pc {

0 commit comments

Comments
 (0)