#[doc = "Control Register"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Cr(pub u32);
impl Cr {
#[doc = "Watchdog Restart"]
#[must_use]
#[inline(always)]
pub const fn wdrstt(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Watchdog Restart"]
#[inline(always)]
pub const fn set_wdrstt(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Password."]
#[must_use]
#[inline(always)]
pub const fn key(&self) -> super::vals::Key {
let val = (self.0 >> 24usize) & 0xff;
super::vals::Key::from_bits(val as u8)
}
#[doc = "Password."]
#[inline(always)]
pub const fn set_key(&mut self, val: super::vals::Key) {
self.0 = (self.0 & !(0xff << 24usize)) | (((val.to_bits() as u32) & 0xff) << 24usize);
}
}
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("wdrstt", &self.wdrstt())
.field("key", &self.key())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Cr {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Cr {{ wdrstt: {=bool:?}, key: {:?} }}",
self.wdrstt(),
self.key()
)
}
}
#[doc = "Mode Register"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Mr(pub u32);
impl Mr {
#[doc = "Watchdog Counter Value"]
#[must_use]
#[inline(always)]
pub const fn wdv(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x0fff;
val as u16
}
#[doc = "Watchdog Counter Value"]
#[inline(always)]
pub const fn set_wdv(&mut self, val: u16) {
self.0 = (self.0 & !(0x0fff << 0usize)) | (((val as u32) & 0x0fff) << 0usize);
}
#[doc = "Watchdog Fault Interrupt Enable"]
#[must_use]
#[inline(always)]
pub const fn wdfien(&self) -> bool {
let val = (self.0 >> 12usize) & 0x01;
val != 0
}
#[doc = "Watchdog Fault Interrupt Enable"]
#[inline(always)]
pub const fn set_wdfien(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 12usize)) | (((val as u32) & 0x01) << 12usize);
}
#[doc = "Watchdog Reset Enable"]
#[must_use]
#[inline(always)]
pub const fn wdrsten(&self) -> bool {
let val = (self.0 >> 13usize) & 0x01;
val != 0
}
#[doc = "Watchdog Reset Enable"]
#[inline(always)]
pub const fn set_wdrsten(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 13usize)) | (((val as u32) & 0x01) << 13usize);
}
#[doc = "Watchdog Reset Processor"]
#[must_use]
#[inline(always)]
pub const fn wdrproc(&self) -> bool {
let val = (self.0 >> 14usize) & 0x01;
val != 0
}
#[doc = "Watchdog Reset Processor"]
#[inline(always)]
pub const fn set_wdrproc(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 14usize)) | (((val as u32) & 0x01) << 14usize);
}
#[doc = "Watchdog Disable"]
#[must_use]
#[inline(always)]
pub const fn wddis(&self) -> bool {
let val = (self.0 >> 15usize) & 0x01;
val != 0
}
#[doc = "Watchdog Disable"]
#[inline(always)]
pub const fn set_wddis(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 15usize)) | (((val as u32) & 0x01) << 15usize);
}
#[doc = "Watchdog Delta Value"]
#[must_use]
#[inline(always)]
pub const fn wdd(&self) -> u16 {
let val = (self.0 >> 16usize) & 0x0fff;
val as u16
}
#[doc = "Watchdog Delta Value"]
#[inline(always)]
pub const fn set_wdd(&mut self, val: u16) {
self.0 = (self.0 & !(0x0fff << 16usize)) | (((val as u32) & 0x0fff) << 16usize);
}
#[doc = "Watchdog Debug Halt"]
#[must_use]
#[inline(always)]
pub const fn wddbghlt(&self) -> bool {
let val = (self.0 >> 28usize) & 0x01;
val != 0
}
#[doc = "Watchdog Debug Halt"]
#[inline(always)]
pub const fn set_wddbghlt(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 28usize)) | (((val as u32) & 0x01) << 28usize);
}
#[doc = "Watchdog Idle Halt"]
#[must_use]
#[inline(always)]
pub const fn wdidlehlt(&self) -> bool {
let val = (self.0 >> 29usize) & 0x01;
val != 0
}
#[doc = "Watchdog Idle Halt"]
#[inline(always)]
pub const fn set_wdidlehlt(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 29usize)) | (((val as u32) & 0x01) << 29usize);
}
}
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("wdv", &self.wdv())
.field("wdfien", &self.wdfien())
.field("wdrsten", &self.wdrsten())
.field("wdrproc", &self.wdrproc())
.field("wddis", &self.wddis())
.field("wdd", &self.wdd())
.field("wddbghlt", &self.wddbghlt())
.field("wdidlehlt", &self.wdidlehlt())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Mr {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Mr {{ wdv: {=u16:?}, wdfien: {=bool:?}, wdrsten: {=bool:?}, wdrproc: {=bool:?}, wddis: {=bool:?}, wdd: {=u16:?}, wddbghlt: {=bool:?}, wdidlehlt: {=bool:?} }}",
self.wdv(),
self.wdfien(),
self.wdrsten(),
self.wdrproc(),
self.wddis(),
self.wdd(),
self.wddbghlt(),
self.wdidlehlt()
)
}
}
#[doc = "Status Register"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Sr(pub u32);
impl Sr {
#[doc = "Watchdog Underflow"]
#[must_use]
#[inline(always)]
pub const fn wdunf(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Watchdog Underflow"]
#[inline(always)]
pub const fn set_wdunf(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Watchdog Error"]
#[must_use]
#[inline(always)]
pub const fn wderr(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Watchdog Error"]
#[inline(always)]
pub const fn set_wderr(&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("wdunf", &self.wdunf())
.field("wderr", &self.wderr())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Sr {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Sr {{ wdunf: {=bool:?}, wderr: {=bool:?} }}",
self.wdunf(),
self.wderr()
)
}
}