@@ -14,9 +14,9 @@ use super::{
14
14
} ;
15
15
use super :: { make_cluster, make_interrupt, make_register} ;
16
16
17
- use svd:: registercluster:: { AllRegistersIterMut , ClusterIterMut } ;
17
+ use svd:: registercluster:: { ClusterIterMut , RegisterIterMut } ;
18
18
pub type ClusterMatchIterMut < ' a , ' b > = MatchIter < ' b , ClusterIterMut < ' a > > ;
19
- pub type RegMatchIterMut < ' a , ' b > = MatchIter < ' b , AllRegistersIterMut < ' a > > ;
19
+ pub type RegMatchIterMut < ' a , ' b > = MatchIter < ' b , RegisterIterMut < ' a > > ;
20
20
21
21
/// Collecting methods for processing peripheral contents
22
22
pub trait PeripheralExt : InterruptExt + RegisterBlockExt {
@@ -332,15 +332,6 @@ impl PeripheralExt for Peripheral {
332
332
}
333
333
}
334
334
335
- // Handle clusters
336
- for ( cspec, cluster) in pmod. hash_iter ( "_clusters" ) {
337
- let cspec = cspec. str ( ) ?;
338
- if !cspec. starts_with ( '_' ) {
339
- self . process_cluster ( cspec, cluster. hash ( ) ?, update_fields)
340
- . with_context ( || format ! ( "According to `{cspec}`" ) ) ?;
341
- }
342
- }
343
-
344
335
// Handle registers
345
336
for ( rspec, register) in pmod {
346
337
let rspec = rspec. str ( ) ?;
@@ -364,6 +355,15 @@ impl PeripheralExt for Peripheral {
364
355
. with_context ( || format ! ( "Collecting registers in cluster `{cname}`" ) ) ?;
365
356
}
366
357
358
+ // Handle clusters
359
+ for ( cspec, cluster) in pmod. hash_iter ( "_clusters" ) {
360
+ let cspec = cspec. str ( ) ?;
361
+ if !cspec. starts_with ( '_' ) {
362
+ self . process_cluster ( cspec, cluster. hash ( ) ?, update_fields)
363
+ . with_context ( || format ! ( "According to `{cspec}`" ) ) ?;
364
+ }
365
+ }
366
+
367
367
Ok ( ( ) )
368
368
}
369
369
}
@@ -403,7 +403,7 @@ impl InterruptExt for Peripheral {
403
403
404
404
impl RegisterBlockExt for Peripheral {
405
405
fn iter_registers < ' a , ' b > ( & ' a mut self , spec : & ' b str ) -> RegMatchIterMut < ' a , ' b > {
406
- self . all_registers_mut ( ) . matched ( spec)
406
+ self . registers_mut ( ) . matched ( spec)
407
407
}
408
408
409
409
fn iter_clusters < ' a , ' b > ( & ' a mut self , spec : & ' b str ) -> ClusterMatchIterMut < ' a , ' b > {
@@ -447,9 +447,9 @@ impl RegisterBlockExt for Peripheral {
447
447
}
448
448
449
449
fn add_cluster ( & mut self , cname : & str , cadd : & Hash ) -> PatchResult {
450
- if self . all_registers ( ) . any ( |c| c. name == cname) {
450
+ if self . clusters ( ) . any ( |c| c. name == cname) {
451
451
return Err ( anyhow ! (
452
- "peripheral {} already has a register {cname}" ,
452
+ "peripheral {} already has a cluster {cname}" ,
453
453
self . name
454
454
) ) ;
455
455
}
@@ -515,7 +515,7 @@ impl RegisterBlockExt for Peripheral {
515
515
} ) ?;
516
516
517
517
let mut source = self
518
- . all_registers ( )
518
+ . registers ( )
519
519
. find ( |r| r. name == srcname)
520
520
. ok_or_else ( || anyhow ! ( "peripheral {} does not have register {srcname}" , self . name) ) ?
521
521
. clone ( ) ;
@@ -524,7 +524,7 @@ impl RegisterBlockExt for Peripheral {
524
524
. display_name ( Some ( "" . into ( ) ) ) ;
525
525
// Modifying fields in derived register not implemented
526
526
source. modify_from ( fixes, VAL_LVL ) ?;
527
- if let Some ( ptag) = self . all_registers_mut ( ) . find ( |r| r. name == rname) {
527
+ if let Some ( ptag) = self . registers_mut ( ) . find ( |r| r. name == rname) {
528
528
source. address_offset = ptag. address_offset ;
529
529
* ptag = source;
530
530
} else {
@@ -574,7 +574,7 @@ impl RegisterBlockExt for Peripheral {
574
574
fn strip_start ( & mut self , prefix : & str ) -> PatchResult {
575
575
let len = prefix. len ( ) ;
576
576
let glob = globset:: Glob :: new ( & ( prefix. to_string ( ) + "*" ) ) ?. compile_matcher ( ) ;
577
- for rtag in self . all_registers_mut ( ) {
577
+ for rtag in self . registers_mut ( ) {
578
578
if glob. is_match ( & rtag. name ) {
579
579
rtag. name . drain ( ..len) ;
580
580
}
@@ -592,7 +592,7 @@ impl RegisterBlockExt for Peripheral {
592
592
let glob = globset:: Glob :: new ( & ( "*" . to_string ( ) + suffix) )
593
593
. unwrap ( )
594
594
. compile_matcher ( ) ;
595
- for rtag in self . all_registers_mut ( ) {
595
+ for rtag in self . registers_mut ( ) {
596
596
if glob. is_match ( & rtag. name ) {
597
597
let nlen = rtag. name . len ( ) ;
598
598
rtag. name . truncate ( nlen - len) ;
@@ -867,7 +867,7 @@ impl ClusterExt for Cluster {
867
867
868
868
impl RegisterBlockExt for Cluster {
869
869
fn iter_registers < ' a , ' b > ( & ' a mut self , spec : & ' b str ) -> RegMatchIterMut < ' a , ' b > {
870
- self . all_registers_mut ( ) . matched ( spec)
870
+ self . registers_mut ( ) . matched ( spec)
871
871
}
872
872
873
873
fn iter_clusters < ' a , ' b > ( & ' a mut self , spec : & ' b str ) -> ClusterMatchIterMut < ' a , ' b > {
@@ -973,7 +973,7 @@ impl RegisterBlockExt for Cluster {
973
973
} ) ?;
974
974
975
975
let mut source = self
976
- . all_registers ( )
976
+ . registers ( )
977
977
. find ( |r| r. name == srcname)
978
978
. ok_or_else ( || anyhow ! ( "peripheral {} does not have register {srcname}" , self . name, ) ) ?
979
979
. clone ( ) ;
@@ -982,7 +982,7 @@ impl RegisterBlockExt for Cluster {
982
982
. display_name ( Some ( "" . into ( ) ) ) ;
983
983
// Modifying fields in derived register not implemented
984
984
source. modify_from ( fixes, VAL_LVL ) ?;
985
- if let Some ( ptag) = self . all_registers_mut ( ) . find ( |r| r. name == rname) {
985
+ if let Some ( ptag) = self . registers_mut ( ) . find ( |r| r. name == rname) {
986
986
source. address_offset = ptag. address_offset ;
987
987
* ptag = source;
988
988
} else {
@@ -1023,7 +1023,7 @@ impl RegisterBlockExt for Cluster {
1023
1023
fn strip_start ( & mut self , prefix : & str ) -> PatchResult {
1024
1024
let len = prefix. len ( ) ;
1025
1025
let glob = globset:: Glob :: new ( & ( prefix. to_string ( ) + "*" ) ) ?. compile_matcher ( ) ;
1026
- for rtag in self . all_registers_mut ( ) {
1026
+ for rtag in self . registers_mut ( ) {
1027
1027
if glob. is_match ( & rtag. name ) {
1028
1028
rtag. name . drain ( ..len) ;
1029
1029
}
@@ -1041,7 +1041,7 @@ impl RegisterBlockExt for Cluster {
1041
1041
let glob = globset:: Glob :: new ( & ( "*" . to_string ( ) + suffix) )
1042
1042
. unwrap ( )
1043
1043
. compile_matcher ( ) ;
1044
- for rtag in self . all_registers_mut ( ) {
1044
+ for rtag in self . registers_mut ( ) {
1045
1045
if glob. is_match ( & rtag. name ) {
1046
1046
let nlen = rtag. name . len ( ) ;
1047
1047
rtag. name . truncate ( nlen - len) ;
0 commit comments