Skip to content

Commit 58e10d7

Browse files
committed
set_bits/clear_bits
1 parent 773caae commit 58e10d7

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/generate/generic.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,16 @@ impl<REG: Writable> W<REG> {
291291
self.bits = bits;
292292
self
293293
}
294+
#[inline(always)]
295+
pub unsafe fn set_bits(&mut self, bits: REG::Ux) -> &mut Self {
296+
self.bits |= bits;
297+
self
298+
}
299+
#[inline(always)]
300+
pub unsafe fn clear_bits(&mut self, bits: REG::Ux) -> &mut Self {
301+
self.bits &= !bits;
302+
self
303+
}
294304
}
295305
impl<REG> W<REG>
296306
where
@@ -424,6 +434,18 @@ where
424434
self.w.bits |= (REG::Ux::from(value) & REG::Ux::mask::<WI>()) << self.o;
425435
self.w
426436
}
437+
438+
#[inline(always)]
439+
pub unsafe fn set_bits(self, value: FI::Ux) -> &'a mut W<REG> {
440+
self.w.bits |= (REG::Ux::from(value) & REG::Ux::mask::<WI>()) << self.o;
441+
self.w
442+
}
443+
444+
#[inline(always)]
445+
pub unsafe fn clear_bits(self, value: FI::Ux) -> &'a mut W<REG> {
446+
self.w.bits &= !((REG::Ux::from(value) & REG::Ux::mask::<WI>()) << self.o);
447+
self.w
448+
}
427449
}
428450

429451
impl<'a, REG, const WI: u8, FI> FieldWriter<'a, REG, WI, FI, Safe>

0 commit comments

Comments
 (0)