#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Bits {
#[doc = "8 bits for transfer"]
_8_BIT = 0x0,
#[doc = "9 bits for transfer"]
_9_BIT = 0x01,
#[doc = "10 bits for transfer"]
_10_BIT = 0x02,
#[doc = "11 bits for transfer"]
_11_BIT = 0x03,
#[doc = "12 bits for transfer"]
_12_BIT = 0x04,
#[doc = "13 bits for transfer"]
_13_BIT = 0x05,
#[doc = "14 bits for transfer"]
_14_BIT = 0x06,
#[doc = "15 bits for transfer"]
_15_BIT = 0x07,
#[doc = "16 bits for transfer"]
_16_BIT = 0x08,
_RESERVED_9 = 0x09,
_RESERVED_a = 0x0a,
_RESERVED_b = 0x0b,
_RESERVED_c = 0x0c,
_RESERVED_d = 0x0d,
_RESERVED_e = 0x0e,
_RESERVED_f = 0x0f,
}
impl Bits {
#[inline(always)]
pub const fn from_bits(val: u8) -> Bits {
unsafe { core::mem::transmute(val & 0x0f) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Bits {
#[inline(always)]
fn from(val: u8) -> Bits {
Bits::from_bits(val)
}
}
impl From<Bits> for u8 {
#[inline(always)]
fn from(val: Bits) -> u8 {
Bits::to_bits(val)
}
}
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct Wpkey(u32);
impl Wpkey {
#[doc = "Writing any other value in this field aborts the write operation of the WPEN bit.Always reads as 0."]
pub const PASSWD: Self = Self(0x0053_5049);
}
impl Wpkey {
pub const fn from_bits(val: u32) -> Wpkey {
Self(val & 0x00ff_ffff)
}
pub const fn to_bits(self) -> u32 {
self.0
}
}
impl core::fmt::Debug for Wpkey {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self.0 {
0x0053_5049 => f.write_str("PASSWD"),
other => core::write!(f, "0x{:02X}", other),
}
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Wpkey {
fn format(&self, f: defmt::Formatter) {
match self.0 {
0x0053_5049 => defmt::write!(f, "PASSWD"),
other => defmt::write!(f, "0x{:02X}", other),
}
}
}
impl From<u32> for Wpkey {
#[inline(always)]
fn from(val: u32) -> Wpkey {
Wpkey::from_bits(val)
}
}
impl From<Wpkey> for u32 {
#[inline(always)]
fn from(val: Wpkey) -> u32 {
Wpkey::to_bits(val)
}
}