@@ -49,7 +49,6 @@ impl<RB, const A: usize> core::ops::Deref for Periph<RB, A> {
4949/// Raw register type (`u8`, `u16`, `u32`, ...)
5050pub trait RawReg :
5151 Copy
52- + Default
5352 + From < bool >
5453 + core:: ops:: BitOr < Output = Self >
5554 + core:: ops:: BitAnd < Output = Self >
@@ -60,8 +59,10 @@ pub trait RawReg:
6059{
6160 /// Mask for bits of width `WI`
6261 fn mask < const WI : u8 > ( ) -> Self ;
63- /// Mask for bits of width 1
64- fn one ( ) -> Self ;
62+ /// `0`
63+ const ZERO : Self ;
64+ /// `1`
65+ const ONE : Self ;
6566}
6667
6768macro_rules! raw_reg {
@@ -71,10 +72,8 @@ macro_rules! raw_reg {
7172 fn mask<const WI : u8 >( ) -> Self {
7273 $mask:: <WI >( )
7374 }
74- #[ inline( always) ]
75- fn one( ) -> Self {
76- 1
77- }
75+ const ZERO : Self = 0 ;
76+ const ONE : Self = 1 ;
7877 }
7978 const fn $mask<const WI : u8 >( ) -> $U {
8079 <$U>:: MAX >> ( $size - WI )
@@ -120,10 +119,10 @@ pub trait Writable: RegisterSpec {
120119 type Safety ;
121120
122121 /// Specifies the register bits that are not changed if you pass `1` and are changed if you pass `0`
123- const ZERO_TO_MODIFY_FIELDS_BITMAP : Self :: Ux ;
122+ const ZERO_TO_MODIFY_FIELDS_BITMAP : Self :: Ux = Self :: Ux :: ZERO ;
124123
125124 /// Specifies the register bits that are not changed if you pass `0` and are changed if you pass `1`
126- const ONE_TO_MODIFY_FIELDS_BITMAP : Self :: Ux ;
125+ const ONE_TO_MODIFY_FIELDS_BITMAP : Self :: Ux = Self :: Ux :: ZERO ;
127126}
128127
129128/// Reset value of the register.
@@ -132,7 +131,7 @@ pub trait Writable: RegisterSpec {
132131/// register by using the `reset` method.
133132pub trait Resettable : RegisterSpec {
134133 /// Reset value of the register.
135- const RESET_VALUE : Self :: Ux ;
134+ const RESET_VALUE : Self :: Ux = Self :: Ux :: ZERO ;
136135
137136 /// Reset value of the register.
138137 #[ inline( always) ]
@@ -539,8 +538,8 @@ macro_rules! bit_proxy {
539538 /// Writes bit to the field
540539 #[ inline( always) ]
541540 pub fn bit( self , value: bool ) -> & ' a mut W <REG > {
542- self . w. bits &= !( REG :: Ux :: one ( ) << self . o) ;
543- self . w. bits |= ( REG :: Ux :: from( value) & REG :: Ux :: one ( ) ) << self . o;
541+ self . w. bits &= !( REG :: Ux :: ONE << self . o) ;
542+ self . w. bits |= ( REG :: Ux :: from( value) & REG :: Ux :: ONE ) << self . o;
544543 self . w
545544 }
546545 /// Writes `variant` to the field
@@ -568,13 +567,13 @@ where
568567 /// Sets the field bit
569568 #[ inline( always) ]
570569 pub fn set_bit ( self ) -> & ' a mut W < REG > {
571- self . w . bits |= REG :: Ux :: one ( ) << self . o ;
570+ self . w . bits |= REG :: Ux :: ONE << self . o ;
572571 self . w
573572 }
574573 /// Clears the field bit
575574 #[ inline( always) ]
576575 pub fn clear_bit ( self ) -> & ' a mut W < REG > {
577- self . w . bits &= !( REG :: Ux :: one ( ) << self . o ) ;
576+ self . w . bits &= !( REG :: Ux :: ONE << self . o ) ;
578577 self . w
579578 }
580579}
@@ -587,7 +586,7 @@ where
587586 /// Sets the field bit
588587 #[ inline( always) ]
589588 pub fn set_bit ( self ) -> & ' a mut W < REG > {
590- self . w . bits |= REG :: Ux :: one ( ) << self . o ;
589+ self . w . bits |= REG :: Ux :: ONE << self . o ;
591590 self . w
592591 }
593592}
@@ -600,7 +599,7 @@ where
600599 /// Clears the field bit
601600 #[ inline( always) ]
602601 pub fn clear_bit ( self ) -> & ' a mut W < REG > {
603- self . w . bits &= !( REG :: Ux :: one ( ) << self . o ) ;
602+ self . w . bits &= !( REG :: Ux :: ONE << self . o ) ;
604603 self . w
605604 }
606605}
@@ -613,7 +612,7 @@ where
613612 ///Clears the field bit by passing one
614613 #[ inline( always) ]
615614 pub fn clear_bit_by_one ( self ) -> & ' a mut W < REG > {
616- self . w . bits |= REG :: Ux :: one ( ) << self . o ;
615+ self . w . bits |= REG :: Ux :: ONE << self . o ;
617616 self . w
618617 }
619618}
@@ -626,7 +625,7 @@ where
626625 ///Sets the field bit by passing zero
627626 #[ inline( always) ]
628627 pub fn set_bit_by_zero ( self ) -> & ' a mut W < REG > {
629- self . w . bits &= !( REG :: Ux :: one ( ) << self . o ) ;
628+ self . w . bits &= !( REG :: Ux :: ONE << self . o ) ;
630629 self . w
631630 }
632631}
@@ -639,7 +638,7 @@ where
639638 ///Toggle the field bit by passing one
640639 #[ inline( always) ]
641640 pub fn toggle_bit ( self ) -> & ' a mut W < REG > {
642- self . w . bits |= REG :: Ux :: one ( ) << self . o ;
641+ self . w . bits |= REG :: Ux :: ONE << self . o ;
643642 self . w
644643 }
645644}
@@ -652,7 +651,7 @@ where
652651 ///Toggle the field bit by passing zero
653652 #[ inline( always) ]
654653 pub fn toggle_bit ( self ) -> & ' a mut W < REG > {
655- self . w . bits &= !( REG :: Ux :: one ( ) << self . o ) ;
654+ self . w . bits &= !( REG :: Ux :: ONE << self . o ) ;
656655 self . w
657656 }
658657}
0 commit comments