@@ -273,7 +273,7 @@ pub fn render_register_mod(
273
273
274
274
mod_items. extend ( w_impl_items) ;
275
275
276
- /*
276
+ /*
277
277
// the writer can be safe if:
278
278
// * there is a single field that covers the entire register
279
279
// * that field can represent all values
@@ -923,7 +923,7 @@ pub fn fields(
923
923
proxy_items. extend ( quote ! {
924
924
#[ doc = #doc]
925
925
#inline
926
- pub fn #sc( self ) -> & ' a mut W {
926
+ pub fn #sc( self ) -> & ' a mut crate :: W < REG > {
927
927
self . variant( #value_write_ty:: #pc)
928
928
}
929
929
} ) ;
@@ -955,9 +955,9 @@ pub fn fields(
955
955
span,
956
956
) ;
957
957
if value_write_ty == "bool" {
958
- quote ! { crate :: #wproxy<' a, #regspec_ident , O > }
958
+ quote ! { crate :: #wproxy<' a, REG , O > }
959
959
} else {
960
- quote ! { crate :: #wproxy<' a, #regspec_ident , O , #value_write_ty> }
960
+ quote ! { crate :: #wproxy<' a, REG , O , #value_write_ty> }
961
961
}
962
962
} else {
963
963
let wproxy = Ident :: new (
@@ -970,22 +970,37 @@ pub fn fields(
970
970
) ;
971
971
let width = & util:: unsuffixed ( width as _ ) ;
972
972
if value_write_ty == "u8" {
973
- quote ! { crate :: #wproxy<' a, #regspec_ident , #width, O > }
973
+ quote ! { crate :: #wproxy<' a, REG , #width, O > }
974
974
} else {
975
- quote ! { crate :: #wproxy<' a, #regspec_ident , #width, O , #value_write_ty> }
975
+ quote ! { crate :: #wproxy<' a, REG , #width, O , #value_write_ty> }
976
976
}
977
977
} ;
978
978
mod_items. extend ( quote ! {
979
979
#[ doc = #field_writer_brief]
980
- pub type #writer_ty<' a, const O : u8 > = #proxy;
980
+ pub type #writer_ty<' a, REG , const O : u8 > = #proxy;
981
981
} ) ;
982
982
}
983
983
984
984
// generate proxy items from collected information
985
985
if !proxy_items. is_empty ( ) {
986
- mod_items. extend ( quote ! {
987
- impl <' a, const O : u8 > #writer_ty<' a, O > {
988
- #proxy_items
986
+ mod_items. extend ( if width == 1 {
987
+ quote ! {
988
+ impl <' a, REG , const O : u8 > #writer_ty<' a, REG , O >
989
+ where
990
+ REG : crate :: Writable + crate :: RegisterSpec ,
991
+ {
992
+ #proxy_items
993
+ }
994
+ }
995
+ } else {
996
+ quote ! {
997
+ impl <' a, REG , const O : u8 > #writer_ty<' a, REG , O >
998
+ where
999
+ REG : crate :: Writable + crate :: RegisterSpec ,
1000
+ REG :: Ux : From <#fty>
1001
+ {
1002
+ #proxy_items
1003
+ }
989
1004
}
990
1005
} ) ;
991
1006
}
@@ -1032,7 +1047,7 @@ pub fn fields(
1032
1047
#[ doc = #doc]
1033
1048
#inline
1034
1049
#[ must_use]
1035
- pub unsafe fn #name_snake_case<const O : u8 >( & mut self ) -> #writer_ty<O > {
1050
+ pub unsafe fn #name_snake_case<const O : u8 >( & mut self ) -> #writer_ty<#regspec_ident , O > {
1036
1051
#writer_ty:: new( self )
1037
1052
}
1038
1053
} ) ;
@@ -1051,7 +1066,7 @@ pub fn fields(
1051
1066
#[ doc = #doc]
1052
1067
#inline
1053
1068
#[ must_use]
1054
- pub fn #name_snake_case_n( & mut self ) -> #writer_ty<#sub_offset> {
1069
+ pub fn #name_snake_case_n( & mut self ) -> #writer_ty<#regspec_ident , # sub_offset> {
1055
1070
#writer_ty:: new( self )
1056
1071
}
1057
1072
} ) ;
@@ -1063,7 +1078,7 @@ pub fn fields(
1063
1078
#[ doc = #doc]
1064
1079
#inline
1065
1080
#[ must_use]
1066
- pub fn #name_snake_case( & mut self ) -> #writer_ty<#offset> {
1081
+ pub fn #name_snake_case( & mut self ) -> #writer_ty<#regspec_ident , # offset> {
1067
1082
#writer_ty:: new( self )
1068
1083
}
1069
1084
} ) ;
0 commit comments