@@ -457,18 +457,50 @@ impl<'a, REG, const WI: u8, const OF: u8, FI> FieldWriter<'a, REG, WI, OF, FI>
457457where
458458 REG : Writable + RegisterSpec ,
459459 FI : FieldSpec ,
460+ REG :: Ux : From < FI :: Ux > ,
460461{
461462 /// Field width
462463 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+ }
463481}
464482
465483impl < ' a , REG , const WI : u8 , const OF : u8 , FI > FieldWriterSafe < ' a , REG , WI , OF , FI >
466484where
467485 REG : Writable + RegisterSpec ,
468486 FI : FieldSpec ,
487+ REG :: Ux : From < FI :: Ux > ,
469488{
470489 /// Field width
471490 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+ }
472504}
473505
474506macro_rules! bit_proxy {
@@ -486,17 +518,7 @@ macro_rules! bit_proxy {
486518 {
487519 /// Field width
488520 pub const WIDTH : u8 = 1 ;
489- }
490- } ;
491- }
492521
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- {
500522 /// Writes bit to the field
501523 #[ inline( always) ]
502524 pub fn bit( self , value: bool ) -> & ' a mut W <REG > {
@@ -521,57 +543,6 @@ bit_proxy!(BitWriter0S, Bit0S);
521543bit_proxy ! ( BitWriter1T , Bit1T ) ;
522544bit_proxy ! ( BitWriter0T , Bit0T ) ;
523545
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-
575546impl < ' a , REG , const OF : u8 , FI > BitWriter < ' a , REG , OF , FI >
576547where
577548 REG : Writable + RegisterSpec ,
0 commit comments