[−][src]Crate svd_expander
Expands arrays and resolves inheritance chains in CMSIS-SVD specifications.
Example usage:
use svd_expander::DeviceSpec; fn main() { let xml = r##" <device> <name>CORTEX_DEVICE</name> <peripherals> <peripheral> <name>GPIOA</name> <baseAddress>0x40010000</baseAddress> <registers> <register> <name>IDR</name> <description>Input Data Register</description> <addressOffset>0x00</addressOffset> <fields> <!-- This field is a template that will be expanded out to 16 input fields named D1 through D16. --> <field> <name>D%s</name> <bitWidth>1</bitWidth> <bitOffset>0</bitOffset> <dim>16</dim> <dimIndex>1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16</dimIndex> <dimIncrement>1</dimIncrement> </field> </fields> </register> </registers> </peripheral> <!-- GPIOA will be copied to make GPIOB below, which is identical except for any overridden properties (just name and baseAddress in this case). --> <peripheral derivedFrom="GPIOA"> <name>GPIOB</name> <baseAddress>0x40010100</baseAddress> </peripheral> </peripherals> </device> "##; 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 are welcome.
Feature requests may be considered, but svd-expander depends on svd-parser (at least for now) to parse the SVD files, so it can only implement the features supported by the parser.
Structs
AddressBlockSpec | Describes an address range uniquely mapped to a peripheral. |
ClusterSpec | Describes a cluster of registers that exist on a peripheral. Clusters may be top-level constructs of a peripheral or may be nested within other clusters. |
CpuSpec | Describes the processor included in the microcontroller device. |
DeviceSpec | Represents information about a device specified in a CMSIS-SVD file. |
EnumeratedValueSetSpec | A set of values that can be written to and/or read from a field. |
EnumeratedValueSpec | A value that can be written to or read from a field (or both). |
FieldSpec | Describes a field on a register. |
InterruptSpec | Describes an interrupt that exists on a peripheral. |
PeripheralSpec | Describes a peripheral on a device. |
RegisterSpec | Describes a register. Registers may be top-level constructs of a peripheral or may be nested within register clusters. |
SvdExpanderError | Error struct for all errors thrown by this crate or the crates on which it depends. |
WriteConstraintRangeSpec | A range of values that can be written to a field. Writable values are integers that fall within
the |
Enums
AccessSpec | Defines access rights for fields on the device, though it may be specified at a higher level than individual fields. |
EndianSpec | Defines the endianness of a CPU. |
EnumeratedValueUsageSpec | Defines whether an enumerated value may be read from a field, written to a field, or both. |
EnumeratedValueValueSpec | The actual content that can be written to or read from a field as part of an enumerated value set. |
ModifiedWriteValuesSpec | Describes the manipulation of data written to a field. If not specified, the values written to the field is the value stored in the field. |
WriteConstraintSpec | Defines constraints for writing values to a field. |
Type Definitions
SvdExpanderResult | Convenience type for a result that may contain an |