sam3x8e-pac 0.1.6-dev

Peripheral Access Crate (PAC) for the Atmel SAM3X8E.
#[doc = "Alarm Register"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Ar(pub u32);
impl Ar {
    #[doc = "Alarm Value"]
    #[must_use]
    #[inline(always)]
    pub const fn almv(&self) -> u32 {
        let val = (self.0 >> 0usize) & 0xffff_ffff;
        val as u32
    }
    #[doc = "Alarm Value"]
    #[inline(always)]
    pub const fn set_almv(&mut self, val: u32) {
        self.0 = (self.0 & !(0xffff_ffff << 0usize)) | (((val as u32) & 0xffff_ffff) << 0usize);
    }
}
impl Default for Ar {
    #[inline(always)]
    fn default() -> Ar {
        Ar(0)
    }
}
impl core::fmt::Debug for Ar {
    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
        f.debug_struct("Ar").field("almv", &self.almv()).finish()
    }
}
#[cfg(feature = "defmt")]
impl defmt::Format for Ar {
    fn format(&self, f: defmt::Formatter) {
        defmt::write!(f, "Ar {{ almv: {=u32:?} }}", self.almv())
    }
}
#[doc = "Mode Register"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Mr(pub u32);
impl Mr {
    #[doc = "Real-time Timer Prescaler Value"]
    #[must_use]
    #[inline(always)]
    pub const fn rtpres(&self) -> u16 {
        let val = (self.0 >> 0usize) & 0xffff;
        val as u16
    }
    #[doc = "Real-time Timer Prescaler Value"]
    #[inline(always)]
    pub const fn set_rtpres(&mut self, val: u16) {
        self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize);
    }
    #[doc = "Alarm Interrupt Enable"]
    #[must_use]
    #[inline(always)]
    pub const fn almien(&self) -> bool {
        let val = (self.0 >> 16usize) & 0x01;
        val != 0
    }
    #[doc = "Alarm Interrupt Enable"]
    #[inline(always)]
    pub const fn set_almien(&mut self, val: bool) {
        self.0 = (self.0 & !(0x01 << 16usize)) | (((val as u32) & 0x01) << 16usize);
    }
    #[doc = "Real-time Timer Increment Interrupt Enable"]
    #[must_use]
    #[inline(always)]
    pub const fn rttincien(&self) -> bool {
        let val = (self.0 >> 17usize) & 0x01;
        val != 0
    }
    #[doc = "Real-time Timer Increment Interrupt Enable"]
    #[inline(always)]
    pub const fn set_rttincien(&mut self, val: bool) {
        self.0 = (self.0 & !(0x01 << 17usize)) | (((val as u32) & 0x01) << 17usize);
    }
    #[doc = "Real-time Timer Restart"]
    #[must_use]
    #[inline(always)]
    pub const fn rttrst(&self) -> bool {
        let val = (self.0 >> 18usize) & 0x01;
        val != 0
    }
    #[doc = "Real-time Timer Restart"]
    #[inline(always)]
    pub const fn set_rttrst(&mut self, val: bool) {
        self.0 = (self.0 & !(0x01 << 18usize)) | (((val as u32) & 0x01) << 18usize);
    }
}
impl Default for Mr {
    #[inline(always)]
    fn default() -> Mr {
        Mr(0)
    }
}
impl core::fmt::Debug for Mr {
    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
        f.debug_struct("Mr")
            .field("rtpres", &self.rtpres())
            .field("almien", &self.almien())
            .field("rttincien", &self.rttincien())
            .field("rttrst", &self.rttrst())
            .finish()
    }
}
#[cfg(feature = "defmt")]
impl defmt::Format for Mr {
    fn format(&self, f: defmt::Formatter) {
        defmt::write!(
            f,
            "Mr {{ rtpres: {=u16:?}, almien: {=bool:?}, rttincien: {=bool:?}, rttrst: {=bool:?} }}",
            self.rtpres(),
            self.almien(),
            self.rttincien(),
            self.rttrst()
        )
    }
}
#[doc = "Status Register"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Sr(pub u32);
impl Sr {
    #[doc = "Real-time Alarm Status"]
    #[must_use]
    #[inline(always)]
    pub const fn alms(&self) -> bool {
        let val = (self.0 >> 0usize) & 0x01;
        val != 0
    }
    #[doc = "Real-time Alarm Status"]
    #[inline(always)]
    pub const fn set_alms(&mut self, val: bool) {
        self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
    }
    #[doc = "Real-time Timer Increment"]
    #[must_use]
    #[inline(always)]
    pub const fn rttinc(&self) -> bool {
        let val = (self.0 >> 1usize) & 0x01;
        val != 0
    }
    #[doc = "Real-time Timer Increment"]
    #[inline(always)]
    pub const fn set_rttinc(&mut self, val: bool) {
        self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
    }
}
impl Default for Sr {
    #[inline(always)]
    fn default() -> Sr {
        Sr(0)
    }
}
impl core::fmt::Debug for Sr {
    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
        f.debug_struct("Sr")
            .field("alms", &self.alms())
            .field("rttinc", &self.rttinc())
            .finish()
    }
}
#[cfg(feature = "defmt")]
impl defmt::Format for Sr {
    fn format(&self, f: defmt::Formatter) {
        defmt::write!(
            f,
            "Sr {{ alms: {=bool:?}, rttinc: {=bool:?} }}",
            self.alms(),
            self.rttinc()
        )
    }
}
#[doc = "Value Register"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Vr(pub u32);
impl Vr {
    #[doc = "Current Real-time Value"]
    #[must_use]
    #[inline(always)]
    pub const fn crtv(&self) -> u32 {
        let val = (self.0 >> 0usize) & 0xffff_ffff;
        val as u32
    }
    #[doc = "Current Real-time Value"]
    #[inline(always)]
    pub const fn set_crtv(&mut self, val: u32) {
        self.0 = (self.0 & !(0xffff_ffff << 0usize)) | (((val as u32) & 0xffff_ffff) << 0usize);
    }
}
impl Default for Vr {
    #[inline(always)]
    fn default() -> Vr {
        Vr(0)
    }
}
impl core::fmt::Debug for Vr {
    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
        f.debug_struct("Vr").field("crtv", &self.crtv()).finish()
    }
}
#[cfg(feature = "defmt")]
impl defmt::Format for Vr {
    fn format(&self, f: defmt::Formatter) {
        defmt::write!(f, "Vr {{ crtv: {=u32:?} }}", self.crtv())
    }
}