mimxrt595s/i3c0/
mctrl.rs

1#[doc = "Register `MCTRL` reader"]
2pub struct R(crate::R<MCTRL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<MCTRL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<MCTRL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<MCTRL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `MCTRL` writer"]
17pub struct W(crate::W<MCTRL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<MCTRL_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<MCTRL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<MCTRL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `REQUEST` reader - Request"]
38pub type REQUEST_R = crate::FieldReader<u8, REQUEST_A>;
39#[doc = "Request\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum REQUEST_A {
43    #[doc = "0: NONE"]
44    NONE = 0,
45    #[doc = "1: EMITSTARTADDR"]
46    EMITSTARTADDR = 1,
47    #[doc = "2: EMITSTOP"]
48    EMITSTOP = 2,
49    #[doc = "3: IBIACKNACK"]
50    IBIACKNACK = 3,
51    #[doc = "4: PROCESSDAA"]
52    PROCESSDAA = 4,
53    #[doc = "6: FORCEEXIT and IBHR"]
54    FORCEEXIT = 6,
55    #[doc = "7: AUTOIBI"]
56    AUTOIBI = 7,
57}
58impl From<REQUEST_A> for u8 {
59    #[inline(always)]
60    fn from(variant: REQUEST_A) -> Self {
61        variant as _
62    }
63}
64impl REQUEST_R {
65    #[doc = "Get enumerated values variant"]
66    #[inline(always)]
67    pub fn variant(&self) -> Option<REQUEST_A> {
68        match self.bits {
69            0 => Some(REQUEST_A::NONE),
70            1 => Some(REQUEST_A::EMITSTARTADDR),
71            2 => Some(REQUEST_A::EMITSTOP),
72            3 => Some(REQUEST_A::IBIACKNACK),
73            4 => Some(REQUEST_A::PROCESSDAA),
74            6 => Some(REQUEST_A::FORCEEXIT),
75            7 => Some(REQUEST_A::AUTOIBI),
76            _ => None,
77        }
78    }
79    #[doc = "Checks if the value of the field is `NONE`"]
80    #[inline(always)]
81    pub fn is_none(&self) -> bool {
82        *self == REQUEST_A::NONE
83    }
84    #[doc = "Checks if the value of the field is `EMITSTARTADDR`"]
85    #[inline(always)]
86    pub fn is_emitstartaddr(&self) -> bool {
87        *self == REQUEST_A::EMITSTARTADDR
88    }
89    #[doc = "Checks if the value of the field is `EMITSTOP`"]
90    #[inline(always)]
91    pub fn is_emitstop(&self) -> bool {
92        *self == REQUEST_A::EMITSTOP
93    }
94    #[doc = "Checks if the value of the field is `IBIACKNACK`"]
95    #[inline(always)]
96    pub fn is_ibiacknack(&self) -> bool {
97        *self == REQUEST_A::IBIACKNACK
98    }
99    #[doc = "Checks if the value of the field is `PROCESSDAA`"]
100    #[inline(always)]
101    pub fn is_processdaa(&self) -> bool {
102        *self == REQUEST_A::PROCESSDAA
103    }
104    #[doc = "Checks if the value of the field is `FORCEEXIT`"]
105    #[inline(always)]
106    pub fn is_forceexit(&self) -> bool {
107        *self == REQUEST_A::FORCEEXIT
108    }
109    #[doc = "Checks if the value of the field is `AUTOIBI`"]
110    #[inline(always)]
111    pub fn is_autoibi(&self) -> bool {
112        *self == REQUEST_A::AUTOIBI
113    }
114}
115#[doc = "Field `REQUEST` writer - Request"]
116pub type REQUEST_W<'a, const O: u8> = crate::FieldWriter<'a, u32, MCTRL_SPEC, u8, REQUEST_A, 3, O>;
117impl<'a, const O: u8> REQUEST_W<'a, O> {
118    #[doc = "NONE"]
119    #[inline(always)]
120    pub fn none(self) -> &'a mut W {
121        self.variant(REQUEST_A::NONE)
122    }
123    #[doc = "EMITSTARTADDR"]
124    #[inline(always)]
125    pub fn emitstartaddr(self) -> &'a mut W {
126        self.variant(REQUEST_A::EMITSTARTADDR)
127    }
128    #[doc = "EMITSTOP"]
129    #[inline(always)]
130    pub fn emitstop(self) -> &'a mut W {
131        self.variant(REQUEST_A::EMITSTOP)
132    }
133    #[doc = "IBIACKNACK"]
134    #[inline(always)]
135    pub fn ibiacknack(self) -> &'a mut W {
136        self.variant(REQUEST_A::IBIACKNACK)
137    }
138    #[doc = "PROCESSDAA"]
139    #[inline(always)]
140    pub fn processdaa(self) -> &'a mut W {
141        self.variant(REQUEST_A::PROCESSDAA)
142    }
143    #[doc = "FORCEEXIT and IBHR"]
144    #[inline(always)]
145    pub fn forceexit(self) -> &'a mut W {
146        self.variant(REQUEST_A::FORCEEXIT)
147    }
148    #[doc = "AUTOIBI"]
149    #[inline(always)]
150    pub fn autoibi(self) -> &'a mut W {
151        self.variant(REQUEST_A::AUTOIBI)
152    }
153}
154#[doc = "Field `TYPE` reader - Bus type with START"]
155pub type TYPE_R = crate::FieldReader<u8, TYPE_A>;
156#[doc = "Bus type with START\n\nValue on reset: 0"]
157#[derive(Clone, Copy, Debug, PartialEq, Eq)]
158#[repr(u8)]
159pub enum TYPE_A {
160    #[doc = "0: I3C"]
161    I3C = 0,
162    #[doc = "1: I2C"]
163    I2C = 1,
164    #[doc = "2: DDR"]
165    DDR = 2,
166    #[doc = "3: For ForcedExit, this is forced IBHR."]
167    FORCEDIBHR = 3,
168}
169impl From<TYPE_A> for u8 {
170    #[inline(always)]
171    fn from(variant: TYPE_A) -> Self {
172        variant as _
173    }
174}
175impl TYPE_R {
176    #[doc = "Get enumerated values variant"]
177    #[inline(always)]
178    pub fn variant(&self) -> TYPE_A {
179        match self.bits {
180            0 => TYPE_A::I3C,
181            1 => TYPE_A::I2C,
182            2 => TYPE_A::DDR,
183            3 => TYPE_A::FORCEDIBHR,
184            _ => unreachable!(),
185        }
186    }
187    #[doc = "Checks if the value of the field is `I3C`"]
188    #[inline(always)]
189    pub fn is_i3c(&self) -> bool {
190        *self == TYPE_A::I3C
191    }
192    #[doc = "Checks if the value of the field is `I2C`"]
193    #[inline(always)]
194    pub fn is_i2c(&self) -> bool {
195        *self == TYPE_A::I2C
196    }
197    #[doc = "Checks if the value of the field is `DDR`"]
198    #[inline(always)]
199    pub fn is_ddr(&self) -> bool {
200        *self == TYPE_A::DDR
201    }
202    #[doc = "Checks if the value of the field is `FORCEDIBHR`"]
203    #[inline(always)]
204    pub fn is_forcedibhr(&self) -> bool {
205        *self == TYPE_A::FORCEDIBHR
206    }
207}
208#[doc = "Field `TYPE` writer - Bus type with START"]
209pub type TYPE_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u32, MCTRL_SPEC, u8, TYPE_A, 2, O>;
210impl<'a, const O: u8> TYPE_W<'a, O> {
211    #[doc = "I3C"]
212    #[inline(always)]
213    pub fn i3c(self) -> &'a mut W {
214        self.variant(TYPE_A::I3C)
215    }
216    #[doc = "I2C"]
217    #[inline(always)]
218    pub fn i2c(self) -> &'a mut W {
219        self.variant(TYPE_A::I2C)
220    }
221    #[doc = "DDR"]
222    #[inline(always)]
223    pub fn ddr(self) -> &'a mut W {
224        self.variant(TYPE_A::DDR)
225    }
226    #[doc = "For ForcedExit, this is forced IBHR."]
227    #[inline(always)]
228    pub fn forcedibhr(self) -> &'a mut W {
229        self.variant(TYPE_A::FORCEDIBHR)
230    }
231}
232#[doc = "Field `IBIRESP` reader - In-Band Interrupt (IBI) response"]
233pub type IBIRESP_R = crate::FieldReader<u8, IBIRESP_A>;
234#[doc = "In-Band Interrupt (IBI) response\n\nValue on reset: 0"]
235#[derive(Clone, Copy, Debug, PartialEq, Eq)]
236#[repr(u8)]
237pub enum IBIRESP_A {
238    #[doc = "0: ACK"]
239    ACK = 0,
240    #[doc = "1: NACK"]
241    NACK = 1,
242    #[doc = "2: ACK_WITH_MANDATORY"]
243    ACK_WITH_MANDATORY = 2,
244    #[doc = "3: MANUAL"]
245    MANUAL = 3,
246}
247impl From<IBIRESP_A> for u8 {
248    #[inline(always)]
249    fn from(variant: IBIRESP_A) -> Self {
250        variant as _
251    }
252}
253impl IBIRESP_R {
254    #[doc = "Get enumerated values variant"]
255    #[inline(always)]
256    pub fn variant(&self) -> IBIRESP_A {
257        match self.bits {
258            0 => IBIRESP_A::ACK,
259            1 => IBIRESP_A::NACK,
260            2 => IBIRESP_A::ACK_WITH_MANDATORY,
261            3 => IBIRESP_A::MANUAL,
262            _ => unreachable!(),
263        }
264    }
265    #[doc = "Checks if the value of the field is `ACK`"]
266    #[inline(always)]
267    pub fn is_ack(&self) -> bool {
268        *self == IBIRESP_A::ACK
269    }
270    #[doc = "Checks if the value of the field is `NACK`"]
271    #[inline(always)]
272    pub fn is_nack(&self) -> bool {
273        *self == IBIRESP_A::NACK
274    }
275    #[doc = "Checks if the value of the field is `ACK_WITH_MANDATORY`"]
276    #[inline(always)]
277    pub fn is_ack_with_mandatory(&self) -> bool {
278        *self == IBIRESP_A::ACK_WITH_MANDATORY
279    }
280    #[doc = "Checks if the value of the field is `MANUAL`"]
281    #[inline(always)]
282    pub fn is_manual(&self) -> bool {
283        *self == IBIRESP_A::MANUAL
284    }
285}
286#[doc = "Field `IBIRESP` writer - In-Band Interrupt (IBI) response"]
287pub type IBIRESP_W<'a, const O: u8> =
288    crate::FieldWriterSafe<'a, u32, MCTRL_SPEC, u8, IBIRESP_A, 2, O>;
289impl<'a, const O: u8> IBIRESP_W<'a, O> {
290    #[doc = "ACK"]
291    #[inline(always)]
292    pub fn ack(self) -> &'a mut W {
293        self.variant(IBIRESP_A::ACK)
294    }
295    #[doc = "NACK"]
296    #[inline(always)]
297    pub fn nack(self) -> &'a mut W {
298        self.variant(IBIRESP_A::NACK)
299    }
300    #[doc = "ACK_WITH_MANDATORY"]
301    #[inline(always)]
302    pub fn ack_with_mandatory(self) -> &'a mut W {
303        self.variant(IBIRESP_A::ACK_WITH_MANDATORY)
304    }
305    #[doc = "MANUAL"]
306    #[inline(always)]
307    pub fn manual(self) -> &'a mut W {
308        self.variant(IBIRESP_A::MANUAL)
309    }
310}
311#[doc = "Field `DIR` reader - DIR"]
312pub type DIR_R = crate::BitReader<DIR_A>;
313#[doc = "DIR\n\nValue on reset: 0"]
314#[derive(Clone, Copy, Debug, PartialEq, Eq)]
315pub enum DIR_A {
316    #[doc = "0: DIRWRITE: Write"]
317    DIRWRITE = 0,
318    #[doc = "1: DIRREAD: Read"]
319    DIRREAD = 1,
320}
321impl From<DIR_A> for bool {
322    #[inline(always)]
323    fn from(variant: DIR_A) -> Self {
324        variant as u8 != 0
325    }
326}
327impl DIR_R {
328    #[doc = "Get enumerated values variant"]
329    #[inline(always)]
330    pub fn variant(&self) -> DIR_A {
331        match self.bits {
332            false => DIR_A::DIRWRITE,
333            true => DIR_A::DIRREAD,
334        }
335    }
336    #[doc = "Checks if the value of the field is `DIRWRITE`"]
337    #[inline(always)]
338    pub fn is_dirwrite(&self) -> bool {
339        *self == DIR_A::DIRWRITE
340    }
341    #[doc = "Checks if the value of the field is `DIRREAD`"]
342    #[inline(always)]
343    pub fn is_dirread(&self) -> bool {
344        *self == DIR_A::DIRREAD
345    }
346}
347#[doc = "Field `DIR` writer - DIR"]
348pub type DIR_W<'a, const O: u8> = crate::BitWriter<'a, u32, MCTRL_SPEC, DIR_A, O>;
349impl<'a, const O: u8> DIR_W<'a, O> {
350    #[doc = "DIRWRITE: Write"]
351    #[inline(always)]
352    pub fn dirwrite(self) -> &'a mut W {
353        self.variant(DIR_A::DIRWRITE)
354    }
355    #[doc = "DIRREAD: Read"]
356    #[inline(always)]
357    pub fn dirread(self) -> &'a mut W {
358        self.variant(DIR_A::DIRREAD)
359    }
360}
361#[doc = "Field `ADDR` reader - ADDR"]
362pub type ADDR_R = crate::FieldReader<u8, u8>;
363#[doc = "Field `ADDR` writer - ADDR"]
364pub type ADDR_W<'a, const O: u8> = crate::FieldWriter<'a, u32, MCTRL_SPEC, u8, u8, 7, O>;
365#[doc = "Field `RDTERM` reader - Read terminate"]
366pub type RDTERM_R = crate::FieldReader<u8, u8>;
367#[doc = "Field `RDTERM` writer - Read terminate"]
368pub type RDTERM_W<'a, const O: u8> = crate::FieldWriter<'a, u32, MCTRL_SPEC, u8, u8, 8, O>;
369impl R {
370    #[doc = "Bits 0:2 - Request"]
371    #[inline(always)]
372    pub fn request(&self) -> REQUEST_R {
373        REQUEST_R::new((self.bits & 7) as u8)
374    }
375    #[doc = "Bits 4:5 - Bus type with START"]
376    #[inline(always)]
377    pub fn type_(&self) -> TYPE_R {
378        TYPE_R::new(((self.bits >> 4) & 3) as u8)
379    }
380    #[doc = "Bits 6:7 - In-Band Interrupt (IBI) response"]
381    #[inline(always)]
382    pub fn ibiresp(&self) -> IBIRESP_R {
383        IBIRESP_R::new(((self.bits >> 6) & 3) as u8)
384    }
385    #[doc = "Bit 8 - DIR"]
386    #[inline(always)]
387    pub fn dir(&self) -> DIR_R {
388        DIR_R::new(((self.bits >> 8) & 1) != 0)
389    }
390    #[doc = "Bits 9:15 - ADDR"]
391    #[inline(always)]
392    pub fn addr(&self) -> ADDR_R {
393        ADDR_R::new(((self.bits >> 9) & 0x7f) as u8)
394    }
395    #[doc = "Bits 16:23 - Read terminate"]
396    #[inline(always)]
397    pub fn rdterm(&self) -> RDTERM_R {
398        RDTERM_R::new(((self.bits >> 16) & 0xff) as u8)
399    }
400}
401impl W {
402    #[doc = "Bits 0:2 - Request"]
403    #[inline(always)]
404    #[must_use]
405    pub fn request(&mut self) -> REQUEST_W<0> {
406        REQUEST_W::new(self)
407    }
408    #[doc = "Bits 4:5 - Bus type with START"]
409    #[inline(always)]
410    #[must_use]
411    pub fn type_(&mut self) -> TYPE_W<4> {
412        TYPE_W::new(self)
413    }
414    #[doc = "Bits 6:7 - In-Band Interrupt (IBI) response"]
415    #[inline(always)]
416    #[must_use]
417    pub fn ibiresp(&mut self) -> IBIRESP_W<6> {
418        IBIRESP_W::new(self)
419    }
420    #[doc = "Bit 8 - DIR"]
421    #[inline(always)]
422    #[must_use]
423    pub fn dir(&mut self) -> DIR_W<8> {
424        DIR_W::new(self)
425    }
426    #[doc = "Bits 9:15 - ADDR"]
427    #[inline(always)]
428    #[must_use]
429    pub fn addr(&mut self) -> ADDR_W<9> {
430        ADDR_W::new(self)
431    }
432    #[doc = "Bits 16:23 - Read terminate"]
433    #[inline(always)]
434    #[must_use]
435    pub fn rdterm(&mut self) -> RDTERM_W<16> {
436        RDTERM_W::new(self)
437    }
438    #[doc = "Writes raw bits to the register."]
439    #[inline(always)]
440    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
441        self.0.bits(bits);
442        self
443    }
444}
445#[doc = "Master Main Control Register\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 [mctrl](index.html) module"]
446pub struct MCTRL_SPEC;
447impl crate::RegisterSpec for MCTRL_SPEC {
448    type Ux = u32;
449}
450#[doc = "`read()` method returns [mctrl::R](R) reader structure"]
451impl crate::Readable for MCTRL_SPEC {
452    type Reader = R;
453}
454#[doc = "`write(|w| ..)` method takes [mctrl::W](W) writer structure"]
455impl crate::Writable for MCTRL_SPEC {
456    type Writer = W;
457    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
458    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
459}
460#[doc = "`reset()` method sets MCTRL to value 0"]
461impl crate::Resettable for MCTRL_SPEC {
462    const RESET_VALUE: Self::Ux = 0;
463}