pub type R = crate::R<STATErs>;
pub type BusyR = crate::BitReader;
pub type MasterR = crate::BitReader;
pub type TransmitterR = crate::BitReader;
pub type NackedR = crate::BitReader;
pub type BusholdR = crate::BitReader;
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum STATE {
Idle = 0,
Wait = 1,
Start = 2,
Addr = 3,
Addrack = 4,
Data = 5,
Dataack = 6,
}
impl From<STATE> for u8 {
#[inline(always)]
fn from(variant: STATE) -> Self {
variant as _
}
}
impl crate::FieldSpec for STATE {
type Ux = u8;
}
impl crate::IsEnum for STATE {}
pub type StateR = crate::FieldReader<STATE>;
impl StateR {
#[inline(always)]
pub const fn variant(&self) -> Option<STATE> {
match self.bits {
0 => Some(STATE::Idle),
1 => Some(STATE::Wait),
2 => Some(STATE::Start),
3 => Some(STATE::Addr),
4 => Some(STATE::Addrack),
5 => Some(STATE::Data),
6 => Some(STATE::Dataack),
_ => None,
}
}
#[inline(always)]
pub fn is_idle(&self) -> bool {
*self == STATE::Idle
}
#[inline(always)]
pub fn is_wait(&self) -> bool {
*self == STATE::Wait
}
#[inline(always)]
pub fn is_start(&self) -> bool {
*self == STATE::Start
}
#[inline(always)]
pub fn is_addr(&self) -> bool {
*self == STATE::Addr
}
#[inline(always)]
pub fn is_addrack(&self) -> bool {
*self == STATE::Addrack
}
#[inline(always)]
pub fn is_data(&self) -> bool {
*self == STATE::Data
}
#[inline(always)]
pub fn is_dataack(&self) -> bool {
*self == STATE::Dataack
}
}
impl R {
#[inline(always)]
pub fn busy(&self) -> BusyR {
BusyR::new((self.bits & 1) != 0)
}
#[inline(always)]
pub fn master(&self) -> MasterR {
MasterR::new(((self.bits >> 1) & 1) != 0)
}
#[inline(always)]
pub fn transmitter(&self) -> TransmitterR {
TransmitterR::new(((self.bits >> 2) & 1) != 0)
}
#[inline(always)]
pub fn nacked(&self) -> NackedR {
NackedR::new(((self.bits >> 3) & 1) != 0)
}
#[inline(always)]
pub fn bushold(&self) -> BusholdR {
BusholdR::new(((self.bits >> 4) & 1) != 0)
}
#[inline(always)]
pub fn state(&self) -> StateR {
StateR::new(((self.bits >> 5) & 7) as u8)
}
}
impl core::fmt::Debug for R {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("STATE")
.field("busy", &self.busy())
.field("master", &self.master())
.field("transmitter", &self.transmitter())
.field("nacked", &self.nacked())
.field("bushold", &self.bushold())
.field("state", &self.state())
.finish()
}
}
pub struct STATErs;
impl crate::RegisterSpec for STATErs {
type Ux = u32;
}
impl crate::Readable for STATErs {}
impl crate::Resettable for STATErs {
const RESET_VALUE: u32 = 0x01;
}