Skip to main content

mcxa_pac/i3c0/
mconfig.rs

1#[doc = "Register `MCONFIG` reader"]
2pub type R = crate::R<MconfigSpec>;
3#[doc = "Register `MCONFIG` writer"]
4pub type W = crate::W<MconfigSpec>;
5#[doc = "Controller Enable\n\nValue on reset: 0"]
6#[cfg_attr(feature = "defmt", derive(defmt::Format))]
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8#[repr(u8)]
9pub enum Mstena {
10    #[doc = "0: CONTROLLER_OFF"]
11    MasterOff = 0,
12    #[doc = "1: CONTROLLER_ON"]
13    MasterOn = 1,
14    #[doc = "2: CONTROLLER_CAPABLE"]
15    MasterCapable = 2,
16    #[doc = "3: I2C_CONTROLLER_MODE"]
17    I2cMasterMode = 3,
18}
19impl From<Mstena> for u8 {
20    #[inline(always)]
21    fn from(variant: Mstena) -> Self {
22        variant as _
23    }
24}
25impl crate::FieldSpec for Mstena {
26    type Ux = u8;
27}
28impl crate::IsEnum for Mstena {}
29#[doc = "Field `MSTENA` reader - Controller Enable"]
30pub type MstenaR = crate::FieldReader<Mstena>;
31impl MstenaR {
32    #[doc = "Get enumerated values variant"]
33    #[inline(always)]
34    pub const fn variant(&self) -> Mstena {
35        match self.bits {
36            0 => Mstena::MasterOff,
37            1 => Mstena::MasterOn,
38            2 => Mstena::MasterCapable,
39            3 => Mstena::I2cMasterMode,
40            _ => unreachable!(),
41        }
42    }
43    #[doc = "CONTROLLER_OFF"]
44    #[inline(always)]
45    pub fn is_master_off(&self) -> bool {
46        *self == Mstena::MasterOff
47    }
48    #[doc = "CONTROLLER_ON"]
49    #[inline(always)]
50    pub fn is_master_on(&self) -> bool {
51        *self == Mstena::MasterOn
52    }
53    #[doc = "CONTROLLER_CAPABLE"]
54    #[inline(always)]
55    pub fn is_master_capable(&self) -> bool {
56        *self == Mstena::MasterCapable
57    }
58    #[doc = "I2C_CONTROLLER_MODE"]
59    #[inline(always)]
60    pub fn is_i2c_master_mode(&self) -> bool {
61        *self == Mstena::I2cMasterMode
62    }
63}
64#[doc = "Field `MSTENA` writer - Controller Enable"]
65pub type MstenaW<'a, REG> = crate::FieldWriter<'a, REG, 2, Mstena, crate::Safe>;
66impl<'a, REG> MstenaW<'a, REG>
67where
68    REG: crate::Writable + crate::RegisterSpec,
69    REG::Ux: From<u8>,
70{
71    #[doc = "CONTROLLER_OFF"]
72    #[inline(always)]
73    pub fn master_off(self) -> &'a mut crate::W<REG> {
74        self.variant(Mstena::MasterOff)
75    }
76    #[doc = "CONTROLLER_ON"]
77    #[inline(always)]
78    pub fn master_on(self) -> &'a mut crate::W<REG> {
79        self.variant(Mstena::MasterOn)
80    }
81    #[doc = "CONTROLLER_CAPABLE"]
82    #[inline(always)]
83    pub fn master_capable(self) -> &'a mut crate::W<REG> {
84        self.variant(Mstena::MasterCapable)
85    }
86    #[doc = "I2C_CONTROLLER_MODE"]
87    #[inline(always)]
88    pub fn i2c_master_mode(self) -> &'a mut crate::W<REG> {
89        self.variant(Mstena::I2cMasterMode)
90    }
91}
92#[doc = "Disable Timeout\n\nValue on reset: 0"]
93#[cfg_attr(feature = "defmt", derive(defmt::Format))]
94#[derive(Clone, Copy, Debug, PartialEq, Eq)]
95pub enum Disto {
96    #[doc = "0: Enabled"]
97    Enable = 0,
98    #[doc = "1: Disabled, if configured"]
99    Disable = 1,
100}
101impl From<Disto> for bool {
102    #[inline(always)]
103    fn from(variant: Disto) -> Self {
104        variant as u8 != 0
105    }
106}
107#[doc = "Field `DISTO` reader - Disable Timeout"]
108pub type DistoR = crate::BitReader<Disto>;
109impl DistoR {
110    #[doc = "Get enumerated values variant"]
111    #[inline(always)]
112    pub const fn variant(&self) -> Disto {
113        match self.bits {
114            false => Disto::Enable,
115            true => Disto::Disable,
116        }
117    }
118    #[doc = "Enabled"]
119    #[inline(always)]
120    pub fn is_enable(&self) -> bool {
121        *self == Disto::Enable
122    }
123    #[doc = "Disabled, if configured"]
124    #[inline(always)]
125    pub fn is_disable(&self) -> bool {
126        *self == Disto::Disable
127    }
128}
129#[doc = "Field `DISTO` writer - Disable Timeout"]
130pub type DistoW<'a, REG> = crate::BitWriter<'a, REG, Disto>;
131impl<'a, REG> DistoW<'a, REG>
132where
133    REG: crate::Writable + crate::RegisterSpec,
134{
135    #[doc = "Enabled"]
136    #[inline(always)]
137    pub fn enable(self) -> &'a mut crate::W<REG> {
138        self.variant(Disto::Enable)
139    }
140    #[doc = "Disabled, if configured"]
141    #[inline(always)]
142    pub fn disable(self) -> &'a mut crate::W<REG> {
143        self.variant(Disto::Disable)
144    }
145}
146#[doc = "High-Keeper\n\nValue on reset: 0"]
147#[cfg_attr(feature = "defmt", derive(defmt::Format))]
148#[derive(Clone, Copy, Debug, PartialEq, Eq)]
149#[repr(u8)]
150pub enum Hkeep {
151    #[doc = "0: None"]
152    None = 0,
153    #[doc = "1: WIRED_IN"]
154    WiredIn = 1,
155    #[doc = "2: PASSIVE_SDA (I2C mode, no clock stretches mode)"]
156    PassiveSda = 2,
157    #[doc = "3: PASSIVE_ON_SDA_SCL"]
158    PassiveOnSdaScl = 3,
159}
160impl From<Hkeep> for u8 {
161    #[inline(always)]
162    fn from(variant: Hkeep) -> Self {
163        variant as _
164    }
165}
166impl crate::FieldSpec for Hkeep {
167    type Ux = u8;
168}
169impl crate::IsEnum for Hkeep {}
170#[doc = "Field `HKEEP` reader - High-Keeper"]
171pub type HkeepR = crate::FieldReader<Hkeep>;
172impl HkeepR {
173    #[doc = "Get enumerated values variant"]
174    #[inline(always)]
175    pub const fn variant(&self) -> Hkeep {
176        match self.bits {
177            0 => Hkeep::None,
178            1 => Hkeep::WiredIn,
179            2 => Hkeep::PassiveSda,
180            3 => Hkeep::PassiveOnSdaScl,
181            _ => unreachable!(),
182        }
183    }
184    #[doc = "None"]
185    #[inline(always)]
186    pub fn is_none(&self) -> bool {
187        *self == Hkeep::None
188    }
189    #[doc = "WIRED_IN"]
190    #[inline(always)]
191    pub fn is_wired_in(&self) -> bool {
192        *self == Hkeep::WiredIn
193    }
194    #[doc = "PASSIVE_SDA (I2C mode, no clock stretches mode)"]
195    #[inline(always)]
196    pub fn is_passive_sda(&self) -> bool {
197        *self == Hkeep::PassiveSda
198    }
199    #[doc = "PASSIVE_ON_SDA_SCL"]
200    #[inline(always)]
201    pub fn is_passive_on_sda_scl(&self) -> bool {
202        *self == Hkeep::PassiveOnSdaScl
203    }
204}
205#[doc = "Field `HKEEP` writer - High-Keeper"]
206pub type HkeepW<'a, REG> = crate::FieldWriter<'a, REG, 2, Hkeep, crate::Safe>;
207impl<'a, REG> HkeepW<'a, REG>
208where
209    REG: crate::Writable + crate::RegisterSpec,
210    REG::Ux: From<u8>,
211{
212    #[doc = "None"]
213    #[inline(always)]
214    pub fn none(self) -> &'a mut crate::W<REG> {
215        self.variant(Hkeep::None)
216    }
217    #[doc = "WIRED_IN"]
218    #[inline(always)]
219    pub fn wired_in(self) -> &'a mut crate::W<REG> {
220        self.variant(Hkeep::WiredIn)
221    }
222    #[doc = "PASSIVE_SDA (I2C mode, no clock stretches mode)"]
223    #[inline(always)]
224    pub fn passive_sda(self) -> &'a mut crate::W<REG> {
225        self.variant(Hkeep::PassiveSda)
226    }
227    #[doc = "PASSIVE_ON_SDA_SCL"]
228    #[inline(always)]
229    pub fn passive_on_sda_scl(self) -> &'a mut crate::W<REG> {
230        self.variant(Hkeep::PassiveOnSdaScl)
231    }
232}
233#[doc = "Open-drain Stop\n\nValue on reset: 0"]
234#[cfg_attr(feature = "defmt", derive(defmt::Format))]
235#[derive(Clone, Copy, Debug, PartialEq, Eq)]
236pub enum Odstop {
237    #[doc = "0: Disable"]
238    Disable = 0,
239    #[doc = "1: Enable"]
240    Enable = 1,
241}
242impl From<Odstop> for bool {
243    #[inline(always)]
244    fn from(variant: Odstop) -> Self {
245        variant as u8 != 0
246    }
247}
248#[doc = "Field `ODSTOP` reader - Open-drain Stop"]
249pub type OdstopR = crate::BitReader<Odstop>;
250impl OdstopR {
251    #[doc = "Get enumerated values variant"]
252    #[inline(always)]
253    pub const fn variant(&self) -> Odstop {
254        match self.bits {
255            false => Odstop::Disable,
256            true => Odstop::Enable,
257        }
258    }
259    #[doc = "Disable"]
260    #[inline(always)]
261    pub fn is_disable(&self) -> bool {
262        *self == Odstop::Disable
263    }
264    #[doc = "Enable"]
265    #[inline(always)]
266    pub fn is_enable(&self) -> bool {
267        *self == Odstop::Enable
268    }
269}
270#[doc = "Field `ODSTOP` writer - Open-drain Stop"]
271pub type OdstopW<'a, REG> = crate::BitWriter<'a, REG, Odstop>;
272impl<'a, REG> OdstopW<'a, REG>
273where
274    REG: crate::Writable + crate::RegisterSpec,
275{
276    #[doc = "Disable"]
277    #[inline(always)]
278    pub fn disable(self) -> &'a mut crate::W<REG> {
279        self.variant(Odstop::Disable)
280    }
281    #[doc = "Enable"]
282    #[inline(always)]
283    pub fn enable(self) -> &'a mut crate::W<REG> {
284        self.variant(Odstop::Enable)
285    }
286}
287#[doc = "Field `PPBAUD` reader - Push-Pull Baud Rate"]
288pub type PpbaudR = crate::FieldReader;
289#[doc = "Field `PPBAUD` writer - Push-Pull Baud Rate"]
290pub type PpbaudW<'a, REG> = crate::FieldWriter<'a, REG, 4>;
291#[doc = "Field `PPLOW` reader - Push-Pull Low"]
292pub type PplowR = crate::FieldReader;
293#[doc = "Field `PPLOW` writer - Push-Pull Low"]
294pub type PplowW<'a, REG> = crate::FieldWriter<'a, REG, 4>;
295#[doc = "Field `ODBAUD` reader - Open-drain Baud Rate"]
296pub type OdbaudR = crate::FieldReader;
297#[doc = "Field `ODBAUD` writer - Open-drain Baud Rate"]
298pub type OdbaudW<'a, REG> = crate::FieldWriter<'a, REG, 8>;
299#[doc = "Open-drain High Push-Pull\n\nValue on reset: 0"]
300#[cfg_attr(feature = "defmt", derive(defmt::Format))]
301#[derive(Clone, Copy, Debug, PartialEq, Eq)]
302pub enum Odhpp {
303    #[doc = "0: Disable"]
304    Disable = 0,
305    #[doc = "1: Enable"]
306    Enable = 1,
307}
308impl From<Odhpp> for bool {
309    #[inline(always)]
310    fn from(variant: Odhpp) -> Self {
311        variant as u8 != 0
312    }
313}
314#[doc = "Field `ODHPP` reader - Open-drain High Push-Pull"]
315pub type OdhppR = crate::BitReader<Odhpp>;
316impl OdhppR {
317    #[doc = "Get enumerated values variant"]
318    #[inline(always)]
319    pub const fn variant(&self) -> Odhpp {
320        match self.bits {
321            false => Odhpp::Disable,
322            true => Odhpp::Enable,
323        }
324    }
325    #[doc = "Disable"]
326    #[inline(always)]
327    pub fn is_disable(&self) -> bool {
328        *self == Odhpp::Disable
329    }
330    #[doc = "Enable"]
331    #[inline(always)]
332    pub fn is_enable(&self) -> bool {
333        *self == Odhpp::Enable
334    }
335}
336#[doc = "Field `ODHPP` writer - Open-drain High Push-Pull"]
337pub type OdhppW<'a, REG> = crate::BitWriter<'a, REG, Odhpp>;
338impl<'a, REG> OdhppW<'a, REG>
339where
340    REG: crate::Writable + crate::RegisterSpec,
341{
342    #[doc = "Disable"]
343    #[inline(always)]
344    pub fn disable(self) -> &'a mut crate::W<REG> {
345        self.variant(Odhpp::Disable)
346    }
347    #[doc = "Enable"]
348    #[inline(always)]
349    pub fn enable(self) -> &'a mut crate::W<REG> {
350        self.variant(Odhpp::Enable)
351    }
352}
353#[doc = "Field `SKEW` reader - Skew"]
354pub type SkewR = crate::FieldReader;
355#[doc = "Field `SKEW` writer - Skew"]
356pub type SkewW<'a, REG> = crate::FieldWriter<'a, REG, 3>;
357#[doc = "Field `I2CBAUD` reader - I2C Baud Rate"]
358pub type I2cbaudR = crate::FieldReader;
359#[doc = "Field `I2CBAUD` writer - I2C Baud Rate"]
360pub type I2cbaudW<'a, REG> = crate::FieldWriter<'a, REG, 4>;
361impl R {
362    #[doc = "Bits 0:1 - Controller Enable"]
363    #[inline(always)]
364    pub fn mstena(&self) -> MstenaR {
365        MstenaR::new((self.bits & 3) as u8)
366    }
367    #[doc = "Bit 3 - Disable Timeout"]
368    #[inline(always)]
369    pub fn disto(&self) -> DistoR {
370        DistoR::new(((self.bits >> 3) & 1) != 0)
371    }
372    #[doc = "Bits 4:5 - High-Keeper"]
373    #[inline(always)]
374    pub fn hkeep(&self) -> HkeepR {
375        HkeepR::new(((self.bits >> 4) & 3) as u8)
376    }
377    #[doc = "Bit 6 - Open-drain Stop"]
378    #[inline(always)]
379    pub fn odstop(&self) -> OdstopR {
380        OdstopR::new(((self.bits >> 6) & 1) != 0)
381    }
382    #[doc = "Bits 8:11 - Push-Pull Baud Rate"]
383    #[inline(always)]
384    pub fn ppbaud(&self) -> PpbaudR {
385        PpbaudR::new(((self.bits >> 8) & 0x0f) as u8)
386    }
387    #[doc = "Bits 12:15 - Push-Pull Low"]
388    #[inline(always)]
389    pub fn pplow(&self) -> PplowR {
390        PplowR::new(((self.bits >> 12) & 0x0f) as u8)
391    }
392    #[doc = "Bits 16:23 - Open-drain Baud Rate"]
393    #[inline(always)]
394    pub fn odbaud(&self) -> OdbaudR {
395        OdbaudR::new(((self.bits >> 16) & 0xff) as u8)
396    }
397    #[doc = "Bit 24 - Open-drain High Push-Pull"]
398    #[inline(always)]
399    pub fn odhpp(&self) -> OdhppR {
400        OdhppR::new(((self.bits >> 24) & 1) != 0)
401    }
402    #[doc = "Bits 25:27 - Skew"]
403    #[inline(always)]
404    pub fn skew(&self) -> SkewR {
405        SkewR::new(((self.bits >> 25) & 7) as u8)
406    }
407    #[doc = "Bits 28:31 - I2C Baud Rate"]
408    #[inline(always)]
409    pub fn i2cbaud(&self) -> I2cbaudR {
410        I2cbaudR::new(((self.bits >> 28) & 0x0f) as u8)
411    }
412}
413#[cfg(feature = "debug")]
414impl core::fmt::Debug for R {
415    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
416        f.debug_struct("MCONFIG")
417            .field("mstena", &self.mstena())
418            .field("disto", &self.disto())
419            .field("hkeep", &self.hkeep())
420            .field("odstop", &self.odstop())
421            .field("ppbaud", &self.ppbaud())
422            .field("pplow", &self.pplow())
423            .field("odbaud", &self.odbaud())
424            .field("odhpp", &self.odhpp())
425            .field("skew", &self.skew())
426            .field("i2cbaud", &self.i2cbaud())
427            .finish()
428    }
429}
430impl W {
431    #[doc = "Bits 0:1 - Controller Enable"]
432    #[inline(always)]
433    pub fn mstena(&mut self) -> MstenaW<'_, MconfigSpec> {
434        MstenaW::new(self, 0)
435    }
436    #[doc = "Bit 3 - Disable Timeout"]
437    #[inline(always)]
438    pub fn disto(&mut self) -> DistoW<'_, MconfigSpec> {
439        DistoW::new(self, 3)
440    }
441    #[doc = "Bits 4:5 - High-Keeper"]
442    #[inline(always)]
443    pub fn hkeep(&mut self) -> HkeepW<'_, MconfigSpec> {
444        HkeepW::new(self, 4)
445    }
446    #[doc = "Bit 6 - Open-drain Stop"]
447    #[inline(always)]
448    pub fn odstop(&mut self) -> OdstopW<'_, MconfigSpec> {
449        OdstopW::new(self, 6)
450    }
451    #[doc = "Bits 8:11 - Push-Pull Baud Rate"]
452    #[inline(always)]
453    pub fn ppbaud(&mut self) -> PpbaudW<'_, MconfigSpec> {
454        PpbaudW::new(self, 8)
455    }
456    #[doc = "Bits 12:15 - Push-Pull Low"]
457    #[inline(always)]
458    pub fn pplow(&mut self) -> PplowW<'_, MconfigSpec> {
459        PplowW::new(self, 12)
460    }
461    #[doc = "Bits 16:23 - Open-drain Baud Rate"]
462    #[inline(always)]
463    pub fn odbaud(&mut self) -> OdbaudW<'_, MconfigSpec> {
464        OdbaudW::new(self, 16)
465    }
466    #[doc = "Bit 24 - Open-drain High Push-Pull"]
467    #[inline(always)]
468    pub fn odhpp(&mut self) -> OdhppW<'_, MconfigSpec> {
469        OdhppW::new(self, 24)
470    }
471    #[doc = "Bits 25:27 - Skew"]
472    #[inline(always)]
473    pub fn skew(&mut self) -> SkewW<'_, MconfigSpec> {
474        SkewW::new(self, 25)
475    }
476    #[doc = "Bits 28:31 - I2C Baud Rate"]
477    #[inline(always)]
478    pub fn i2cbaud(&mut self) -> I2cbaudW<'_, MconfigSpec> {
479        I2cbaudW::new(self, 28)
480    }
481}
482#[doc = "Controller Configuration\n\nYou can [`read`](crate::Reg::read) this register and get [`mconfig::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`mconfig::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
483pub struct MconfigSpec;
484impl crate::RegisterSpec for MconfigSpec {
485    type Ux = u32;
486}
487#[doc = "`read()` method returns [`mconfig::R`](R) reader structure"]
488impl crate::Readable for MconfigSpec {}
489#[doc = "`write(|w| ..)` method takes [`mconfig::W`](W) writer structure"]
490impl crate::Writable for MconfigSpec {
491    type Safety = crate::Unsafe;
492}
493#[doc = "`reset()` method sets MCONFIG to value 0"]
494impl crate::Resettable for MconfigSpec {}