#[doc = "CR"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Cr(pub u32);
impl Cr {
#[doc = "Low-power Stop/ Low Power Sleep/Low-power run"]
#[must_use]
#[inline(always)]
pub const fn lpsdsr(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Low-power Stop/ Low Power Sleep/Low-power run"]
#[inline(always)]
pub const fn set_lpsdsr(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Power voltage detector enable"]
#[must_use]
#[inline(always)]
pub const fn pvde(&self) -> bool {
let val = (self.0 >> 4usize) & 0x01;
val != 0
}
#[doc = "Power voltage detector enable"]
#[inline(always)]
pub const fn set_pvde(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
}
#[doc = "PVD level selection"]
#[must_use]
#[inline(always)]
pub const fn pls(&self) -> u8 {
let val = (self.0 >> 5usize) & 0x07;
val as u8
}
#[doc = "PVD level selection"]
#[inline(always)]
pub const fn set_pls(&mut self, val: u8) {
self.0 = (self.0 & !(0x07 << 5usize)) | (((val as u32) & 0x07) << 5usize);
}
#[doc = "Disable backup write protection"]
#[must_use]
#[inline(always)]
pub const fn dbp(&self) -> bool {
let val = (self.0 >> 8usize) & 0x01;
val != 0
}
#[doc = "Disable backup write protection"]
#[inline(always)]
pub const fn set_dbp(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize);
}
#[doc = "Ultra-low-power mode"]
#[must_use]
#[inline(always)]
pub const fn ulp(&self) -> bool {
let val = (self.0 >> 9usize) & 0x01;
val != 0
}
#[doc = "Ultra-low-power mode"]
#[inline(always)]
pub const fn set_ulp(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 9usize)) | (((val as u32) & 0x01) << 9usize);
}
#[doc = "Voltage scaling range selection"]
#[must_use]
#[inline(always)]
pub const fn vos(&self) -> u8 {
let val = (self.0 >> 11usize) & 0x03;
val as u8
}
#[doc = "Voltage scaling range selection"]
#[inline(always)]
pub const fn set_vos(&mut self, val: u8) {
self.0 = (self.0 & !(0x03 << 11usize)) | (((val as u32) & 0x03) << 11usize);
}
#[doc = "Flash Reset control"]
#[must_use]
#[inline(always)]
pub const fn flashdpd(&self) -> bool {
let val = (self.0 >> 13usize) & 0x01;
val != 0
}
#[doc = "Flash Reset control"]
#[inline(always)]
pub const fn set_flashdpd(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 13usize)) | (((val as u32) & 0x01) << 13usize);
}
#[doc = "Low-power run mode"]
#[must_use]
#[inline(always)]
pub const fn lprun(&self) -> bool {
let val = (self.0 >> 14usize) & 0x01;
val != 0
}
#[doc = "Low-power run mode"]
#[inline(always)]
pub const fn set_lprun(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 14usize)) | (((val as u32) & 0x01) << 14usize);
}
}
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("lpsdsr", &self.lpsdsr())
.field("pvde", &self.pvde())
.field("pls", &self.pls())
.field("dbp", &self.dbp())
.field("ulp", &self.ulp())
.field("vos", &self.vos())
.field("flashdpd", &self.flashdpd())
.field("lprun", &self.lprun())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Cr {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Cr {{ lpsdsr: {=bool:?}, pvde: {=bool:?}, pls: {=u8:?}, dbp: {=bool:?}, ulp: {=bool:?}, vos: {=u8:?}, flashdpd: {=bool:?}, lprun: {=bool:?} }}" , self . lpsdsr () , self . pvde () , self . pls () , self . dbp () , self . ulp () , self . vos () , self . flashdpd () , self . lprun ())
}
}
#[doc = "CSR"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Csr(pub u32);
impl Csr {
#[doc = "PVD output"]
#[must_use]
#[inline(always)]
pub const fn pvdo(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "PVD output"]
#[inline(always)]
pub const fn set_pvdo(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "Internal voltage reference ready flag"]
#[must_use]
#[inline(always)]
pub const fn vrefintrdyf(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "Internal voltage reference ready flag"]
#[inline(always)]
pub const fn set_vrefintrdyf(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
#[doc = "Power on fail flag"]
#[must_use]
#[inline(always)]
pub const fn flash_por_fail_flag(&self) -> bool {
let val = (self.0 >> 7usize) & 0x01;
val != 0
}
#[doc = "Power on fail flag"]
#[inline(always)]
pub const fn set_flash_por_fail_flag(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize);
}
}
impl Default for Csr {
#[inline(always)]
fn default() -> Csr {
Csr(0)
}
}
impl core::fmt::Debug for Csr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Csr")
.field("pvdo", &self.pvdo())
.field("vrefintrdyf", &self.vrefintrdyf())
.field("flash_por_fail_flag", &self.flash_por_fail_flag())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Csr {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Csr {{ pvdo: {=bool:?}, vrefintrdyf: {=bool:?}, flash_por_fail_flag: {=bool:?} }}",
self.pvdo(),
self.vrefintrdyf(),
self.flash_por_fail_flag()
)
}
}
#[doc = "LVD_CFGR"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct LvdCfgr(pub u32);
impl LvdCfgr {
#[doc = "PVD input voltage source selection"]
#[must_use]
#[inline(always)]
pub const fn pvd_det_sel(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x03;
val as u8
}
#[doc = "PVD input voltage source selection"]
#[inline(always)]
pub const fn set_pvd_det_sel(&mut self, val: u8) {
self.0 = (self.0 & !(0x03 << 0usize)) | (((val as u32) & 0x03) << 0usize);
}
#[doc = "BOR level selection"]
#[must_use]
#[inline(always)]
pub const fn bor_cfg(&self) -> u8 {
let val = (self.0 >> 8usize) & 0x07;
val as u8
}
#[doc = "BOR level selection"]
#[inline(always)]
pub const fn set_bor_cfg(&mut self, val: u8) {
self.0 = (self.0 & !(0x07 << 8usize)) | (((val as u32) & 0x07) << 8usize);
}
#[doc = "BOR function enable"]
#[must_use]
#[inline(always)]
pub const fn bor_pd(&self) -> bool {
let val = (self.0 >> 12usize) & 0x01;
val != 0
}
#[doc = "BOR function enable"]
#[inline(always)]
pub const fn set_bor_pd(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 12usize)) | (((val as u32) & 0x01) << 12usize);
}
}
impl Default for LvdCfgr {
#[inline(always)]
fn default() -> LvdCfgr {
LvdCfgr(0)
}
}
impl core::fmt::Debug for LvdCfgr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("LvdCfgr")
.field("pvd_det_sel", &self.pvd_det_sel())
.field("bor_cfg", &self.bor_cfg())
.field("bor_pd", &self.bor_pd())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for LvdCfgr {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"LvdCfgr {{ pvd_det_sel: {=u8:?}, bor_cfg: {=u8:?}, bor_pd: {=bool:?} }}",
self.pvd_det_sel(),
self.bor_cfg(),
self.bor_pd()
)
}
}
#[doc = "VOS_CFG_KEY"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct VosCfgKey(pub u32);
impl VosCfgKey {
#[doc = "VOS Key"]
#[must_use]
#[inline(always)]
pub const fn vos_cfg_key(&self) -> u16 {
let val = (self.0 >> 0usize) & 0xffff;
val as u16
}
#[doc = "VOS Key"]
#[inline(always)]
pub const fn set_vos_cfg_key(&mut self, val: u16) {
self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize);
}
}
impl Default for VosCfgKey {
#[inline(always)]
fn default() -> VosCfgKey {
VosCfgKey(0)
}
}
impl core::fmt::Debug for VosCfgKey {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("VosCfgKey")
.field("vos_cfg_key", &self.vos_cfg_key())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for VosCfgKey {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"VosCfgKey {{ vos_cfg_key: {=u16:?} }}",
self.vos_cfg_key()
)
}
}