Skip to content

Commit 83175e5

Browse files
author
Jorge Aparicio
committed
also update the write method of write-only registers
1 parent 028a95b commit 83175e5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,12 @@ pub fn gen_register(cx: &ExtCtxt, r: &Register, d: &Defaults) -> Vec<P<Item>> {
186186

187187
items.push(quote_item!(cx,
188188
impl $name {
189-
pub fn write(&self, value: $name_w) {
190-
self.register.write(value.bits);
189+
pub fn write<F>(&self, f: F)
190+
where F: FnOnce(&mut $name_w) -> &mut $name_w,
191+
{
192+
let mut w = $name_w::reset_value();
193+
f(&mut w);
194+
self.register.write(w.bits);
191195
}
192196
})
193197
.unwrap());

0 commit comments

Comments
 (0)