11use crate :: svd:: {
2- Access , BitRange , DimElement , EnumeratedValues , Field , MaybeArray , ModifiedWriteValues ,
2+ self , Access , BitRange , DimElement , EnumeratedValues , Field , MaybeArray , ModifiedWriteValues ,
33 ReadAction , Register , RegisterProperties , Usage , WriteConstraint ,
44} ;
55use core:: u64;
@@ -857,12 +857,12 @@ pub fn fields(
857857 }
858858 }
859859
860- if let Field :: Array ( _ , de) = & f {
860+ if let Field :: Array ( f , de) = & f {
861861 let increment = de. dim_increment ;
862862 let doc = util:: replace_suffix ( & description, & brief_suffix) ;
863-
863+ let first_name = svd :: array :: names ( f , de ) . next ( ) . unwrap ( ) ;
864864 let array_doc =
865- format ! ( "{doc}\n \n NOTE: `n` is number of field in register starting from 0 " ) ;
865+ format ! ( "{doc}\n \n NOTE: `n` is number of field in register. `n == 0` corresponds to `{first_name}` field " ) ;
866866 let offset_calc = calculate_offset ( increment, offset, true ) ;
867867 let value = quote ! { ( ( self . bits >> #offset_calc) & #hexmask) #cast } ;
868868 let dim = util:: unsuffixed ( de. dim as _ ) ;
@@ -876,7 +876,7 @@ pub fn fields(
876876 }
877877 } ) ;
878878
879- for fi in crate :: svd:: field:: expand ( & f, de) {
879+ for fi in svd:: field:: expand ( & f, de) {
880880 let sub_offset = fi. bit_offset ( ) as u64 ;
881881 let value = if sub_offset != 0 {
882882 let sub_offset = & util:: unsuffixed ( sub_offset) ;
@@ -1111,13 +1111,16 @@ pub fn fields(
11111111 }
11121112 }
11131113
1114- if let Field :: Array ( _ , de) = & f {
1114+ if let Field :: Array ( f , de) = & f {
11151115 let increment = de. dim_increment ;
11161116 let offset_calc = calculate_offset ( increment, offset, false ) ;
11171117 let doc = & util:: replace_suffix ( & description, & brief_suffix) ;
1118+ let first_name = svd:: array:: names ( f, de) . next ( ) . unwrap ( ) ;
1119+ let array_doc =
1120+ format ! ( "{doc}\n \n NOTE: `n` is number of field in register. `n == 0` corresponds to `{first_name}` field" ) ;
11181121 let dim = util:: unsuffixed ( de. dim as _ ) ;
11191122 w_impl_items. extend ( quote ! {
1120- #[ doc = #doc ]
1123+ #[ doc = #array_doc ]
11211124 #inline
11221125 #[ must_use]
11231126 pub fn #name_snake_case( & mut self , n: u8 ) -> #writer_ty<#regspec_ident> {
@@ -1127,7 +1130,7 @@ pub fn fields(
11271130 }
11281131 } ) ;
11291132
1130- for fi in crate :: svd:: field:: expand ( & f, de) {
1133+ for fi in svd:: field:: expand ( & f, de) {
11311134 let sub_offset = fi. bit_offset ( ) as u64 ;
11321135 let name_snake_case_n = & fi. name . to_snake_case_ident ( Span :: call_site ( ) ) ;
11331136 let doc = description_with_bits (
0 commit comments