svd-generator 0.4.4

Converts device information from flattened device tree into an SVD description
Documentation
use crate::svd::create_peripheral;
use crate::Result;

mod model;
pub mod registers;
mod version;

pub use model::*;
pub use version::*;

/// Represents a Synopsys DesignWare MMC (compatible) peripheral.
pub struct DwMmc {
    peripheral: svd::Peripheral,
}

impl DwMmc {
    /// Creates a new [DwMmc] peripheral.
    pub fn create(
        name: &str,
        base_address: u64,
        size: u32,
        interrupt: Option<Vec<svd::Interrupt>>,
        model: DwMmcModel,
    ) -> Result<Self> {
        let peripheral = create_peripheral(
            name,
            format!("Synopsys DesignWare MMC ({model}): {name}").as_str(),
            base_address,
            size,
            interrupt,
            Some(registers::create(model)?),
            None,
        )?;

        Ok(Self { peripheral })
    }

    /// Gets a reference to the SVD [`Peripheral`](svd::Peripheral).
    pub const fn peripheral(&self) -> &svd::Peripheral {
        &self.peripheral
    }

    /// Gets a mutable reference to the SVD [`Peripheral`](svd::Peripheral).
    pub fn peripheral_mut(&mut self) -> &mut svd::Peripheral {
        &mut self.peripheral
    }

    /// Converts the [DwMmc] into the inner SVD [`Peripheral`](svd::Peripheral).
    pub fn to_inner(self) -> svd::Peripheral {
        self.peripheral
    }
}