@@ -5,8 +5,7 @@ use std::collections::HashMap;
5
5
use std:: fmt;
6
6
use std:: mem:: take;
7
7
use svd_rs:: {
8
- array:: { descriptions, names} ,
9
- cluster, field, peripheral, register, BitRange , Cluster , ClusterInfo , DeriveFrom , Device ,
8
+ array:: names, cluster, field, peripheral, register, Cluster , ClusterInfo , DeriveFrom , Device ,
10
9
EnumeratedValues , Field , Peripheral , Register , RegisterCluster , RegisterProperties ,
11
10
} ;
12
11
@@ -320,17 +319,7 @@ fn expand_cluster_array(
320
319
match c {
321
320
Cluster :: Single ( c) => expand_cluster ( regs, c) ,
322
321
Cluster :: Array ( info, dim) => {
323
- for c in names ( & info, & dim)
324
- . zip ( descriptions ( & info, & dim) )
325
- . zip ( cluster:: address_offsets ( & info, & dim) )
326
- . map ( |( ( name, description) , address_offset) | {
327
- let mut info = info. clone ( ) ;
328
- info. name = name;
329
- info. description = description;
330
- info. address_offset = address_offset;
331
- info
332
- } )
333
- {
322
+ for c in cluster:: expand ( & info, & dim) {
334
323
expand_cluster ( regs, c) ;
335
324
}
336
325
}
@@ -468,19 +457,7 @@ fn expand_register_array(
468
457
regs. push ( r. into ( ) ) ;
469
458
}
470
459
Register :: Array ( info, dim) => {
471
- for rx in names ( & info, & dim)
472
- . zip ( descriptions ( & info, & dim) )
473
- . zip ( register:: address_offsets ( & info, & dim) )
474
- . map ( |( ( name, description) , address_offset) | {
475
- let mut info = info. clone ( ) ;
476
- info. name = name;
477
- info. description = description;
478
- info. address_offset = address_offset;
479
- info. single ( )
480
- } )
481
- {
482
- regs. push ( rx. into ( ) ) ;
483
- }
460
+ regs. extend ( register:: expand ( & info, & dim) . map ( |r| r. single ( ) . into ( ) ) ) ;
484
461
}
485
462
}
486
463
Ok ( ( ) )
@@ -511,19 +488,7 @@ fn expand_field(
511
488
fields. push ( f) ;
512
489
}
513
490
Field :: Array ( info, dim) => {
514
- for fx in names ( & info, & dim)
515
- . zip ( descriptions ( & info, & dim) )
516
- . zip ( field:: bit_offsets ( & info, & dim) )
517
- . map ( |( ( name, description) , bit_offset) | {
518
- let mut info = info. clone ( ) ;
519
- info. name = name;
520
- info. description = description;
521
- info. bit_range = BitRange :: from_offset_width ( bit_offset, info. bit_width ( ) ) ;
522
- Field :: Single ( info)
523
- } )
524
- {
525
- fields. push ( fx) ;
526
- }
491
+ fields. extend ( field:: expand ( & info, & dim) . map ( Field :: Single ) ) ;
527
492
}
528
493
}
529
494
@@ -636,19 +601,9 @@ pub fn expand(indevice: &Device) -> Result<Device> {
636
601
device. peripherals . push ( p) ;
637
602
}
638
603
Peripheral :: Array ( info, dim) => {
639
- for px in names ( & info, & dim)
640
- . zip ( descriptions ( & info, & dim) )
641
- . zip ( peripheral:: base_addresses ( & info, & dim) )
642
- . map ( |( ( name, description) , base_address) | {
643
- let mut info = info. clone ( ) ;
644
- info. name = name;
645
- info. description = description;
646
- info. base_address = base_address;
647
- Peripheral :: Single ( info)
648
- } )
649
- {
650
- device. peripherals . push ( px) ;
651
- }
604
+ device
605
+ . peripherals
606
+ . extend ( peripheral:: expand ( & info, & dim) . map ( Peripheral :: Single ) ) ;
652
607
}
653
608
}
654
609
}
0 commit comments