@@ -7,6 +7,7 @@ use super::{
7
7
AddressBlock , BuildError , Cluster , Description , DimElement , EmptyToNone , Interrupt , MaybeArray ,
8
8
Name , Register , RegisterCluster , RegisterProperties , SvdError , ValidateLevel ,
9
9
} ;
10
+ use std:: ops:: Deref ;
10
11
11
12
/// A single peripheral or array of peripherals
12
13
pub type Peripheral = MaybeArray < PeripheralInfo > ;
@@ -369,7 +370,7 @@ impl PeripheralInfo {
369
370
self . validate ( lvl)
370
371
}
371
372
372
- /// Validate the [`Peripheral `]
373
+ /// Validate the [`PeripheralInfo `]
373
374
pub fn validate ( & self , lvl : ValidateLevel ) -> Result < ( ) , SvdError > {
374
375
if !lvl. is_disabled ( ) {
375
376
// TODO
@@ -388,6 +389,25 @@ impl PeripheralInfo {
388
389
}
389
390
Ok ( ( ) )
390
391
}
392
+ /// Validate the [`PeripheralInfo`] recursively
393
+ pub fn validate_all ( & self , lvl : ValidateLevel ) -> Result < ( ) , SvdError > {
394
+ if let Some ( abs) = self . address_block . as_ref ( ) {
395
+ for ab in abs {
396
+ ab. validate ( lvl) ?;
397
+ }
398
+ }
399
+ for i in & self . interrupt {
400
+ i. validate ( lvl) ?;
401
+ }
402
+ self . default_register_properties . validate ( lvl) ?;
403
+ for r in self . registers ( ) {
404
+ r. validate_all ( lvl) ?;
405
+ }
406
+ for c in self . clusters ( ) {
407
+ c. validate_all ( lvl) ?;
408
+ }
409
+ self . validate ( lvl)
410
+ }
391
411
392
412
/// Returns iterator over child registers
393
413
pub fn registers ( & self ) -> RegisterIter {
@@ -492,6 +512,16 @@ impl PeripheralInfo {
492
512
}
493
513
}
494
514
515
+ impl Peripheral {
516
+ /// Validate the [`Peripheral`] recursively
517
+ pub fn validate_all ( & self , lvl : ValidateLevel ) -> Result < ( ) , SvdError > {
518
+ if let Self :: Array ( _, dim) = self {
519
+ dim. validate ( lvl) ?;
520
+ }
521
+ self . deref ( ) . validate_all ( lvl)
522
+ }
523
+ }
524
+
495
525
impl Name for PeripheralInfo {
496
526
fn name ( & self ) -> & str {
497
527
& self . name
0 commit comments