@@ -7,6 +7,7 @@ use super::{
77 AddressBlock , BuildError , Cluster , Description , DimElement , EmptyToNone , Interrupt , MaybeArray ,
88 Name , Register , RegisterCluster , RegisterProperties , SvdError , ValidateLevel ,
99} ;
10+ use std:: ops:: Deref ;
1011
1112/// A single peripheral or array of peripherals
1213pub type Peripheral = MaybeArray < PeripheralInfo > ;
@@ -369,7 +370,7 @@ impl PeripheralInfo {
369370 self . validate ( lvl)
370371 }
371372
372- /// Validate the [`Peripheral `]
373+ /// Validate the [`PeripheralInfo `]
373374 pub fn validate ( & self , lvl : ValidateLevel ) -> Result < ( ) , SvdError > {
374375 if !lvl. is_disabled ( ) {
375376 // TODO
@@ -388,6 +389,25 @@ impl PeripheralInfo {
388389 }
389390 Ok ( ( ) )
390391 }
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+ }
391411
392412 /// Returns iterator over child registers
393413 pub fn registers ( & self ) -> RegisterIter {
@@ -492,6 +512,16 @@ impl PeripheralInfo {
492512 }
493513}
494514
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+
495525impl Name for PeripheralInfo {
496526 fn name ( & self ) -> & str {
497527 & self . name
0 commit comments