#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Div {
#[doc = "Peripheral clock is MCK"]
PERIPH_DIV_MCK = 0x0,
#[doc = "Peripheral clock is MCK/2"]
PERIPH_DIV2_MCK = 0x01,
#[doc = "Peripheral clock is MCK/4"]
PERIPH_DIV4_MCK = 0x02,
_RESERVED_3 = 0x03,
}
impl Div {
#[inline(always)]
pub const fn from_bits(val: u8) -> Div {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Div {
#[inline(always)]
fn from(val: u8) -> Div {
Div::from_bits(val)
}
}
impl From<Div> for u8 {
#[inline(always)]
fn from(val: Div) -> u8 {
Div::to_bits(val)
}
}
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct Key(u8);
impl Key {
#[doc = "Writing any other value in this field aborts the write operation.Always reads as 0."]
pub const PASSWD: Self = Self(0x37);
}
impl Key {
pub const fn from_bits(val: u8) -> Key {
Self(val & 0xff)
}
pub const fn to_bits(self) -> u8 {
self.0
}
}
impl core::fmt::Debug for Key {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self.0 {
0x37 => f.write_str("PASSWD"),
other => core::write!(f, "0x{:02X}", other),
}
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Key {
fn format(&self, f: defmt::Formatter) {
match self.0 {
0x37 => defmt::write!(f, "PASSWD"),
other => defmt::write!(f, "0x{:02X}", other),
}
}
}
impl From<u8> for Key {
#[inline(always)]
fn from(val: u8) -> Key {
Key::from_bits(val)
}
}
impl From<Key> for u8 {
#[inline(always)]
fn from(val: Key) -> u8 {
Key::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Moscrcf {
#[doc = "The Fast RC Oscillator Frequency is at 4 MHz (default)"]
_4_MHZ = 0x0,
#[doc = "The Fast RC Oscillator Frequency is at 8 MHz"]
_8_MHZ = 0x01,
#[doc = "The Fast RC Oscillator Frequency is at 12 MHz"]
_12_MHZ = 0x02,
_RESERVED_3 = 0x03,
_RESERVED_4 = 0x04,
_RESERVED_5 = 0x05,
_RESERVED_6 = 0x06,
_RESERVED_7 = 0x07,
}
impl Moscrcf {
#[inline(always)]
pub const fn from_bits(val: u8) -> Moscrcf {
unsafe { core::mem::transmute(val & 0x07) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Moscrcf {
#[inline(always)]
fn from(val: u8) -> Moscrcf {
Moscrcf::from_bits(val)
}
}
impl From<Moscrcf> for u8 {
#[inline(always)]
fn from(val: Moscrcf) -> u8 {
Moscrcf::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum PmcMckrCss {
#[doc = "Slow Clock is selected"]
SLOW_CLK = 0x0,
#[doc = "Main Clock is selected"]
MAIN_CLK = 0x01,
#[doc = "PLLA Clock is selected"]
PLLA_CLK = 0x02,
#[doc = "UPLL Clock is selected"]
UPLL_CLK = 0x03,
}
impl PmcMckrCss {
#[inline(always)]
pub const fn from_bits(val: u8) -> PmcMckrCss {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for PmcMckrCss {
#[inline(always)]
fn from(val: u8) -> PmcMckrCss {
PmcMckrCss::from_bits(val)
}
}
impl From<PmcMckrCss> for u8 {
#[inline(always)]
fn from(val: PmcMckrCss) -> u8 {
PmcMckrCss::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum PmcMckrPres {
#[doc = "Selected clock"]
CLK_1 = 0x0,
#[doc = "Selected clock divided by 2"]
CLK_2 = 0x01,
#[doc = "Selected clock divided by 4"]
CLK_4 = 0x02,
#[doc = "Selected clock divided by 8"]
CLK_8 = 0x03,
#[doc = "Selected clock divided by 16"]
CLK_16 = 0x04,
#[doc = "Selected clock divided by 32"]
CLK_32 = 0x05,
#[doc = "Selected clock divided by 64"]
CLK_64 = 0x06,
#[doc = "Selected clock divided by 3"]
CLK_3 = 0x07,
}
impl PmcMckrPres {
#[inline(always)]
pub const fn from_bits(val: u8) -> PmcMckrPres {
unsafe { core::mem::transmute(val & 0x07) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for PmcMckrPres {
#[inline(always)]
fn from(val: u8) -> PmcMckrPres {
PmcMckrPres::from_bits(val)
}
}
impl From<PmcMckrPres> for u8 {
#[inline(always)]
fn from(val: PmcMckrPres) -> u8 {
PmcMckrPres::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum PmcPckCss {
#[doc = "Slow Clock is selected"]
SLOW_CLK = 0x0,
#[doc = "Main Clock is selected"]
MAIN_CLK = 0x01,
#[doc = "PLLA Clock is selected"]
PLLA_CLK = 0x02,
#[doc = "UPLL Clock is selected"]
UPLL_CLK = 0x03,
#[doc = "Master Clock is selected"]
MCK = 0x04,
_RESERVED_5 = 0x05,
_RESERVED_6 = 0x06,
_RESERVED_7 = 0x07,
}
impl PmcPckCss {
#[inline(always)]
pub const fn from_bits(val: u8) -> PmcPckCss {
unsafe { core::mem::transmute(val & 0x07) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for PmcPckCss {
#[inline(always)]
fn from(val: u8) -> PmcPckCss {
PmcPckCss::from_bits(val)
}
}
impl From<PmcPckCss> for u8 {
#[inline(always)]
fn from(val: PmcPckCss) -> u8 {
PmcPckCss::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum PmcPckPres {
#[doc = "Selected clock"]
CLK_1 = 0x0,
#[doc = "Selected clock divided by 2"]
CLK_2 = 0x01,
#[doc = "Selected clock divided by 4"]
CLK_4 = 0x02,
#[doc = "Selected clock divided by 8"]
CLK_8 = 0x03,
#[doc = "Selected clock divided by 16"]
CLK_16 = 0x04,
#[doc = "Selected clock divided by 32"]
CLK_32 = 0x05,
#[doc = "Selected clock divided by 64"]
CLK_64 = 0x06,
_RESERVED_7 = 0x07,
}
impl PmcPckPres {
#[inline(always)]
pub const fn from_bits(val: u8) -> PmcPckPres {
unsafe { core::mem::transmute(val & 0x07) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for PmcPckPres {
#[inline(always)]
fn from(val: u8) -> PmcPckPres {
PmcPckPres::from_bits(val)
}
}
impl From<PmcPckPres> for u8 {
#[inline(always)]
fn from(val: PmcPckPres) -> u8 {
PmcPckPres::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(0x0050_4d43);
}
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 {
0x0050_4d43 => 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 {
0x0050_4d43 => 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)
}
}