svd_generator/svd/peripheral/
jh7110_ispcrg.rs

1use crate::svd::create_peripheral;
2use crate::Result;
3
4pub mod registers;
5
6/// Represents a StarFive JH7110 ISP CRG (compatible) peripheral
7pub struct Jh7110IspCrg {
8    peripheral: svd::Peripheral,
9}
10
11impl Jh7110IspCrg {
12    /// Creates a new [Jh7110IspCrg] peripheral.
13    pub fn create(
14        name: &str,
15        base_address: u64,
16        size: u32,
17        interrupt: Option<Vec<svd::Interrupt>>,
18    ) -> Result<Self> {
19        let peripheral = create_peripheral(
20            name,
21            format!("StarFive JH7110 ISP CRG: {name}").as_str(),
22            base_address,
23            size,
24            interrupt,
25            Some(registers::create()?),
26            None,
27        )?;
28
29        Ok(Self { peripheral })
30    }
31
32    /// Gets a reference to the SVD [`Peripheral`](svd::Peripheral).
33    pub const fn peripheral(&self) -> &svd::Peripheral {
34        &self.peripheral
35    }
36
37    /// Gets a mutable reference to the SVD [`Peripheral`](svd::Peripheral).
38    pub fn peripheral_mut(&mut self) -> &mut svd::Peripheral {
39        &mut self.peripheral
40    }
41
42    /// Converts the [Jh7110IspCrg] into the inner SVD [`Peripheral`](svd::Peripheral).
43    pub fn to_inner(self) -> svd::Peripheral {
44        self.peripheral
45    }
46}