Skip to main content

mcxa_pac/lpi2c0/
srdror.rs

1#[doc = "Register `SRDROR` reader"]
2pub type R = crate::R<SrdrorSpec>;
3#[doc = "Field `DATA` reader - Receive Data"]
4pub type DataR = crate::FieldReader;
5#[doc = "Field `RADDR` reader - Received Address"]
6pub type RaddrR = crate::FieldReader;
7#[doc = "Receive Empty\n\nValue on reset: 1"]
8#[cfg_attr(feature = "defmt", derive(defmt::Format))]
9#[derive(Clone, Copy, Debug, PartialEq, Eq)]
10pub enum Rxempty {
11    #[doc = "0: Not empty"]
12    NotEmpty = 0,
13    #[doc = "1: Empty"]
14    Empty = 1,
15}
16impl From<Rxempty> for bool {
17    #[inline(always)]
18    fn from(variant: Rxempty) -> Self {
19        variant as u8 != 0
20    }
21}
22#[doc = "Field `RXEMPTY` reader - Receive Empty"]
23pub type RxemptyR = crate::BitReader<Rxempty>;
24impl RxemptyR {
25    #[doc = "Get enumerated values variant"]
26    #[inline(always)]
27    pub const fn variant(&self) -> Rxempty {
28        match self.bits {
29            false => Rxempty::NotEmpty,
30            true => Rxempty::Empty,
31        }
32    }
33    #[doc = "Not empty"]
34    #[inline(always)]
35    pub fn is_not_empty(&self) -> bool {
36        *self == Rxempty::NotEmpty
37    }
38    #[doc = "Empty"]
39    #[inline(always)]
40    pub fn is_empty(&self) -> bool {
41        *self == Rxempty::Empty
42    }
43}
44#[doc = "Start of Frame\n\nValue on reset: 0"]
45#[cfg_attr(feature = "defmt", derive(defmt::Format))]
46#[derive(Clone, Copy, Debug, PartialEq, Eq)]
47pub enum Sof {
48    #[doc = "0: Not the first"]
49    NotFirstDataWord = 0,
50    #[doc = "1: First"]
51    FirstDataWord = 1,
52}
53impl From<Sof> for bool {
54    #[inline(always)]
55    fn from(variant: Sof) -> Self {
56        variant as u8 != 0
57    }
58}
59#[doc = "Field `SOF` reader - Start of Frame"]
60pub type SofR = crate::BitReader<Sof>;
61impl SofR {
62    #[doc = "Get enumerated values variant"]
63    #[inline(always)]
64    pub const fn variant(&self) -> Sof {
65        match self.bits {
66            false => Sof::NotFirstDataWord,
67            true => Sof::FirstDataWord,
68        }
69    }
70    #[doc = "Not the first"]
71    #[inline(always)]
72    pub fn is_not_first_data_word(&self) -> bool {
73        *self == Sof::NotFirstDataWord
74    }
75    #[doc = "First"]
76    #[inline(always)]
77    pub fn is_first_data_word(&self) -> bool {
78        *self == Sof::FirstDataWord
79    }
80}
81impl R {
82    #[doc = "Bits 0:7 - Receive Data"]
83    #[inline(always)]
84    pub fn data(&self) -> DataR {
85        DataR::new((self.bits & 0xff) as u8)
86    }
87    #[doc = "Bits 8:10 - Received Address"]
88    #[inline(always)]
89    pub fn raddr(&self) -> RaddrR {
90        RaddrR::new(((self.bits >> 8) & 7) as u8)
91    }
92    #[doc = "Bit 14 - Receive Empty"]
93    #[inline(always)]
94    pub fn rxempty(&self) -> RxemptyR {
95        RxemptyR::new(((self.bits >> 14) & 1) != 0)
96    }
97    #[doc = "Bit 15 - Start of Frame"]
98    #[inline(always)]
99    pub fn sof(&self) -> SofR {
100        SofR::new(((self.bits >> 15) & 1) != 0)
101    }
102}
103#[cfg(feature = "debug")]
104impl core::fmt::Debug for R {
105    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
106        f.debug_struct("SRDROR")
107            .field("data", &self.data())
108            .field("raddr", &self.raddr())
109            .field("rxempty", &self.rxempty())
110            .field("sof", &self.sof())
111            .finish()
112    }
113}
114#[doc = "Target Receive Data Read Only\n\nYou can [`read`](crate::Reg::read) this register and get [`srdror::R`](R). See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
115pub struct SrdrorSpec;
116impl crate::RegisterSpec for SrdrorSpec {
117    type Ux = u32;
118}
119#[doc = "`read()` method returns [`srdror::R`](R) reader structure"]
120impl crate::Readable for SrdrorSpec {}
121#[doc = "`reset()` method sets SRDROR to value 0x4000"]
122impl crate::Resettable for SrdrorSpec {
123    const RESET_VALUE: u32 = 0x4000;
124}