@@ -3,7 +3,6 @@ use core::marker;
3
3
/// Raw register type (`u8`, `u16`, `u32`, ...)
4
4
pub trait RawReg :
5
5
Copy
6
- + Default
7
6
+ From < bool >
8
7
+ core:: ops:: BitOr < Output = Self >
9
8
+ core:: ops:: BitAnd < Output = Self >
@@ -14,8 +13,10 @@ pub trait RawReg:
14
13
{
15
14
/// Mask for bits of width `WI`
16
15
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 ;
19
20
}
20
21
21
22
macro_rules! raw_reg {
@@ -25,10 +26,8 @@ macro_rules! raw_reg {
25
26
fn mask<const WI : u8 >( ) -> Self {
26
27
$mask:: <WI >( )
27
28
}
28
- #[ inline( always) ]
29
- fn one( ) -> Self {
30
- 1
31
- }
29
+ const ZERO : Self = 0 ;
30
+ const ONE : Self = 1 ;
32
31
}
33
32
const fn $mask<const WI : u8 >( ) -> $U {
34
33
<$U>:: MAX >> ( $size - WI )
@@ -74,10 +73,10 @@ pub trait Writable: RegisterSpec {
74
73
type Safety ;
75
74
76
75
/// 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 ;
78
77
79
78
/// 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 ;
81
80
}
82
81
83
82
/// Reset value of the register.
@@ -86,7 +85,7 @@ pub trait Writable: RegisterSpec {
86
85
/// register by using the `reset` method.
87
86
pub trait Resettable : RegisterSpec {
88
87
/// Reset value of the register.
89
- const RESET_VALUE : Self :: Ux ;
88
+ const RESET_VALUE : Self :: Ux = Self :: Ux :: ZERO ;
90
89
91
90
/// Reset value of the register.
92
91
#[ inline( always) ]
@@ -247,7 +246,10 @@ impl<REG: Writable> W<REG> {
247
246
self
248
247
}
249
248
}
250
- impl < REG > W < REG > where REG : Writable < Safety = Safe > {
249
+ impl < REG > W < REG >
250
+ where
251
+ REG : Writable < Safety = Safe > ,
252
+ {
251
253
/// Writes raw bits to the register.
252
254
#[ inline( always) ]
253
255
pub fn set ( & mut self , bits : REG :: Ux ) -> & mut Self {
@@ -335,7 +337,8 @@ pub struct RangeFrom<const MIN: u64>;
335
337
pub struct RangeTo < const MAX : u64 > ;
336
338
337
339
/// 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 > ;
339
342
340
343
impl < REG , const WI : u8 , FI , Safety > FieldWriter < ' _ , REG , WI , FI , Safety >
341
344
where
@@ -390,7 +393,8 @@ where
390
393
}
391
394
}
392
395
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 > >
394
398
where
395
399
REG : Writable + RegisterSpec ,
396
400
FI : FieldSpec ,
@@ -478,7 +482,7 @@ macro_rules! bit_proxy {
478
482
pub const fn width( & self ) -> u8 {
479
483
Self :: WIDTH
480
484
}
481
-
485
+
482
486
/// Field offset
483
487
#[ inline( always) ]
484
488
pub const fn offset( & self ) -> u8 {
@@ -488,8 +492,8 @@ macro_rules! bit_proxy {
488
492
/// Writes bit to the field
489
493
#[ inline( always) ]
490
494
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;
493
497
self . w
494
498
}
495
499
/// Writes `variant` to the field
@@ -517,13 +521,13 @@ where
517
521
/// Sets the field bit
518
522
#[ inline( always) ]
519
523
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 ;
521
525
self . w
522
526
}
523
527
/// Clears the field bit
524
528
#[ inline( always) ]
525
529
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 ) ;
527
531
self . w
528
532
}
529
533
}
@@ -536,7 +540,7 @@ where
536
540
/// Sets the field bit
537
541
#[ inline( always) ]
538
542
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 ;
540
544
self . w
541
545
}
542
546
}
@@ -549,7 +553,7 @@ where
549
553
/// Clears the field bit
550
554
#[ inline( always) ]
551
555
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 ) ;
553
557
self . w
554
558
}
555
559
}
@@ -562,7 +566,7 @@ where
562
566
///Clears the field bit by passing one
563
567
#[ inline( always) ]
564
568
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 ;
566
570
self . w
567
571
}
568
572
}
@@ -575,7 +579,7 @@ where
575
579
///Sets the field bit by passing zero
576
580
#[ inline( always) ]
577
581
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 ) ;
579
583
self . w
580
584
}
581
585
}
@@ -588,7 +592,7 @@ where
588
592
///Toggle the field bit by passing one
589
593
#[ inline( always) ]
590
594
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 ;
592
596
self . w
593
597
}
594
598
}
@@ -601,7 +605,7 @@ where
601
605
///Toggle the field bit by passing zero
602
606
#[ inline( always) ]
603
607
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 ) ;
605
609
self . w
606
610
}
607
611
}
0 commit comments