1
1
use crate :: svd:: {
2
- Access , BitRange , DimElement , EnumeratedValues , Field , MaybeArray , ModifiedWriteValues ,
2
+ self , Access , BitRange , DimElement , EnumeratedValues , Field , MaybeArray , ModifiedWriteValues ,
3
3
ReadAction , Register , RegisterProperties , Usage , WriteConstraint ,
4
4
} ;
5
5
use core:: u64;
@@ -857,12 +857,12 @@ pub fn fields(
857
857
}
858
858
}
859
859
860
- if let Field :: Array ( _ , de) = & f {
860
+ if let Field :: Array ( f , de) = & f {
861
861
let increment = de. dim_increment ;
862
862
let doc = util:: replace_suffix ( & description, & brief_suffix) ;
863
-
863
+ let first_name = svd :: array :: names ( f , de ) . next ( ) . unwrap ( ) ;
864
864
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 " ) ;
866
866
let offset_calc = calculate_offset ( increment, offset, true ) ;
867
867
let value = quote ! { ( ( self . bits >> #offset_calc) & #hexmask) #cast } ;
868
868
let dim = util:: unsuffixed ( de. dim as _ ) ;
@@ -876,7 +876,7 @@ pub fn fields(
876
876
}
877
877
} ) ;
878
878
879
- for fi in crate :: svd:: field:: expand ( & f, de) {
879
+ for fi in svd:: field:: expand ( & f, de) {
880
880
let sub_offset = fi. bit_offset ( ) as u64 ;
881
881
let value = if sub_offset != 0 {
882
882
let sub_offset = & util:: unsuffixed ( sub_offset) ;
@@ -1111,13 +1111,16 @@ pub fn fields(
1111
1111
}
1112
1112
}
1113
1113
1114
- if let Field :: Array ( _ , de) = & f {
1114
+ if let Field :: Array ( f , de) = & f {
1115
1115
let increment = de. dim_increment ;
1116
1116
let offset_calc = calculate_offset ( increment, offset, false ) ;
1117
1117
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" ) ;
1118
1121
let dim = util:: unsuffixed ( de. dim as _ ) ;
1119
1122
w_impl_items. extend ( quote ! {
1120
- #[ doc = #doc ]
1123
+ #[ doc = #array_doc ]
1121
1124
#inline
1122
1125
#[ must_use]
1123
1126
pub fn #name_snake_case( & mut self , n: u8 ) -> #writer_ty<#regspec_ident> {
@@ -1127,7 +1130,7 @@ pub fn fields(
1127
1130
}
1128
1131
} ) ;
1129
1132
1130
- for fi in crate :: svd:: field:: expand ( & f, de) {
1133
+ for fi in svd:: field:: expand ( & f, de) {
1131
1134
let sub_offset = fi. bit_offset ( ) as u64 ;
1132
1135
let name_snake_case_n = & fi. name . to_snake_case_ident ( Span :: call_site ( ) ) ;
1133
1136
let doc = description_with_bits (
0 commit comments