@@ -3,7 +3,6 @@ use core::marker;
33/// Raw register type (`u8`, `u16`, `u32`, ...)
44pub trait RawReg :
55 Copy
6- + Default
76 + From < bool >
87 + core:: ops:: BitOr < Output = Self >
98 + core:: ops:: BitAnd < Output = Self >
@@ -14,8 +13,10 @@ pub trait RawReg:
1413{
1514 /// Mask for bits of width `WI`
1615 fn mask < const WI : u8 > ( ) -> Self ;
17- /// Mask for bits of width 1
18- fn one ( ) -> Self ;
16+ /// `0`
17+ const ZERO : Self ;
18+ /// `1`
19+ const ONE : Self ;
1920}
2021
2122macro_rules! raw_reg {
@@ -25,10 +26,8 @@ macro_rules! raw_reg {
2526 fn mask<const WI : u8 >( ) -> Self {
2627 $mask:: <WI >( )
2728 }
28- #[ inline( always) ]
29- fn one( ) -> Self {
30- 1
31- }
29+ const ZERO : Self = 0 ;
30+ const ONE : Self = 1 ;
3231 }
3332 const fn $mask<const WI : u8 >( ) -> $U {
3433 <$U>:: MAX >> ( $size - WI )
@@ -74,10 +73,10 @@ pub trait Writable: RegisterSpec {
7473 type Safety ;
7574
7675 /// 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 ;
76+ const ZERO_TO_MODIFY_FIELDS_BITMAP : Self :: Ux = Self :: Ux :: ZERO ;
7877
7978 /// 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 ;
79+ const ONE_TO_MODIFY_FIELDS_BITMAP : Self :: Ux = Self :: Ux :: ZERO ;
8180}
8281
8382/// Reset value of the register.
@@ -86,7 +85,7 @@ pub trait Writable: RegisterSpec {
8685/// register by using the `reset` method.
8786pub trait Resettable : RegisterSpec {
8887 /// Reset value of the register.
89- const RESET_VALUE : Self :: Ux ;
88+ const RESET_VALUE : Self :: Ux = Self :: Ux :: ZERO ;
9089
9190 /// Reset value of the register.
9291 #[ inline( always) ]
@@ -247,7 +246,10 @@ impl<REG: Writable> W<REG> {
247246 self
248247 }
249248}
250- impl < REG > W < REG > where REG : Writable < Safety = Safe > {
249+ impl < REG > W < REG >
250+ where
251+ REG : Writable < Safety = Safe > ,
252+ {
251253 /// Writes raw bits to the register.
252254 #[ inline( always) ]
253255 pub fn set ( & mut self , bits : REG :: Ux ) -> & mut Self {
@@ -335,7 +337,8 @@ pub struct RangeFrom<const MIN: u64>;
335337pub struct RangeTo < const MAX : u64 > ;
336338
337339/// Write field Proxy
338- pub type FieldWriter < ' a , REG , const WI : u8 , FI = u8 , Safety = Unsafe > = raw:: FieldWriter < ' a , REG , WI , FI , Safety > ;
340+ pub type FieldWriter < ' a , REG , const WI : u8 , FI = u8 , Safety = Unsafe > =
341+ raw:: FieldWriter < ' a , REG , WI , FI , Safety > ;
339342
340343impl < REG , const WI : u8 , FI , Safety > FieldWriter < ' _ , REG , WI , FI , Safety >
341344where
@@ -390,7 +393,8 @@ where
390393 }
391394}
392395
393- impl < ' a , REG , const WI : u8 , FI , const MIN : u64 , const MAX : u64 > FieldWriter < ' a , REG , WI , FI , Range < MIN , MAX > >
396+ impl < ' a , REG , const WI : u8 , FI , const MIN : u64 , const MAX : u64 >
397+ FieldWriter < ' a , REG , WI , FI , Range < MIN , MAX > >
394398where
395399 REG : Writable + RegisterSpec ,
396400 FI : FieldSpec ,
@@ -478,7 +482,7 @@ macro_rules! bit_proxy {
478482 pub const fn width( & self ) -> u8 {
479483 Self :: WIDTH
480484 }
481-
485+
482486 /// Field offset
483487 #[ inline( always) ]
484488 pub const fn offset( & self ) -> u8 {
@@ -488,8 +492,8 @@ macro_rules! bit_proxy {
488492 /// Writes bit to the field
489493 #[ inline( always) ]
490494 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;
495+ self . w. bits &= !( REG :: Ux :: ONE << self . o) ;
496+ self . w. bits |= ( REG :: Ux :: from( value) & REG :: Ux :: ONE ) << self . o;
493497 self . w
494498 }
495499 /// Writes `variant` to the field
@@ -517,13 +521,13 @@ where
517521 /// Sets the field bit
518522 #[ inline( always) ]
519523 pub fn set_bit ( self ) -> & ' a mut W < REG > {
520- self . w . bits |= REG :: Ux :: one ( ) << self . o ;
524+ self . w . bits |= REG :: Ux :: ONE << self . o ;
521525 self . w
522526 }
523527 /// Clears the field bit
524528 #[ inline( always) ]
525529 pub fn clear_bit ( self ) -> & ' a mut W < REG > {
526- self . w . bits &= !( REG :: Ux :: one ( ) << self . o ) ;
530+ self . w . bits &= !( REG :: Ux :: ONE << self . o ) ;
527531 self . w
528532 }
529533}
@@ -536,7 +540,7 @@ where
536540 /// Sets the field bit
537541 #[ inline( always) ]
538542 pub fn set_bit ( self ) -> & ' a mut W < REG > {
539- self . w . bits |= REG :: Ux :: one ( ) << self . o ;
543+ self . w . bits |= REG :: Ux :: ONE << self . o ;
540544 self . w
541545 }
542546}
@@ -549,7 +553,7 @@ where
549553 /// Clears the field bit
550554 #[ inline( always) ]
551555 pub fn clear_bit ( self ) -> & ' a mut W < REG > {
552- self . w . bits &= !( REG :: Ux :: one ( ) << self . o ) ;
556+ self . w . bits &= !( REG :: Ux :: ONE << self . o ) ;
553557 self . w
554558 }
555559}
@@ -562,7 +566,7 @@ where
562566 ///Clears the field bit by passing one
563567 #[ inline( always) ]
564568 pub fn clear_bit_by_one ( self ) -> & ' a mut W < REG > {
565- self . w . bits |= REG :: Ux :: one ( ) << self . o ;
569+ self . w . bits |= REG :: Ux :: ONE << self . o ;
566570 self . w
567571 }
568572}
@@ -575,7 +579,7 @@ where
575579 ///Sets the field bit by passing zero
576580 #[ inline( always) ]
577581 pub fn set_bit_by_zero ( self ) -> & ' a mut W < REG > {
578- self . w . bits &= !( REG :: Ux :: one ( ) << self . o ) ;
582+ self . w . bits &= !( REG :: Ux :: ONE << self . o ) ;
579583 self . w
580584 }
581585}
@@ -588,7 +592,7 @@ where
588592 ///Toggle the field bit by passing one
589593 #[ inline( always) ]
590594 pub fn toggle_bit ( self ) -> & ' a mut W < REG > {
591- self . w . bits |= REG :: Ux :: one ( ) << self . o ;
595+ self . w . bits |= REG :: Ux :: ONE << self . o ;
592596 self . w
593597 }
594598}
@@ -601,7 +605,7 @@ where
601605 ///Toggle the field bit by passing zero
602606 #[ inline( always) ]
603607 pub fn toggle_bit ( self ) -> & ' a mut W < REG > {
604- self . w . bits &= !( REG :: Ux :: one ( ) << self . o ) ;
608+ self . w . bits &= !( REG :: Ux :: ONE << self . o ) ;
605609 self . w
606610 }
607611}
0 commit comments