#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum MmrMot {
#[doc = "Mailbox is disabled. This prevents receiving or transmitting any messages with this mailbox."]
MB_DISABLED = 0x0,
#[doc = "Reception Mailbox. Mailbox is configured for reception. If a message is received while the mailbox data register is full, it is discarded."]
MB_RX = 0x01,
#[doc = "Reception mailbox with overwrite. Mailbox is configured for reception. If a message is received while the mailbox is full, it overwrites the previous message."]
MB_RX_OVERWRITE = 0x02,
#[doc = "Transmit mailbox. Mailbox is configured for transmission."]
MB_TX = 0x03,
#[doc = "Consumer Mailbox. Mailbox is configured in reception but behaves as a Transmit Mailbox, i.e., it sends a remote frame and waits for an answer."]
MB_CONSUMER = 0x04,
#[doc = "Producer Mailbox. Mailbox is configured in transmission but also behaves like a reception mailbox, i.e., it waits to receive a Remote Frame before sending its contents."]
MB_PRODUCER = 0x05,
_RESERVED_6 = 0x06,
_RESERVED_7 = 0x07,
}
impl MmrMot {
#[inline(always)]
pub const fn from_bits(val: u8) -> MmrMot {
unsafe { core::mem::transmute(val & 0x07) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for MmrMot {
#[inline(always)]
fn from(val: u8) -> MmrMot {
MmrMot::from_bits(val)
}
}
impl From<MmrMot> for u8 {
#[inline(always)]
fn from(val: MmrMot) -> u8 {
MmrMot::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Rxsync {
#[doc = "Rx Signal with Double Synchro Stages (2 Positive Edges)"]
DOUBLE_PP = 0x0,
#[doc = "Rx Signal with Double Synchro Stages (One Positive Edge and One Negative Edge)"]
DOUBLE_PN = 0x01,
#[doc = "Rx Signal with Single Synchro Stage (Positive Edge)"]
SINGLE_P = 0x02,
#[doc = "Rx Signal with No Synchro Stage"]
NONE = 0x03,
_RESERVED_4 = 0x04,
_RESERVED_5 = 0x05,
_RESERVED_6 = 0x06,
_RESERVED_7 = 0x07,
}
impl Rxsync {
#[inline(always)]
pub const fn from_bits(val: u8) -> Rxsync {
unsafe { core::mem::transmute(val & 0x07) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Rxsync {
#[inline(always)]
fn from(val: u8) -> Rxsync {
Rxsync::from_bits(val)
}
}
impl From<Rxsync> for u8 {
#[inline(always)]
fn from(val: Rxsync) -> u8 {
Rxsync::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Smp {
#[doc = "The incoming bit stream is sampled once at sample point."]
ONCE = 0x0,
#[doc = "The incoming bit stream is sampled three times with a period of a MCK clock period, centered on sample point."]
THREE = 0x01,
}
impl Smp {
#[inline(always)]
pub const fn from_bits(val: u8) -> Smp {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Smp {
#[inline(always)]
fn from(val: u8) -> Smp {
Smp::from_bits(val)
}
}
impl From<Smp> for u8 {
#[inline(always)]
fn from(val: Smp) -> u8 {
Smp::to_bits(val)
}
}
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct WpKey(u32);
impl WpKey {
pub const PASSWD: Self = Self(0x0043_414e);
}
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 {
0x0043_414e => 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 {
0x0043_414e => 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)
}
}