[![crates.io](https://img.shields.io/crates/d/svd-expander.svg)](https://crates.io/crates/svd-expander) [![crates.io](https://img.shields.io/crates/v/svd-expander.svg)](https://crates.io/crates/svd-expander) [![Documentation](https://docs.rs/svd-expander/badge.svg)](https://docs.rs/svd-expander) [![Rust CI](https://github.com/Past9/svd-expander/workflows/Rust/badge.svg?branch=master)](https://github.com/Past9/svd-expander/actions?query=workflow%3ARust+branch%3Amaster) # `svd-expander` Expands arrays and resolves inheritance chains in CMSIS-SVD specifications. ## Example usage: ```rust use svd_expander::DeviceSpec; fn main() { let xml = r##" CORTEX_DEVICE GPIOA 0x40010000 IDR Input Data Register 0x00 D%s 1 0 16 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 1 GPIOB 0x40010100 "##; let device = DeviceSpec::from_xml(xml).unwrap(); // The IDR register on GPIOA has been expanded to 16 fields. assert_eq!(16, device.get_register("GPIOA.IDR").unwrap().fields.len()); // Those fields each had their bit offset (location in the register) // incremented appropriately. assert_eq!(0, device.get_field("GPIOA.IDR.D1").unwrap().offset); assert_eq!(1, device.get_field("GPIOA.IDR.D2").unwrap().offset); // ...etc... assert_eq!(9, device.get_field("GPIOA.IDR.D10").unwrap().offset); // ...etc... // GPIOB also has an IDR register with 16 fields, which was inherited // from GPIOA. assert_eq!(16, device.get_register("GPIOB.IDR").unwrap().fields.len()); // GPIOB kept its name and base address when it inherited properties // from GPIOA. assert_eq!("GPIOB", device.get_peripheral("GPIOB").unwrap().name); assert_eq!(0x40010100, device.get_peripheral("GPIOB").unwrap().base_address); } ``` This crate is intended for use in code generators. It is under active development and bug reports and feature requests are welcome.