#[doc = "Control Register"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Cr(pub u32);
impl Cr {
#[doc = "Processor Reset"]
#[must_use]
#[inline(always)]
pub const fn procrst(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Processor Reset"]
#[inline(always)]
pub const fn set_procrst(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Peripheral Reset"]
#[must_use]
#[inline(always)]
pub const fn perrst(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Peripheral Reset"]
#[inline(always)]
pub const fn set_perrst(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "External Reset"]
#[must_use]
#[inline(always)]
pub const fn extrst(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "External Reset"]
#[inline(always)]
pub const fn set_extrst(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
#[doc = "System Reset Key"]
#[must_use]
#[inline(always)]
pub const fn key(&self) -> super::vals::CrKey {
let val = (self.0 >> 24usize) & 0xff;
super::vals::CrKey::from_bits(val as u8)
}
#[doc = "System Reset Key"]
#[inline(always)]
pub const fn set_key(&mut self, val: super::vals::CrKey) {
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("procrst", &self.procrst())
.field("perrst", &self.perrst())
.field("extrst", &self.extrst())
.field("key", &self.key())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Cr {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Cr {{ procrst: {=bool:?}, perrst: {=bool:?}, extrst: {=bool:?}, key: {:?} }}",
self.procrst(),
self.perrst(),
self.extrst(),
self.key()
)
}
}
#[doc = "Mode Register"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Mr(pub u32);
impl Mr {
#[doc = "User Reset Enable"]
#[must_use]
#[inline(always)]
pub const fn ursten(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "User Reset Enable"]
#[inline(always)]
pub const fn set_ursten(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "User Reset Interrupt Enable"]
#[must_use]
#[inline(always)]
pub const fn urstien(&self) -> bool {
let val = (self.0 >> 4usize) & 0x01;
val != 0
}
#[doc = "User Reset Interrupt Enable"]
#[inline(always)]
pub const fn set_urstien(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
}
#[doc = "External Reset Length"]
#[must_use]
#[inline(always)]
pub const fn erstl(&self) -> u8 {
let val = (self.0 >> 8usize) & 0x0f;
val as u8
}
#[doc = "External Reset Length"]
#[inline(always)]
pub const fn set_erstl(&mut self, val: u8) {
self.0 = (self.0 & !(0x0f << 8usize)) | (((val as u32) & 0x0f) << 8usize);
}
#[doc = "Write Access Password"]
#[must_use]
#[inline(always)]
pub const fn key(&self) -> super::vals::MrKey {
let val = (self.0 >> 24usize) & 0xff;
super::vals::MrKey::from_bits(val as u8)
}
#[doc = "Write Access Password"]
#[inline(always)]
pub const fn set_key(&mut self, val: super::vals::MrKey) {
self.0 = (self.0 & !(0xff << 24usize)) | (((val.to_bits() as u32) & 0xff) << 24usize);
}
}
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("ursten", &self.ursten())
.field("urstien", &self.urstien())
.field("erstl", &self.erstl())
.field("key", &self.key())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Mr {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Mr {{ ursten: {=bool:?}, urstien: {=bool:?}, erstl: {=u8:?}, key: {:?} }}",
self.ursten(),
self.urstien(),
self.erstl(),
self.key()
)
}
}
#[doc = "Status Register"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Sr(pub u32);
impl Sr {
#[doc = "User Reset Status"]
#[must_use]
#[inline(always)]
pub const fn ursts(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "User Reset Status"]
#[inline(always)]
pub const fn set_ursts(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Reset Type"]
#[must_use]
#[inline(always)]
pub const fn rsttyp(&self) -> super::vals::Rsttyp {
let val = (self.0 >> 8usize) & 0x07;
super::vals::Rsttyp::from_bits(val as u8)
}
#[doc = "Reset Type"]
#[inline(always)]
pub const fn set_rsttyp(&mut self, val: super::vals::Rsttyp) {
self.0 = (self.0 & !(0x07 << 8usize)) | (((val.to_bits() as u32) & 0x07) << 8usize);
}
#[doc = "NRST Pin Level"]
#[must_use]
#[inline(always)]
pub const fn nrstl(&self) -> bool {
let val = (self.0 >> 16usize) & 0x01;
val != 0
}
#[doc = "NRST Pin Level"]
#[inline(always)]
pub const fn set_nrstl(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 16usize)) | (((val as u32) & 0x01) << 16usize);
}
#[doc = "Software Reset Command in Progress"]
#[must_use]
#[inline(always)]
pub const fn srcmp(&self) -> bool {
let val = (self.0 >> 17usize) & 0x01;
val != 0
}
#[doc = "Software Reset Command in Progress"]
#[inline(always)]
pub const fn set_srcmp(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 17usize)) | (((val as u32) & 0x01) << 17usize);
}
}
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("ursts", &self.ursts())
.field("rsttyp", &self.rsttyp())
.field("nrstl", &self.nrstl())
.field("srcmp", &self.srcmp())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Sr {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Sr {{ ursts: {=bool:?}, rsttyp: {:?}, nrstl: {=bool:?}, srcmp: {=bool:?} }}",
self.ursts(),
self.rsttyp(),
self.nrstl(),
self.srcmp()
)
}
}