@@ -62,7 +62,9 @@ pub fn gen_peripheral(cx: &ExtCtxt, p: &Peripheral, d: &Defaults) -> Vec<P<Item>
62
62
i += 1 ;
63
63
}
64
64
65
- let comment = & format ! ( "/// {}" , respace( & register. description) ) [ ..] ;
65
+ let comment = & format ! ( "/// 0x{:02x} - {}" ,
66
+ register. address_offset,
67
+ respace( & register. description) ) [ ..] ;
66
68
fields. push ( builder. struct_field ( register. name . to_camel_case ( ) )
67
69
. pub_ ( )
68
70
. attr ( )
@@ -241,7 +243,13 @@ pub fn gen_register_r(cx: &ExtCtxt, r: &Register, d: &Defaults) -> Vec<P<Item>>
241
243
} ;
242
244
243
245
if let Some ( description) = field. description . as_ref ( ) {
244
- let comment = & format ! ( "/// {}" , respace( description) ) [ ..] ;
246
+ let bits = if width == 1 {
247
+ format ! ( "Bit {}" , field. bit_range. offset)
248
+ } else {
249
+ format ! ( "Bits {}:{}" , field. bit_range. offset, field. bit_range. offset + width - 1 )
250
+ } ;
251
+
252
+ let comment = & format ! ( "/// {} - {}" , bits, respace( description) ) [ ..] ;
245
253
item. attrs . push ( builder. attr ( ) . doc ( comment) ) ;
246
254
}
247
255
@@ -319,7 +327,13 @@ pub fn gen_register_w(cx: &ExtCtxt, r: &Register, d: &Defaults) -> Vec<P<Item>>
319
327
} ;
320
328
321
329
if let Some ( description) = field. description . as_ref ( ) {
322
- let comment = & format ! ( "/// {}" , respace( description) ) [ ..] ;
330
+ let bits = if width == 1 {
331
+ format ! ( "Bit {}" , field. bit_range. offset)
332
+ } else {
333
+ format ! ( "Bits {}:{}" , field. bit_range. offset, field. bit_range. offset + width - 1 )
334
+ } ;
335
+
336
+ let comment = & format ! ( "/// {} - {}" , bits, respace( description) ) [ ..] ;
323
337
item. attrs . push ( builder. attr ( ) . doc ( comment) ) ;
324
338
}
325
339
0 commit comments