Skip to content

Commit

Permalink
optim
Browse files Browse the repository at this point in the history
  • Loading branch information
burrbull committed Oct 19, 2023
1 parent d021974 commit 8c512bb
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions src/generate/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ pub mod raw {
FI: FieldSpec,
{
pub(crate) w: &'a mut W<REG>,
pub(crate) offset: u8,
pub(crate) o: u8,
_field: marker::PhantomData<(FI, Safety)>,
}

Expand All @@ -322,10 +322,10 @@ pub mod raw {
/// Creates a new instance of the writer
#[allow(unused)]
#[inline(always)]
pub(crate) fn new(w: &'a mut W<REG>, offset: u8) -> Self {
pub(crate) fn new(w: &'a mut W<REG>, o: u8) -> Self {
Self {
w,
offset,
o,
_field: marker::PhantomData,
}
}
Expand All @@ -337,7 +337,7 @@ pub mod raw {
bool: From<FI>,
{
pub(crate) w: &'a mut W<REG>,
pub(crate) offset: u8,
pub(crate) o: u8,
_field: marker::PhantomData<(FI, M)>,
}

Expand All @@ -349,10 +349,10 @@ pub mod raw {
/// Creates a new instance of the writer
#[allow(unused)]
#[inline(always)]
pub(crate) fn new(w: &'a mut W<REG>, offset: u8) -> Self {
pub(crate) fn new(w: &'a mut W<REG>, o: u8) -> Self {
Self {
w,
offset,
o,
_field: marker::PhantomData,
}
}
Expand Down Expand Up @@ -435,12 +435,12 @@ impl<FI> BitReader<FI> {
}
/// Returns `true` if the bit is clear (0).
#[inline(always)]
pub fn bit_is_clear(&self) -> bool {
pub const fn bit_is_clear(&self) -> bool {
!self.bit()
}
/// Returns `true` if the bit is set (1).
#[inline(always)]
pub fn bit_is_set(&self) -> bool {
pub const fn bit_is_set(&self) -> bool {
self.bit()
}
}
Expand Down Expand Up @@ -510,8 +510,8 @@ macro_rules! impl_bit_proxy {
/// Writes bit to the field
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W<REG> {
self.w.bits &= !(REG::Ux::one() << self.offset);
self.w.bits |= (REG::Ux::from(value) & REG::Ux::one()) << self.offset;
self.w.bits &= !(REG::Ux::one() << self.o);
self.w.bits |= (REG::Ux::from(value) & REG::Ux::one()) << self.o;
self.w
}
/// Writes `variant` to the field
Expand Down Expand Up @@ -544,8 +544,8 @@ where
/// Passing incorrect value can cause undefined behaviour. See reference manual
#[inline(always)]
pub unsafe fn bits(self, value: FI::Ux) -> &'a mut W<REG> {
self.w.bits &= !(REG::Ux::mask::<WI>() << self.offset);
self.w.bits |= (REG::Ux::from(value) & REG::Ux::mask::<WI>()) << self.offset;
self.w.bits &= !(REG::Ux::mask::<WI>() << self.o);
self.w.bits |= (REG::Ux::from(value) & REG::Ux::mask::<WI>()) << self.o;
self.w
}
/// Writes `variant` to the field
Expand All @@ -564,8 +564,8 @@ where
/// Writes raw bits to the field
#[inline(always)]
pub fn bits(self, value: FI::Ux) -> &'a mut W<REG> {
self.w.bits &= !(REG::Ux::mask::<WI>() << self.offset);
self.w.bits |= (REG::Ux::from(value) & REG::Ux::mask::<WI>()) << self.offset;
self.w.bits &= !(REG::Ux::mask::<WI>() << self.o);
self.w.bits |= (REG::Ux::from(value) & REG::Ux::mask::<WI>()) << self.o;
self.w
}
/// Writes `variant` to the field
Expand All @@ -583,13 +583,13 @@ where
/// Sets the field bit
#[inline(always)]
pub fn set_bit(self) -> &'a mut W<REG> {
self.w.bits |= REG::Ux::one() << self.offset;
self.w.bits |= REG::Ux::one() << self.o;
self.w
}
/// Clears the field bit
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W<REG> {
self.w.bits &= !(REG::Ux::one() << self.offset);
self.w.bits &= !(REG::Ux::one() << self.o);
self.w
}
}
Expand All @@ -602,7 +602,7 @@ where
/// Sets the field bit
#[inline(always)]
pub fn set_bit(self) -> &'a mut W<REG> {
self.w.bits |= REG::Ux::one() << self.offset;
self.w.bits |= REG::Ux::one() << self.o;
self.w
}
}
Expand All @@ -615,7 +615,7 @@ where
/// Clears the field bit
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W<REG> {
self.w.bits &= !(REG::Ux::one() << self.offset);
self.w.bits &= !(REG::Ux::one() << self.o);
self.w
}
}
Expand All @@ -628,7 +628,7 @@ where
///Clears the field bit by passing one
#[inline(always)]
pub fn clear_bit_by_one(self) -> &'a mut W<REG> {
self.w.bits |= REG::Ux::one() << self.offset;
self.w.bits |= REG::Ux::one() << self.o;
self.w
}
}
Expand All @@ -641,7 +641,7 @@ where
///Sets the field bit by passing zero
#[inline(always)]
pub fn set_bit_by_zero(self) -> &'a mut W<REG> {
self.w.bits &= !(REG::Ux::one() << self.offset);
self.w.bits &= !(REG::Ux::one() << self.o);
self.w
}
}
Expand All @@ -654,7 +654,7 @@ where
///Toggle the field bit by passing one
#[inline(always)]
pub fn toggle_bit(self) -> &'a mut W<REG> {
self.w.bits |= REG::Ux::one() << self.offset;
self.w.bits |= REG::Ux::one() << self.o;
self.w
}
}
Expand All @@ -667,7 +667,7 @@ where
///Toggle the field bit by passing zero
#[inline(always)]
pub fn toggle_bit(self) -> &'a mut W<REG> {
self.w.bits &= !(REG::Ux::one() << self.offset);
self.w.bits &= !(REG::Ux::one() << self.o);
self.w
}
}

0 comments on commit 8c512bb

Please sign in to comment.