hk32f005-pac 0.1.0

HK32F005 PAC, Generate by Chiptool
Documentation
#[doc = "CR"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Cr(pub u32);
impl Cr {
    #[doc = "Reset control"]
    #[must_use]
    #[inline(always)]
    pub const fn reset(&self) -> bool {
        let val = (self.0 >> 0usize) & 0x01;
        val != 0
    }
    #[doc = "Reset control"]
    #[inline(always)]
    pub const fn set_reset(&mut self, val: bool) {
        self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
    }
    #[doc = "Input data revert"]
    #[must_use]
    #[inline(always)]
    pub const fn rev_in(&self) -> u8 {
        let val = (self.0 >> 5usize) & 0x03;
        val as u8
    }
    #[doc = "Input data revert"]
    #[inline(always)]
    pub const fn set_rev_in(&mut self, val: u8) {
        self.0 = (self.0 & !(0x03 << 5usize)) | (((val as u32) & 0x03) << 5usize);
    }
    #[doc = "Output data revert"]
    #[must_use]
    #[inline(always)]
    pub const fn rev_out(&self) -> bool {
        let val = (self.0 >> 7usize) & 0x01;
        val != 0
    }
    #[doc = "Output data revert"]
    #[inline(always)]
    pub const fn set_rev_out(&mut self, val: bool) {
        self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize);
    }
}
impl Default for Cr {
    #[inline(always)]
    fn default() -> Cr {
        Cr(0)
    }
}
impl core::fmt::Debug for Cr {
    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
        f.debug_struct("Cr")
            .field("reset", &self.reset())
            .field("rev_in", &self.rev_in())
            .field("rev_out", &self.rev_out())
            .finish()
    }
}
#[cfg(feature = "defmt")]
impl defmt::Format for Cr {
    fn format(&self, f: defmt::Formatter) {
        defmt::write!(
            f,
            "Cr {{ reset: {=bool:?}, rev_in: {=u8:?}, rev_out: {=bool:?} }}",
            self.reset(),
            self.rev_in(),
            self.rev_out()
        )
    }
}
#[doc = "DR"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Dr(pub u32);
impl Dr {
    #[doc = "Data register"]
    #[must_use]
    #[inline(always)]
    pub const fn dr(&self) -> u32 {
        let val = (self.0 >> 0usize) & 0xffff_ffff;
        val as u32
    }
    #[doc = "Data register"]
    #[inline(always)]
    pub const fn set_dr(&mut self, val: u32) {
        self.0 = (self.0 & !(0xffff_ffff << 0usize)) | (((val as u32) & 0xffff_ffff) << 0usize);
    }
}
impl Default for Dr {
    #[inline(always)]
    fn default() -> Dr {
        Dr(0)
    }
}
impl core::fmt::Debug for Dr {
    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
        f.debug_struct("Dr").field("dr", &self.dr()).finish()
    }
}
#[cfg(feature = "defmt")]
impl defmt::Format for Dr {
    fn format(&self, f: defmt::Formatter) {
        defmt::write!(f, "Dr {{ dr: {=u32:?} }}", self.dr())
    }
}
#[doc = "IDR"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Idr(pub u32);
impl Idr {
    #[doc = "General purpose 8-bit data register"]
    #[must_use]
    #[inline(always)]
    pub const fn idr(&self) -> u8 {
        let val = (self.0 >> 0usize) & 0xff;
        val as u8
    }
    #[doc = "General purpose 8-bit data register"]
    #[inline(always)]
    pub const fn set_idr(&mut self, val: u8) {
        self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
    }
}
impl Default for Idr {
    #[inline(always)]
    fn default() -> Idr {
        Idr(0)
    }
}
impl core::fmt::Debug for Idr {
    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
        f.debug_struct("Idr").field("idr", &self.idr()).finish()
    }
}
#[cfg(feature = "defmt")]
impl defmt::Format for Idr {
    fn format(&self, f: defmt::Formatter) {
        defmt::write!(f, "Idr {{ idr: {=u8:?} }}", self.idr())
    }
}
#[doc = "INIT"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Init(pub u32);
impl Init {
    #[doc = "CRC initiate value"]
    #[must_use]
    #[inline(always)]
    pub const fn crc_init(&self) -> u32 {
        let val = (self.0 >> 0usize) & 0xffff_ffff;
        val as u32
    }
    #[doc = "CRC initiate value"]
    #[inline(always)]
    pub const fn set_crc_init(&mut self, val: u32) {
        self.0 = (self.0 & !(0xffff_ffff << 0usize)) | (((val as u32) & 0xffff_ffff) << 0usize);
    }
}
impl Default for Init {
    #[inline(always)]
    fn default() -> Init {
        Init(0)
    }
}
impl core::fmt::Debug for Init {
    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
        f.debug_struct("Init")
            .field("crc_init", &self.crc_init())
            .finish()
    }
}
#[cfg(feature = "defmt")]
impl defmt::Format for Init {
    fn format(&self, f: defmt::Formatter) {
        defmt::write!(f, "Init {{ crc_init: {=u32:?} }}", self.crc_init())
    }
}