11use core:: marker;
2+ use num_traits:: { ConstOne , ConstZero } ;
23
34/// Raw register type (`u8`, `u16`, `u32`, ...)
45pub trait RawReg :
56 Copy
6- + Default
7+ + ConstOne
8+ + ConstZero
79 + From < bool >
810 + core:: ops:: BitOr < Output = Self >
911 + core:: ops:: BitAnd < Output = Self >
@@ -14,8 +16,6 @@ pub trait RawReg:
1416{
1517 /// Mask for bits of width `WI`
1618 fn mask < const WI : u8 > ( ) -> Self ;
17- /// Mask for bits of width 1
18- fn one ( ) -> Self ;
1919}
2020
2121macro_rules! raw_reg {
@@ -25,10 +25,6 @@ macro_rules! raw_reg {
2525 fn mask<const WI : u8 >( ) -> Self {
2626 $mask:: <WI >( )
2727 }
28- #[ inline( always) ]
29- fn one( ) -> Self {
30- 1
31- }
3228 }
3329 const fn $mask<const WI : u8 >( ) -> $U {
3430 <$U>:: MAX >> ( $size - WI )
@@ -74,10 +70,10 @@ pub trait Writable: RegisterSpec {
7470 type Safety ;
7571
7672 /// Specifies the register bits that are not changed if you pass `1` and are changed if you pass `0`
77- const ZERO_TO_MODIFY_FIELDS_BITMAP : Self :: Ux ;
73+ const ZERO_TO_MODIFY_FIELDS_BITMAP : Self :: Ux = Self :: Ux :: ZERO ;
7874
7975 /// Specifies the register bits that are not changed if you pass `0` and are changed if you pass `1`
80- const ONE_TO_MODIFY_FIELDS_BITMAP : Self :: Ux ;
76+ const ONE_TO_MODIFY_FIELDS_BITMAP : Self :: Ux = Self :: Ux :: ZERO ;
8177}
8278
8379/// Reset value of the register.
@@ -86,7 +82,7 @@ pub trait Writable: RegisterSpec {
8682/// register by using the `reset` method.
8783pub trait Resettable : RegisterSpec {
8884 /// Reset value of the register.
89- const RESET_VALUE : Self :: Ux ;
85+ const RESET_VALUE : Self :: Ux = Self :: Ux :: ZERO ;
9086
9187 /// Reset value of the register.
9288 #[ inline( always) ]
@@ -247,7 +243,10 @@ impl<REG: Writable> W<REG> {
247243 self
248244 }
249245}
250- impl < REG > W < REG > where REG : Writable < Safety = Safe > {
246+ impl < REG > W < REG >
247+ where
248+ REG : Writable < Safety = Safe > ,
249+ {
251250 /// Writes raw bits to the register.
252251 #[ inline( always) ]
253252 pub fn set ( & mut self , bits : REG :: Ux ) -> & mut Self {
@@ -335,7 +334,8 @@ pub struct RangeFrom<const MIN: u64>;
335334pub struct RangeTo < const MAX : u64 > ;
336335
337336/// Write field Proxy
338- pub type FieldWriter < ' a , REG , const WI : u8 , FI = u8 , Safety = Unsafe > = raw:: FieldWriter < ' a , REG , WI , FI , Safety > ;
337+ pub type FieldWriter < ' a , REG , const WI : u8 , FI = u8 , Safety = Unsafe > =
338+ raw:: FieldWriter < ' a , REG , WI , FI , Safety > ;
339339
340340impl < ' a , REG , const WI : u8 , FI , Safety > FieldWriter < ' a , REG , WI , FI , Safety >
341341where
@@ -390,7 +390,8 @@ where
390390 }
391391}
392392
393- impl < ' a , REG , const WI : u8 , FI , const MIN : u64 , const MAX : u64 > FieldWriter < ' a , REG , WI , FI , Range < MIN , MAX > >
393+ impl < ' a , REG , const WI : u8 , FI , const MIN : u64 , const MAX : u64 >
394+ FieldWriter < ' a , REG , WI , FI , Range < MIN , MAX > >
394395where
395396 REG : Writable + RegisterSpec ,
396397 FI : FieldSpec ,
@@ -478,7 +479,7 @@ macro_rules! bit_proxy {
478479 pub const fn width( & self ) -> u8 {
479480 Self :: WIDTH
480481 }
481-
482+
482483 /// Field offset
483484 #[ inline( always) ]
484485 pub const fn offset( & self ) -> u8 {
@@ -488,8 +489,8 @@ macro_rules! bit_proxy {
488489 /// Writes bit to the field
489490 #[ inline( always) ]
490491 pub fn bit( self , value: bool ) -> & ' a mut W <REG > {
491- self . w. bits &= !( REG :: Ux :: one ( ) << self . o) ;
492- self . w. bits |= ( REG :: Ux :: from( value) & REG :: Ux :: one ( ) ) << self . o;
492+ self . w. bits &= !( REG :: Ux :: ONE << self . o) ;
493+ self . w. bits |= ( REG :: Ux :: from( value) & REG :: Ux :: ONE ) << self . o;
493494 self . w
494495 }
495496 /// Writes `variant` to the field
@@ -517,13 +518,13 @@ where
517518 /// Sets the field bit
518519 #[ inline( always) ]
519520 pub fn set_bit ( self ) -> & ' a mut W < REG > {
520- self . w . bits |= REG :: Ux :: one ( ) << self . o ;
521+ self . w . bits |= REG :: Ux :: ONE << self . o ;
521522 self . w
522523 }
523524 /// Clears the field bit
524525 #[ inline( always) ]
525526 pub fn clear_bit ( self ) -> & ' a mut W < REG > {
526- self . w . bits &= !( REG :: Ux :: one ( ) << self . o ) ;
527+ self . w . bits &= !( REG :: Ux :: ONE << self . o ) ;
527528 self . w
528529 }
529530}
@@ -536,7 +537,7 @@ where
536537 /// Sets the field bit
537538 #[ inline( always) ]
538539 pub fn set_bit ( self ) -> & ' a mut W < REG > {
539- self . w . bits |= REG :: Ux :: one ( ) << self . o ;
540+ self . w . bits |= REG :: Ux :: ONE << self . o ;
540541 self . w
541542 }
542543}
@@ -549,7 +550,7 @@ where
549550 /// Clears the field bit
550551 #[ inline( always) ]
551552 pub fn clear_bit ( self ) -> & ' a mut W < REG > {
552- self . w . bits &= !( REG :: Ux :: one ( ) << self . o ) ;
553+ self . w . bits &= !( REG :: Ux :: ONE << self . o ) ;
553554 self . w
554555 }
555556}
@@ -562,7 +563,7 @@ where
562563 ///Clears the field bit by passing one
563564 #[ inline( always) ]
564565 pub fn clear_bit_by_one ( self ) -> & ' a mut W < REG > {
565- self . w . bits |= REG :: Ux :: one ( ) << self . o ;
566+ self . w . bits |= REG :: Ux :: ONE << self . o ;
566567 self . w
567568 }
568569}
@@ -575,7 +576,7 @@ where
575576 ///Sets the field bit by passing zero
576577 #[ inline( always) ]
577578 pub fn set_bit_by_zero ( self ) -> & ' a mut W < REG > {
578- self . w . bits &= !( REG :: Ux :: one ( ) << self . o ) ;
579+ self . w . bits &= !( REG :: Ux :: ONE << self . o ) ;
579580 self . w
580581 }
581582}
@@ -588,7 +589,7 @@ where
588589 ///Toggle the field bit by passing one
589590 #[ inline( always) ]
590591 pub fn toggle_bit ( self ) -> & ' a mut W < REG > {
591- self . w . bits |= REG :: Ux :: one ( ) << self . o ;
592+ self . w . bits |= REG :: Ux :: ONE << self . o ;
592593 self . w
593594 }
594595}
@@ -601,7 +602,7 @@ where
601602 ///Toggle the field bit by passing zero
602603 #[ inline( always) ]
603604 pub fn toggle_bit ( self ) -> & ' a mut W < REG > {
604- self . w . bits &= !( REG :: Ux :: one ( ) << self . o ) ;
605+ self . w . bits &= !( REG :: Ux :: ONE << self . o ) ;
605606 self . w
606607 }
607608}
0 commit comments