[][src]Struct svd_expander::DeviceSpec

pub struct DeviceSpec {
    pub name: String,
    pub version: Option<String>,
    pub description: Option<String>,
    pub address_unit_bits: Option<u32>,
    pub width: Option<u32>,
    pub cpu: Option<CpuSpec>,
    pub peripherals: Vec<PeripheralSpec>,
    pub default_register_size: Option<u32>,
    pub default_register_reset_value: Option<u32>,
    pub default_register_reset_mask: Option<u32>,
    pub default_register_access: Option<AccessSpec>,
}

Represents information about a device specified in a CMSIS-SVD file.

Fields

name: Stringversion: Option<String>

The full name of the vendor of the device.

description: Option<String>

Description of the main features of the device (i.e. CPU, clock frequency, peripheral overview).

address_unit_bits: Option<u32>

The number of data bits uniquely selected by each address. The value for Cortex-M-based devices is 8 (byte-addressable).

width: Option<u32>

The bit width of the maximum single data transfer supported by bu bus infrastructure. Expected value for Cortex-M-based devices is 32.

cpu: Option<CpuSpec>

The processor included in the device.

peripherals: Vec<PeripheralSpec>

The device's peripherals.

default_register_size: Option<u32>

Default bit width of any register contained in the device.

default_register_reset_value: Option<u32>

Default value of all registers after reset.

default_register_reset_mask: Option<u32>

Defines which register bits have a defined reset value.

default_register_access: Option<AccessSpec>

Default access rights for all registers.

Implementations

impl DeviceSpec[src]

pub fn from_xml(xml: &str) -> SvdExpanderResult<Self>[src]

Creates a new device by parsing an XML string following the CMSIS-SVD specification. Expands all array definitions and resolves inheritance chains to fully resolve all populate all the components of the device.

Arguments

  • xml = An XML string containing a device specification in the CMSIS-SVD format.

Example

use svd_expander::DeviceSpec;
let device = DeviceSpec::from_xml(
  r##"
  <device
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" schemaVersion="1.1" xsi:noNamespaceSchemaLocation="CMSIS-SVD_Schema_1_1.xsd">
    <name>STM32F303</name>
    <version>1.2</version>
    <peripherals>
    </peripherals>
  </device>
  "##
).unwrap();

assert_eq!("STM32F303", device.name);
assert_eq!("1.2", device.version.unwrap());

pub fn iter_clusters(&self) -> impl Iterator<Item = &ClusterSpec>[src]

Recursively iterates all the register clusters on the device.

pub fn iter_registers(&self) -> impl Iterator<Item = &RegisterSpec>[src]

Recursively iterates all the registers on the device.

pub fn iter_fields(&self) -> impl Iterator<Item = &FieldSpec>[src]

Recursively iterates all the register fields on the device.

pub fn iter_enumerated_value_sets(
    &self
) -> impl Iterator<Item = &EnumeratedValueSetSpec>
[src]

Recursively iterates all the enumerated value sets on the device.

pub fn get_peripheral(&self, path: &str) -> SvdExpanderResult<&PeripheralSpec>[src]

Gets the peripheral that exists at the given path. Peripherals top-level constructs and can't be nested, so a peripheral path is simply the name of the peripheral.

Arguments

  • path = The path to the peripheral. Since peripherals are top-level components and can't be nested, this is just the name of the peripheral.

pub fn get_cluster(&self, path: &str) -> SvdExpanderResult<&ClusterSpec>[src]

Gets the register cluster that exists at the given path.

Arguments

  • path = The path to the register cluster.

pub fn get_register(&self, path: &str) -> SvdExpanderResult<&RegisterSpec>[src]

Gets the register that exists at the given path.

Arguments

  • path = The path to the register.

pub fn get_field(&self, path: &str) -> SvdExpanderResult<&FieldSpec>[src]

Gets the register field that exists at the given path.

Arguments

  • path = The path to the register field.

Trait Implementations

impl Clone for DeviceSpec[src]

impl Debug for DeviceSpec[src]

impl PartialEq<DeviceSpec> for DeviceSpec[src]

impl StructuralPartialEq for DeviceSpec[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.