@@ -49,7 +49,6 @@ impl<RB, const A: usize> core::ops::Deref for Periph<RB, A> {
49
49
/// Raw register type (`u8`, `u16`, `u32`, ...)
50
50
pub trait RawReg :
51
51
Copy
52
- + Default
53
52
+ From < bool >
54
53
+ core:: ops:: BitOr < Output = Self >
55
54
+ core:: ops:: BitAnd < Output = Self >
@@ -60,8 +59,10 @@ pub trait RawReg:
60
59
{
61
60
/// Mask for bits of width `WI`
62
61
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 ;
65
66
}
66
67
67
68
macro_rules! raw_reg {
@@ -71,10 +72,8 @@ macro_rules! raw_reg {
71
72
fn mask<const WI : u8 >( ) -> Self {
72
73
$mask:: <WI >( )
73
74
}
74
- #[ inline( always) ]
75
- fn one( ) -> Self {
76
- 1
77
- }
75
+ const ZERO : Self = 0 ;
76
+ const ONE : Self = 1 ;
78
77
}
79
78
const fn $mask<const WI : u8 >( ) -> $U {
80
79
<$U>:: MAX >> ( $size - WI )
@@ -120,10 +119,10 @@ pub trait Writable: RegisterSpec {
120
119
type Safety ;
121
120
122
121
/// 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 ;
124
123
125
124
/// 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 ;
127
126
}
128
127
129
128
/// Reset value of the register.
@@ -132,7 +131,7 @@ pub trait Writable: RegisterSpec {
132
131
/// register by using the `reset` method.
133
132
pub trait Resettable : RegisterSpec {
134
133
/// Reset value of the register.
135
- const RESET_VALUE : Self :: Ux ;
134
+ const RESET_VALUE : Self :: Ux = Self :: Ux :: ZERO ;
136
135
137
136
/// Reset value of the register.
138
137
#[ inline( always) ]
@@ -539,8 +538,8 @@ macro_rules! bit_proxy {
539
538
/// Writes bit to the field
540
539
#[ inline( always) ]
541
540
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;
544
543
self . w
545
544
}
546
545
/// Writes `variant` to the field
@@ -568,13 +567,13 @@ where
568
567
/// Sets the field bit
569
568
#[ inline( always) ]
570
569
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 ;
572
571
self . w
573
572
}
574
573
/// Clears the field bit
575
574
#[ inline( always) ]
576
575
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 ) ;
578
577
self . w
579
578
}
580
579
}
@@ -587,7 +586,7 @@ where
587
586
/// Sets the field bit
588
587
#[ inline( always) ]
589
588
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 ;
591
590
self . w
592
591
}
593
592
}
@@ -600,7 +599,7 @@ where
600
599
/// Clears the field bit
601
600
#[ inline( always) ]
602
601
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 ) ;
604
603
self . w
605
604
}
606
605
}
@@ -613,7 +612,7 @@ where
613
612
///Clears the field bit by passing one
614
613
#[ inline( always) ]
615
614
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 ;
617
616
self . w
618
617
}
619
618
}
@@ -626,7 +625,7 @@ where
626
625
///Sets the field bit by passing zero
627
626
#[ inline( always) ]
628
627
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 ) ;
630
629
self . w
631
630
}
632
631
}
@@ -639,7 +638,7 @@ where
639
638
///Toggle the field bit by passing one
640
639
#[ inline( always) ]
641
640
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 ;
643
642
self . w
644
643
}
645
644
}
@@ -652,7 +651,7 @@ where
652
651
///Toggle the field bit by passing zero
653
652
#[ inline( always) ]
654
653
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 ) ;
656
655
self . w
657
656
}
658
657
}
0 commit comments