@@ -457,18 +457,50 @@ impl<'a, REG, const WI: u8, const OF: u8, FI> FieldWriter<'a, REG, WI, OF, FI>
457
457
where
458
458
REG : Writable + RegisterSpec ,
459
459
FI : FieldSpec ,
460
+ REG :: Ux : From < FI :: Ux > ,
460
461
{
461
462
/// Field width
462
463
pub const WIDTH : u8 = WI ;
464
+
465
+ /// Writes raw bits to the field
466
+ ///
467
+ /// # Safety
468
+ ///
469
+ /// Passing incorrect value can cause undefined behaviour. See reference manual
470
+ #[ inline( always) ]
471
+ pub unsafe fn bits ( self , value : FI :: Ux ) -> & ' a mut W < REG > {
472
+ self . w . bits &= !( REG :: Ux :: mask :: < WI > ( ) << OF ) ;
473
+ self . w . bits |= ( REG :: Ux :: from ( value) & REG :: Ux :: mask :: < WI > ( ) ) << OF ;
474
+ self . w
475
+ }
476
+ /// Writes `variant` to the field
477
+ #[ inline( always) ]
478
+ pub fn variant ( self , variant : FI ) -> & ' a mut W < REG > {
479
+ unsafe { self . bits ( FI :: Ux :: from ( variant) ) }
480
+ }
463
481
}
464
482
465
483
impl < ' a , REG , const WI : u8 , const OF : u8 , FI > FieldWriterSafe < ' a , REG , WI , OF , FI >
466
484
where
467
485
REG : Writable + RegisterSpec ,
468
486
FI : FieldSpec ,
487
+ REG :: Ux : From < FI :: Ux > ,
469
488
{
470
489
/// Field width
471
490
pub const WIDTH : u8 = WI ;
491
+
492
+ /// Writes raw bits to the field
493
+ #[ inline( always) ]
494
+ pub fn bits ( self , value : FI :: Ux ) -> & ' a mut W < REG > {
495
+ self . w . bits &= !( REG :: Ux :: mask :: < WI > ( ) << OF ) ;
496
+ self . w . bits |= ( REG :: Ux :: from ( value) & REG :: Ux :: mask :: < WI > ( ) ) << OF ;
497
+ self . w
498
+ }
499
+ /// Writes `variant` to the field
500
+ #[ inline( always) ]
501
+ pub fn variant ( self , variant : FI ) -> & ' a mut W < REG > {
502
+ self . bits ( FI :: Ux :: from ( variant) )
503
+ }
472
504
}
473
505
474
506
macro_rules! bit_proxy {
@@ -486,17 +518,7 @@ macro_rules! bit_proxy {
486
518
{
487
519
/// Field width
488
520
pub const WIDTH : u8 = 1 ;
489
- }
490
- } ;
491
- }
492
521
493
- macro_rules! impl_bit_proxy {
494
- ( $writer: ident) => {
495
- impl <' a, REG , const OF : u8 , FI > $writer<' a, REG , OF , FI >
496
- where
497
- REG : Writable + RegisterSpec ,
498
- bool : From <FI >,
499
- {
500
522
/// Writes bit to the field
501
523
#[ inline( always) ]
502
524
pub fn bit( self , value: bool ) -> & ' a mut W <REG > {
@@ -521,57 +543,6 @@ bit_proxy!(BitWriter0S, Bit0S);
521
543
bit_proxy ! ( BitWriter1T , Bit1T ) ;
522
544
bit_proxy ! ( BitWriter0T , Bit0T ) ;
523
545
524
- impl < ' a , REG , const WI : u8 , const OF : u8 , FI > FieldWriter < ' a , REG , WI , OF , FI >
525
- where
526
- REG : Writable + RegisterSpec ,
527
- FI : FieldSpec ,
528
- REG :: Ux : From < FI :: Ux > ,
529
- {
530
- /// Writes raw bits to the field
531
- ///
532
- /// # Safety
533
- ///
534
- /// Passing incorrect value can cause undefined behaviour. See reference manual
535
- #[ inline( always) ]
536
- pub unsafe fn bits ( self , value : FI :: Ux ) -> & ' a mut W < REG > {
537
- self . w . bits &= !( REG :: Ux :: mask :: < WI > ( ) << OF ) ;
538
- self . w . bits |= ( REG :: Ux :: from ( value) & REG :: Ux :: mask :: < WI > ( ) ) << OF ;
539
- self . w
540
- }
541
- /// Writes `variant` to the field
542
- #[ inline( always) ]
543
- pub fn variant ( self , variant : FI ) -> & ' a mut W < REG > {
544
- unsafe { self . bits ( FI :: Ux :: from ( variant) ) }
545
- }
546
- }
547
- impl < ' a , REG , const WI : u8 , const OF : u8 , FI > FieldWriterSafe < ' a , REG , WI , OF , FI >
548
- where
549
- REG : Writable + RegisterSpec ,
550
- FI : FieldSpec ,
551
- REG :: Ux : From < FI :: Ux > ,
552
- {
553
- /// Writes raw bits to the field
554
- #[ inline( always) ]
555
- pub fn bits ( self , value : FI :: Ux ) -> & ' a mut W < REG > {
556
- self . w . bits &= !( REG :: Ux :: mask :: < WI > ( ) << OF ) ;
557
- self . w . bits |= ( REG :: Ux :: from ( value) & REG :: Ux :: mask :: < WI > ( ) ) << OF ;
558
- self . w
559
- }
560
- /// Writes `variant` to the field
561
- #[ inline( always) ]
562
- pub fn variant ( self , variant : FI ) -> & ' a mut W < REG > {
563
- self . bits ( FI :: Ux :: from ( variant) )
564
- }
565
- }
566
-
567
- impl_bit_proxy ! ( BitWriter ) ;
568
- impl_bit_proxy ! ( BitWriter1S ) ;
569
- impl_bit_proxy ! ( BitWriter0C ) ;
570
- impl_bit_proxy ! ( BitWriter1C ) ;
571
- impl_bit_proxy ! ( BitWriter0S ) ;
572
- impl_bit_proxy ! ( BitWriter1T ) ;
573
- impl_bit_proxy ! ( BitWriter0T ) ;
574
-
575
546
impl < ' a , REG , const OF : u8 , FI > BitWriter < ' a , REG , OF , FI >
576
547
where
577
548
REG : Writable + RegisterSpec ,
0 commit comments