avr_device/devices/atmega4809/twi0/
mstatus.rs1#[doc = "Register `MSTATUS` reader"]
2pub struct R(crate::R<MSTATUS_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<MSTATUS_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<MSTATUS_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<MSTATUS_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `MSTATUS` writer"]
17pub struct W(crate::W<MSTATUS_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<MSTATUS_SPEC>;
20 #[inline(always)]
21 fn deref(&self) -> &Self::Target {
22 &self.0
23 }
24}
25impl core::ops::DerefMut for W {
26 #[inline(always)]
27 fn deref_mut(&mut self) -> &mut Self::Target {
28 &mut self.0
29 }
30}
31impl From<crate::W<MSTATUS_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<MSTATUS_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `BUSSTATE` reader - Bus State"]
38pub type BUSSTATE_R = crate::FieldReader<u8, BUSSTATE_A>;
39#[doc = "Bus State\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum BUSSTATE_A {
43 #[doc = "0: Unknown Bus State"]
44 UNKNOWN = 0,
45 #[doc = "1: Bus is Idle"]
46 IDLE = 1,
47 #[doc = "2: This Module Controls The Bus"]
48 OWNER = 2,
49 #[doc = "3: The Bus is Busy"]
50 BUSY = 3,
51}
52impl From<BUSSTATE_A> for u8 {
53 #[inline(always)]
54 fn from(variant: BUSSTATE_A) -> Self {
55 variant as _
56 }
57}
58impl BUSSTATE_R {
59 #[doc = "Get enumerated values variant"]
60 #[inline(always)]
61 pub fn variant(&self) -> BUSSTATE_A {
62 match self.bits {
63 0 => BUSSTATE_A::UNKNOWN,
64 1 => BUSSTATE_A::IDLE,
65 2 => BUSSTATE_A::OWNER,
66 3 => BUSSTATE_A::BUSY,
67 _ => unreachable!(),
68 }
69 }
70 #[doc = "Checks if the value of the field is `UNKNOWN`"]
71 #[inline(always)]
72 pub fn is_unknown(&self) -> bool {
73 *self == BUSSTATE_A::UNKNOWN
74 }
75 #[doc = "Checks if the value of the field is `IDLE`"]
76 #[inline(always)]
77 pub fn is_idle(&self) -> bool {
78 *self == BUSSTATE_A::IDLE
79 }
80 #[doc = "Checks if the value of the field is `OWNER`"]
81 #[inline(always)]
82 pub fn is_owner(&self) -> bool {
83 *self == BUSSTATE_A::OWNER
84 }
85 #[doc = "Checks if the value of the field is `BUSY`"]
86 #[inline(always)]
87 pub fn is_busy(&self) -> bool {
88 *self == BUSSTATE_A::BUSY
89 }
90}
91#[doc = "Field `BUSSTATE` writer - Bus State"]
92pub type BUSSTATE_W<'a, const O: u8> =
93 crate::FieldWriterSafe<'a, u8, MSTATUS_SPEC, u8, BUSSTATE_A, 2, O>;
94impl<'a, const O: u8> BUSSTATE_W<'a, O> {
95 #[doc = "Unknown Bus State"]
96 #[inline(always)]
97 pub fn unknown(self) -> &'a mut W {
98 self.variant(BUSSTATE_A::UNKNOWN)
99 }
100 #[doc = "Bus is Idle"]
101 #[inline(always)]
102 pub fn idle(self) -> &'a mut W {
103 self.variant(BUSSTATE_A::IDLE)
104 }
105 #[doc = "This Module Controls The Bus"]
106 #[inline(always)]
107 pub fn owner(self) -> &'a mut W {
108 self.variant(BUSSTATE_A::OWNER)
109 }
110 #[doc = "The Bus is Busy"]
111 #[inline(always)]
112 pub fn busy(self) -> &'a mut W {
113 self.variant(BUSSTATE_A::BUSY)
114 }
115}
116#[doc = "Field `BUSERR` reader - Bus Error"]
117pub type BUSERR_R = crate::BitReader<bool>;
118#[doc = "Field `BUSERR` writer - Bus Error"]
119pub type BUSERR_W<'a, const O: u8> = crate::BitWriter<'a, u8, MSTATUS_SPEC, bool, O>;
120#[doc = "Field `ARBLOST` reader - Arbitration Lost"]
121pub type ARBLOST_R = crate::BitReader<bool>;
122#[doc = "Field `ARBLOST` writer - Arbitration Lost"]
123pub type ARBLOST_W<'a, const O: u8> = crate::BitWriter<'a, u8, MSTATUS_SPEC, bool, O>;
124#[doc = "Field `RXACK` reader - Received Acknowledge"]
125pub type RXACK_R = crate::BitReader<bool>;
126#[doc = "Field `CLKHOLD` reader - Clock Hold"]
127pub type CLKHOLD_R = crate::BitReader<bool>;
128#[doc = "Field `CLKHOLD` writer - Clock Hold"]
129pub type CLKHOLD_W<'a, const O: u8> = crate::BitWriter<'a, u8, MSTATUS_SPEC, bool, O>;
130#[doc = "Field `WIF` reader - Write Interrupt Flag"]
131pub type WIF_R = crate::BitReader<bool>;
132#[doc = "Field `WIF` writer - Write Interrupt Flag"]
133pub type WIF_W<'a, const O: u8> = crate::BitWriter<'a, u8, MSTATUS_SPEC, bool, O>;
134#[doc = "Field `RIF` reader - Read Interrupt Flag"]
135pub type RIF_R = crate::BitReader<bool>;
136#[doc = "Field `RIF` writer - Read Interrupt Flag"]
137pub type RIF_W<'a, const O: u8> = crate::BitWriter<'a, u8, MSTATUS_SPEC, bool, O>;
138impl R {
139 #[doc = "Bits 0:1 - Bus State"]
140 #[inline(always)]
141 pub fn busstate(&self) -> BUSSTATE_R {
142 BUSSTATE_R::new(self.bits & 3)
143 }
144 #[doc = "Bit 2 - Bus Error"]
145 #[inline(always)]
146 pub fn buserr(&self) -> BUSERR_R {
147 BUSERR_R::new(((self.bits >> 2) & 1) != 0)
148 }
149 #[doc = "Bit 3 - Arbitration Lost"]
150 #[inline(always)]
151 pub fn arblost(&self) -> ARBLOST_R {
152 ARBLOST_R::new(((self.bits >> 3) & 1) != 0)
153 }
154 #[doc = "Bit 4 - Received Acknowledge"]
155 #[inline(always)]
156 pub fn rxack(&self) -> RXACK_R {
157 RXACK_R::new(((self.bits >> 4) & 1) != 0)
158 }
159 #[doc = "Bit 5 - Clock Hold"]
160 #[inline(always)]
161 pub fn clkhold(&self) -> CLKHOLD_R {
162 CLKHOLD_R::new(((self.bits >> 5) & 1) != 0)
163 }
164 #[doc = "Bit 6 - Write Interrupt Flag"]
165 #[inline(always)]
166 pub fn wif(&self) -> WIF_R {
167 WIF_R::new(((self.bits >> 6) & 1) != 0)
168 }
169 #[doc = "Bit 7 - Read Interrupt Flag"]
170 #[inline(always)]
171 pub fn rif(&self) -> RIF_R {
172 RIF_R::new(((self.bits >> 7) & 1) != 0)
173 }
174}
175impl W {
176 #[doc = "Bits 0:1 - Bus State"]
177 #[inline(always)]
178 #[must_use]
179 pub fn busstate(&mut self) -> BUSSTATE_W<0> {
180 BUSSTATE_W::new(self)
181 }
182 #[doc = "Bit 2 - Bus Error"]
183 #[inline(always)]
184 #[must_use]
185 pub fn buserr(&mut self) -> BUSERR_W<2> {
186 BUSERR_W::new(self)
187 }
188 #[doc = "Bit 3 - Arbitration Lost"]
189 #[inline(always)]
190 #[must_use]
191 pub fn arblost(&mut self) -> ARBLOST_W<3> {
192 ARBLOST_W::new(self)
193 }
194 #[doc = "Bit 5 - Clock Hold"]
195 #[inline(always)]
196 #[must_use]
197 pub fn clkhold(&mut self) -> CLKHOLD_W<5> {
198 CLKHOLD_W::new(self)
199 }
200 #[doc = "Bit 6 - Write Interrupt Flag"]
201 #[inline(always)]
202 #[must_use]
203 pub fn wif(&mut self) -> WIF_W<6> {
204 WIF_W::new(self)
205 }
206 #[doc = "Bit 7 - Read Interrupt Flag"]
207 #[inline(always)]
208 #[must_use]
209 pub fn rif(&mut self) -> RIF_W<7> {
210 RIF_W::new(self)
211 }
212 #[doc = "Writes raw bits to the register."]
213 #[inline(always)]
214 pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
215 self.0.bits(bits);
216 self
217 }
218}
219#[doc = "Master Status\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [mstatus](index.html) module"]
220pub struct MSTATUS_SPEC;
221impl crate::RegisterSpec for MSTATUS_SPEC {
222 type Ux = u8;
223}
224#[doc = "`read()` method returns [mstatus::R](R) reader structure"]
225impl crate::Readable for MSTATUS_SPEC {
226 type Reader = R;
227}
228#[doc = "`write(|w| ..)` method takes [mstatus::W](W) writer structure"]
229impl crate::Writable for MSTATUS_SPEC {
230 type Writer = W;
231 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
232 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
233}
234#[doc = "`reset()` method sets MSTATUS to value 0"]
235impl crate::Resettable for MSTATUS_SPEC {
236 const RESET_VALUE: Self::Ux = 0;
237}