#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct CrKey(u8);
impl CrKey {
#[doc = "Writing any other value in this field aborts the write operation."]
pub const PASSWD: Self = Self(0xa5);
}
impl CrKey {
pub const fn from_bits(val: u8) -> CrKey {
Self(val & 0xff)
}
pub const fn to_bits(self) -> u8 {
self.0
}
}
impl core::fmt::Debug for CrKey {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self.0 {
0xa5 => f.write_str("PASSWD"),
other => core::write!(f, "0x{:02X}", other),
}
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for CrKey {
fn format(&self, f: defmt::Formatter) {
match self.0 {
0xa5 => defmt::write!(f, "PASSWD"),
other => defmt::write!(f, "0x{:02X}", other),
}
}
}
impl From<u8> for CrKey {
#[inline(always)]
fn from(val: u8) -> CrKey {
CrKey::from_bits(val)
}
}
impl From<CrKey> for u8 {
#[inline(always)]
fn from(val: CrKey) -> u8 {
CrKey::to_bits(val)
}
}
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct MrKey(u8);
impl MrKey {
#[doc = "Writing any other value in this field aborts the write operation.Always reads as 0."]
pub const PASSWD: Self = Self(0xa5);
}
impl MrKey {
pub const fn from_bits(val: u8) -> MrKey {
Self(val & 0xff)
}
pub const fn to_bits(self) -> u8 {
self.0
}
}
impl core::fmt::Debug for MrKey {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self.0 {
0xa5 => f.write_str("PASSWD"),
other => core::write!(f, "0x{:02X}", other),
}
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for MrKey {
fn format(&self, f: defmt::Formatter) {
match self.0 {
0xa5 => defmt::write!(f, "PASSWD"),
other => defmt::write!(f, "0x{:02X}", other),
}
}
}
impl From<u8> for MrKey {
#[inline(always)]
fn from(val: u8) -> MrKey {
MrKey::from_bits(val)
}
}
impl From<MrKey> for u8 {
#[inline(always)]
fn from(val: MrKey) -> u8 {
MrKey::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Rsttyp {
#[doc = "First power-up Reset"]
GENERAL_RESET = 0x0,
#[doc = "Return from Backup Mode"]
BACKUP_RESET = 0x01,
#[doc = "Watchdog fault occurred"]
WATCHDOG_RESET = 0x02,
#[doc = "Processor reset required by the software"]
SOFTWARE_RESET = 0x03,
#[doc = "NRST pin detected low"]
USER_RESET = 0x04,
_RESERVED_5 = 0x05,
_RESERVED_6 = 0x06,
_RESERVED_7 = 0x07,
}
impl Rsttyp {
#[inline(always)]
pub const fn from_bits(val: u8) -> Rsttyp {
unsafe { core::mem::transmute(val & 0x07) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Rsttyp {
#[inline(always)]
fn from(val: u8) -> Rsttyp {
Rsttyp::from_bits(val)
}
}
impl From<Rsttyp> for u8 {
#[inline(always)]
fn from(val: Rsttyp) -> u8 {
Rsttyp::to_bits(val)
}
}