@@ -485,10 +485,11 @@ pub fn fields(
485485 unsafety = None ;
486486 }
487487
488+ let mut base_pc_w = None ;
488489 if Some ( evs) != evs_r. as_ref ( ) {
489490 pc_w = & f. pc_w ;
490491
491- base. as_ref ( ) . map ( |base| {
492+ base_pc_w = base. as_ref ( ) . map ( |base| {
492493 let pc = base. field . to_sanitized_upper_case ( ) ;
493494 let base_pc_w = Ident :: from ( & * format ! ( "{}_AW" , pc) ) ;
494495 derive_from_base ( mod_items, & base, & pc_w, & base_pc_w, f. name )
@@ -515,13 +516,23 @@ pub fn fields(
515516 let sc = & v. sc ;
516517
517518 let doc = util:: escape_brackets ( util:: respace ( & v. doc ) . as_ref ( ) ) ;
519+ if let Some ( enum_) = base_pc_w. as_ref ( ) {
520+ proxy_items. push ( quote ! {
521+ #[ doc = #doc]
522+ #[ inline( always) ]
523+ pub fn #sc( self ) -> & ' a mut W {
524+ self . variant( #enum_:: #pc)
525+ }
526+ } ) ;
527+ } else {
518528 proxy_items. push ( quote ! {
519529 #[ doc = #doc]
520530 #[ inline( always) ]
521531 pub fn #sc( self ) -> & ' a mut W {
522532 self . variant( #pc_w:: #pc)
523533 }
524534 } ) ;
535+ }
525536 }
526537 }
527538
@@ -685,7 +696,7 @@ fn add_from_variants(mod_items: &mut Vec<Tokens>, variants: &Vec<Variant>, pc: &
685696 } ) ;
686697}
687698
688- fn derive_from_base ( mod_items : & mut Vec < Tokens > , base : & Base , pc : & Ident , base_pc : & Ident , fname : & str ) {
699+ fn derive_from_base ( mod_items : & mut Vec < Tokens > , base : & Base , pc : & Ident , base_pc : & Ident , fname : & str ) -> quote :: Tokens {
689700 let desc = format ! ( "Possible values of the field `{}`" , fname, ) ;
690701
691702 if let ( Some ( peripheral) , Some ( register) ) = ( & base. peripheral , & base. register ) {
@@ -699,6 +710,10 @@ fn derive_from_base(mod_items: &mut Vec<Tokens>, base: &Base, pc: &Ident, base_p
699710 pub type #pc =
700711 crate :: #pmod_:: #rmod_:: #base_pc;
701712 } ) ;
713+
714+ quote ! {
715+ crate :: #pmod_:: #rmod_:: #base_pc
716+ }
702717 } else if let Some ( register) = & base. register {
703718 let mod_ = register. to_sanitized_snake_case ( ) ;
704719 let mod_ = Ident :: from ( & * mod_) ;
@@ -708,11 +723,19 @@ fn derive_from_base(mod_items: &mut Vec<Tokens>, base: &Base, pc: &Ident, base_p
708723 pub type #pc =
709724 super :: #mod_:: #base_pc;
710725 } ) ;
726+
727+ quote ! {
728+ super :: #mod_:: #base_pc
729+ }
711730 } else {
712731 mod_items. push ( quote ! {
713732 #[ doc = #desc]
714733 pub type #pc = #base_pc;
715734 } ) ;
735+
736+ quote ! {
737+ #base_pc
738+ }
716739 }
717740}
718741
0 commit comments