lpc82x_pac/i2c0/
cfg.rs

1#[doc = "Register `CFG` reader"]
2pub struct R(crate::R<CFG_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CFG_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CFG_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CFG_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `CFG` writer"]
17pub struct W(crate::W<CFG_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CFG_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<CFG_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CFG_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Master Enable. When disabled, configurations settings for the Master function are not changed, but the Master function is internally reset.\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39pub enum MSTEN_A {
40    #[doc = "0: Disabled. The I2C Master function is disabled."]
41    DISABLED = 0,
42    #[doc = "1: Enabled. The I2C Master function is enabled."]
43    ENABLED = 1,
44}
45impl From<MSTEN_A> for bool {
46    #[inline(always)]
47    fn from(variant: MSTEN_A) -> Self {
48        variant as u8 != 0
49    }
50}
51#[doc = "Field `MSTEN` reader - Master Enable. When disabled, configurations settings for the Master function are not changed, but the Master function is internally reset."]
52pub struct MSTEN_R(crate::FieldReader<bool, MSTEN_A>);
53impl MSTEN_R {
54    pub(crate) fn new(bits: bool) -> Self {
55        MSTEN_R(crate::FieldReader::new(bits))
56    }
57    #[doc = r"Get enumerated values variant"]
58    #[inline(always)]
59    pub fn variant(&self) -> MSTEN_A {
60        match self.bits {
61            false => MSTEN_A::DISABLED,
62            true => MSTEN_A::ENABLED,
63        }
64    }
65    #[doc = "Checks if the value of the field is `DISABLED`"]
66    #[inline(always)]
67    pub fn is_disabled(&self) -> bool {
68        **self == MSTEN_A::DISABLED
69    }
70    #[doc = "Checks if the value of the field is `ENABLED`"]
71    #[inline(always)]
72    pub fn is_enabled(&self) -> bool {
73        **self == MSTEN_A::ENABLED
74    }
75}
76impl core::ops::Deref for MSTEN_R {
77    type Target = crate::FieldReader<bool, MSTEN_A>;
78    #[inline(always)]
79    fn deref(&self) -> &Self::Target {
80        &self.0
81    }
82}
83#[doc = "Field `MSTEN` writer - Master Enable. When disabled, configurations settings for the Master function are not changed, but the Master function is internally reset."]
84pub struct MSTEN_W<'a> {
85    w: &'a mut W,
86}
87impl<'a> MSTEN_W<'a> {
88    #[doc = r"Writes `variant` to the field"]
89    #[inline(always)]
90    pub fn variant(self, variant: MSTEN_A) -> &'a mut W {
91        self.bit(variant.into())
92    }
93    #[doc = "Disabled. The I2C Master function is disabled."]
94    #[inline(always)]
95    pub fn disabled(self) -> &'a mut W {
96        self.variant(MSTEN_A::DISABLED)
97    }
98    #[doc = "Enabled. The I2C Master function is enabled."]
99    #[inline(always)]
100    pub fn enabled(self) -> &'a mut W {
101        self.variant(MSTEN_A::ENABLED)
102    }
103    #[doc = r"Sets the field bit"]
104    #[inline(always)]
105    pub fn set_bit(self) -> &'a mut W {
106        self.bit(true)
107    }
108    #[doc = r"Clears the field bit"]
109    #[inline(always)]
110    pub fn clear_bit(self) -> &'a mut W {
111        self.bit(false)
112    }
113    #[doc = r"Writes raw bits to the field"]
114    #[inline(always)]
115    pub fn bit(self, value: bool) -> &'a mut W {
116        self.w.bits = (self.w.bits & !0x01) | (value as u32 & 0x01);
117        self.w
118    }
119}
120#[doc = "Slave Enable. When disabled, configurations settings for the Slave function are not changed, but the Slave function is internally reset.\n\nValue on reset: 0"]
121#[derive(Clone, Copy, Debug, PartialEq)]
122pub enum SLVEN_A {
123    #[doc = "0: Disabled. The I2C slave function is disabled."]
124    DISABLED = 0,
125    #[doc = "1: Enabled. The I2C slave function is enabled."]
126    ENABLED = 1,
127}
128impl From<SLVEN_A> for bool {
129    #[inline(always)]
130    fn from(variant: SLVEN_A) -> Self {
131        variant as u8 != 0
132    }
133}
134#[doc = "Field `SLVEN` reader - Slave Enable. When disabled, configurations settings for the Slave function are not changed, but the Slave function is internally reset."]
135pub struct SLVEN_R(crate::FieldReader<bool, SLVEN_A>);
136impl SLVEN_R {
137    pub(crate) fn new(bits: bool) -> Self {
138        SLVEN_R(crate::FieldReader::new(bits))
139    }
140    #[doc = r"Get enumerated values variant"]
141    #[inline(always)]
142    pub fn variant(&self) -> SLVEN_A {
143        match self.bits {
144            false => SLVEN_A::DISABLED,
145            true => SLVEN_A::ENABLED,
146        }
147    }
148    #[doc = "Checks if the value of the field is `DISABLED`"]
149    #[inline(always)]
150    pub fn is_disabled(&self) -> bool {
151        **self == SLVEN_A::DISABLED
152    }
153    #[doc = "Checks if the value of the field is `ENABLED`"]
154    #[inline(always)]
155    pub fn is_enabled(&self) -> bool {
156        **self == SLVEN_A::ENABLED
157    }
158}
159impl core::ops::Deref for SLVEN_R {
160    type Target = crate::FieldReader<bool, SLVEN_A>;
161    #[inline(always)]
162    fn deref(&self) -> &Self::Target {
163        &self.0
164    }
165}
166#[doc = "Field `SLVEN` writer - Slave Enable. When disabled, configurations settings for the Slave function are not changed, but the Slave function is internally reset."]
167pub struct SLVEN_W<'a> {
168    w: &'a mut W,
169}
170impl<'a> SLVEN_W<'a> {
171    #[doc = r"Writes `variant` to the field"]
172    #[inline(always)]
173    pub fn variant(self, variant: SLVEN_A) -> &'a mut W {
174        self.bit(variant.into())
175    }
176    #[doc = "Disabled. The I2C slave function is disabled."]
177    #[inline(always)]
178    pub fn disabled(self) -> &'a mut W {
179        self.variant(SLVEN_A::DISABLED)
180    }
181    #[doc = "Enabled. The I2C slave function is enabled."]
182    #[inline(always)]
183    pub fn enabled(self) -> &'a mut W {
184        self.variant(SLVEN_A::ENABLED)
185    }
186    #[doc = r"Sets the field bit"]
187    #[inline(always)]
188    pub fn set_bit(self) -> &'a mut W {
189        self.bit(true)
190    }
191    #[doc = r"Clears the field bit"]
192    #[inline(always)]
193    pub fn clear_bit(self) -> &'a mut W {
194        self.bit(false)
195    }
196    #[doc = r"Writes raw bits to the field"]
197    #[inline(always)]
198    pub fn bit(self, value: bool) -> &'a mut W {
199        self.w.bits = (self.w.bits & !(0x01 << 1)) | ((value as u32 & 0x01) << 1);
200        self.w
201    }
202}
203#[doc = "Monitor Enable. When disabled, configurations settings for the Monitor function are not changed, but the Monitor function is internally reset.\n\nValue on reset: 0"]
204#[derive(Clone, Copy, Debug, PartialEq)]
205pub enum MONEN_A {
206    #[doc = "0: Disabled. The I2C Monitor function is disabled."]
207    DISABLED = 0,
208    #[doc = "1: Enabled. The I2C Monitor function is enabled."]
209    ENABLED = 1,
210}
211impl From<MONEN_A> for bool {
212    #[inline(always)]
213    fn from(variant: MONEN_A) -> Self {
214        variant as u8 != 0
215    }
216}
217#[doc = "Field `MONEN` reader - Monitor Enable. When disabled, configurations settings for the Monitor function are not changed, but the Monitor function is internally reset."]
218pub struct MONEN_R(crate::FieldReader<bool, MONEN_A>);
219impl MONEN_R {
220    pub(crate) fn new(bits: bool) -> Self {
221        MONEN_R(crate::FieldReader::new(bits))
222    }
223    #[doc = r"Get enumerated values variant"]
224    #[inline(always)]
225    pub fn variant(&self) -> MONEN_A {
226        match self.bits {
227            false => MONEN_A::DISABLED,
228            true => MONEN_A::ENABLED,
229        }
230    }
231    #[doc = "Checks if the value of the field is `DISABLED`"]
232    #[inline(always)]
233    pub fn is_disabled(&self) -> bool {
234        **self == MONEN_A::DISABLED
235    }
236    #[doc = "Checks if the value of the field is `ENABLED`"]
237    #[inline(always)]
238    pub fn is_enabled(&self) -> bool {
239        **self == MONEN_A::ENABLED
240    }
241}
242impl core::ops::Deref for MONEN_R {
243    type Target = crate::FieldReader<bool, MONEN_A>;
244    #[inline(always)]
245    fn deref(&self) -> &Self::Target {
246        &self.0
247    }
248}
249#[doc = "Field `MONEN` writer - Monitor Enable. When disabled, configurations settings for the Monitor function are not changed, but the Monitor function is internally reset."]
250pub struct MONEN_W<'a> {
251    w: &'a mut W,
252}
253impl<'a> MONEN_W<'a> {
254    #[doc = r"Writes `variant` to the field"]
255    #[inline(always)]
256    pub fn variant(self, variant: MONEN_A) -> &'a mut W {
257        self.bit(variant.into())
258    }
259    #[doc = "Disabled. The I2C Monitor function is disabled."]
260    #[inline(always)]
261    pub fn disabled(self) -> &'a mut W {
262        self.variant(MONEN_A::DISABLED)
263    }
264    #[doc = "Enabled. The I2C Monitor function is enabled."]
265    #[inline(always)]
266    pub fn enabled(self) -> &'a mut W {
267        self.variant(MONEN_A::ENABLED)
268    }
269    #[doc = r"Sets the field bit"]
270    #[inline(always)]
271    pub fn set_bit(self) -> &'a mut W {
272        self.bit(true)
273    }
274    #[doc = r"Clears the field bit"]
275    #[inline(always)]
276    pub fn clear_bit(self) -> &'a mut W {
277        self.bit(false)
278    }
279    #[doc = r"Writes raw bits to the field"]
280    #[inline(always)]
281    pub fn bit(self, value: bool) -> &'a mut W {
282        self.w.bits = (self.w.bits & !(0x01 << 2)) | ((value as u32 & 0x01) << 2);
283        self.w
284    }
285}
286#[doc = "I2C bus Time-out Enable. When disabled, the time-out function is internally reset.\n\nValue on reset: 0"]
287#[derive(Clone, Copy, Debug, PartialEq)]
288pub enum TIMEOUTEN_A {
289    #[doc = "0: Disabled. Time-out function is disabled."]
290    DISABLED = 0,
291    #[doc = "1: Enabled. Time-out function is enabled. Both types of time-out flags will be generated and will cause interrupts if they are enabled. Typically, only one time-out will be used in a system."]
292    ENABLED = 1,
293}
294impl From<TIMEOUTEN_A> for bool {
295    #[inline(always)]
296    fn from(variant: TIMEOUTEN_A) -> Self {
297        variant as u8 != 0
298    }
299}
300#[doc = "Field `TIMEOUTEN` reader - I2C bus Time-out Enable. When disabled, the time-out function is internally reset."]
301pub struct TIMEOUTEN_R(crate::FieldReader<bool, TIMEOUTEN_A>);
302impl TIMEOUTEN_R {
303    pub(crate) fn new(bits: bool) -> Self {
304        TIMEOUTEN_R(crate::FieldReader::new(bits))
305    }
306    #[doc = r"Get enumerated values variant"]
307    #[inline(always)]
308    pub fn variant(&self) -> TIMEOUTEN_A {
309        match self.bits {
310            false => TIMEOUTEN_A::DISABLED,
311            true => TIMEOUTEN_A::ENABLED,
312        }
313    }
314    #[doc = "Checks if the value of the field is `DISABLED`"]
315    #[inline(always)]
316    pub fn is_disabled(&self) -> bool {
317        **self == TIMEOUTEN_A::DISABLED
318    }
319    #[doc = "Checks if the value of the field is `ENABLED`"]
320    #[inline(always)]
321    pub fn is_enabled(&self) -> bool {
322        **self == TIMEOUTEN_A::ENABLED
323    }
324}
325impl core::ops::Deref for TIMEOUTEN_R {
326    type Target = crate::FieldReader<bool, TIMEOUTEN_A>;
327    #[inline(always)]
328    fn deref(&self) -> &Self::Target {
329        &self.0
330    }
331}
332#[doc = "Field `TIMEOUTEN` writer - I2C bus Time-out Enable. When disabled, the time-out function is internally reset."]
333pub struct TIMEOUTEN_W<'a> {
334    w: &'a mut W,
335}
336impl<'a> TIMEOUTEN_W<'a> {
337    #[doc = r"Writes `variant` to the field"]
338    #[inline(always)]
339    pub fn variant(self, variant: TIMEOUTEN_A) -> &'a mut W {
340        self.bit(variant.into())
341    }
342    #[doc = "Disabled. Time-out function is disabled."]
343    #[inline(always)]
344    pub fn disabled(self) -> &'a mut W {
345        self.variant(TIMEOUTEN_A::DISABLED)
346    }
347    #[doc = "Enabled. Time-out function is enabled. Both types of time-out flags will be generated and will cause interrupts if they are enabled. Typically, only one time-out will be used in a system."]
348    #[inline(always)]
349    pub fn enabled(self) -> &'a mut W {
350        self.variant(TIMEOUTEN_A::ENABLED)
351    }
352    #[doc = r"Sets the field bit"]
353    #[inline(always)]
354    pub fn set_bit(self) -> &'a mut W {
355        self.bit(true)
356    }
357    #[doc = r"Clears the field bit"]
358    #[inline(always)]
359    pub fn clear_bit(self) -> &'a mut W {
360        self.bit(false)
361    }
362    #[doc = r"Writes raw bits to the field"]
363    #[inline(always)]
364    pub fn bit(self, value: bool) -> &'a mut W {
365        self.w.bits = (self.w.bits & !(0x01 << 3)) | ((value as u32 & 0x01) << 3);
366        self.w
367    }
368}
369#[doc = "Monitor function Clock Stretching.\n\nValue on reset: 0"]
370#[derive(Clone, Copy, Debug, PartialEq)]
371pub enum MONCLKSTR_A {
372    #[doc = "0: Disabled. The Monitor function will not perform clock stretching. Software or DMA may not always be able to read data provided by the Monitor function before it is overwritten. This mode may be used when non-invasive monitoring is critical."]
373    DISABLED = 0,
374    #[doc = "1: Enabled. The Monitor function will perform clock stretching in order to ensure that software or DMA can read all incoming data supplied by the Monitor function."]
375    ENABLED = 1,
376}
377impl From<MONCLKSTR_A> for bool {
378    #[inline(always)]
379    fn from(variant: MONCLKSTR_A) -> Self {
380        variant as u8 != 0
381    }
382}
383#[doc = "Field `MONCLKSTR` reader - Monitor function Clock Stretching."]
384pub struct MONCLKSTR_R(crate::FieldReader<bool, MONCLKSTR_A>);
385impl MONCLKSTR_R {
386    pub(crate) fn new(bits: bool) -> Self {
387        MONCLKSTR_R(crate::FieldReader::new(bits))
388    }
389    #[doc = r"Get enumerated values variant"]
390    #[inline(always)]
391    pub fn variant(&self) -> MONCLKSTR_A {
392        match self.bits {
393            false => MONCLKSTR_A::DISABLED,
394            true => MONCLKSTR_A::ENABLED,
395        }
396    }
397    #[doc = "Checks if the value of the field is `DISABLED`"]
398    #[inline(always)]
399    pub fn is_disabled(&self) -> bool {
400        **self == MONCLKSTR_A::DISABLED
401    }
402    #[doc = "Checks if the value of the field is `ENABLED`"]
403    #[inline(always)]
404    pub fn is_enabled(&self) -> bool {
405        **self == MONCLKSTR_A::ENABLED
406    }
407}
408impl core::ops::Deref for MONCLKSTR_R {
409    type Target = crate::FieldReader<bool, MONCLKSTR_A>;
410    #[inline(always)]
411    fn deref(&self) -> &Self::Target {
412        &self.0
413    }
414}
415#[doc = "Field `MONCLKSTR` writer - Monitor function Clock Stretching."]
416pub struct MONCLKSTR_W<'a> {
417    w: &'a mut W,
418}
419impl<'a> MONCLKSTR_W<'a> {
420    #[doc = r"Writes `variant` to the field"]
421    #[inline(always)]
422    pub fn variant(self, variant: MONCLKSTR_A) -> &'a mut W {
423        self.bit(variant.into())
424    }
425    #[doc = "Disabled. The Monitor function will not perform clock stretching. Software or DMA may not always be able to read data provided by the Monitor function before it is overwritten. This mode may be used when non-invasive monitoring is critical."]
426    #[inline(always)]
427    pub fn disabled(self) -> &'a mut W {
428        self.variant(MONCLKSTR_A::DISABLED)
429    }
430    #[doc = "Enabled. The Monitor function will perform clock stretching in order to ensure that software or DMA can read all incoming data supplied by the Monitor function."]
431    #[inline(always)]
432    pub fn enabled(self) -> &'a mut W {
433        self.variant(MONCLKSTR_A::ENABLED)
434    }
435    #[doc = r"Sets the field bit"]
436    #[inline(always)]
437    pub fn set_bit(self) -> &'a mut W {
438        self.bit(true)
439    }
440    #[doc = r"Clears the field bit"]
441    #[inline(always)]
442    pub fn clear_bit(self) -> &'a mut W {
443        self.bit(false)
444    }
445    #[doc = r"Writes raw bits to the field"]
446    #[inline(always)]
447    pub fn bit(self, value: bool) -> &'a mut W {
448        self.w.bits = (self.w.bits & !(0x01 << 4)) | ((value as u32 & 0x01) << 4);
449        self.w
450    }
451}
452impl R {
453    #[doc = "Bit 0 - Master Enable. When disabled, configurations settings for the Master function are not changed, but the Master function is internally reset."]
454    #[inline(always)]
455    pub fn msten(&self) -> MSTEN_R {
456        MSTEN_R::new((self.bits & 0x01) != 0)
457    }
458    #[doc = "Bit 1 - Slave Enable. When disabled, configurations settings for the Slave function are not changed, but the Slave function is internally reset."]
459    #[inline(always)]
460    pub fn slven(&self) -> SLVEN_R {
461        SLVEN_R::new(((self.bits >> 1) & 0x01) != 0)
462    }
463    #[doc = "Bit 2 - Monitor Enable. When disabled, configurations settings for the Monitor function are not changed, but the Monitor function is internally reset."]
464    #[inline(always)]
465    pub fn monen(&self) -> MONEN_R {
466        MONEN_R::new(((self.bits >> 2) & 0x01) != 0)
467    }
468    #[doc = "Bit 3 - I2C bus Time-out Enable. When disabled, the time-out function is internally reset."]
469    #[inline(always)]
470    pub fn timeouten(&self) -> TIMEOUTEN_R {
471        TIMEOUTEN_R::new(((self.bits >> 3) & 0x01) != 0)
472    }
473    #[doc = "Bit 4 - Monitor function Clock Stretching."]
474    #[inline(always)]
475    pub fn monclkstr(&self) -> MONCLKSTR_R {
476        MONCLKSTR_R::new(((self.bits >> 4) & 0x01) != 0)
477    }
478}
479impl W {
480    #[doc = "Bit 0 - Master Enable. When disabled, configurations settings for the Master function are not changed, but the Master function is internally reset."]
481    #[inline(always)]
482    pub fn msten(&mut self) -> MSTEN_W {
483        MSTEN_W { w: self }
484    }
485    #[doc = "Bit 1 - Slave Enable. When disabled, configurations settings for the Slave function are not changed, but the Slave function is internally reset."]
486    #[inline(always)]
487    pub fn slven(&mut self) -> SLVEN_W {
488        SLVEN_W { w: self }
489    }
490    #[doc = "Bit 2 - Monitor Enable. When disabled, configurations settings for the Monitor function are not changed, but the Monitor function is internally reset."]
491    #[inline(always)]
492    pub fn monen(&mut self) -> MONEN_W {
493        MONEN_W { w: self }
494    }
495    #[doc = "Bit 3 - I2C bus Time-out Enable. When disabled, the time-out function is internally reset."]
496    #[inline(always)]
497    pub fn timeouten(&mut self) -> TIMEOUTEN_W {
498        TIMEOUTEN_W { w: self }
499    }
500    #[doc = "Bit 4 - Monitor function Clock Stretching."]
501    #[inline(always)]
502    pub fn monclkstr(&mut self) -> MONCLKSTR_W {
503        MONCLKSTR_W { w: self }
504    }
505    #[doc = "Writes raw bits to the register."]
506    #[inline(always)]
507    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
508        self.0.bits(bits);
509        self
510    }
511}
512#[doc = "Configuration for shared functions.\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)."]
513pub struct CFG_SPEC;
514impl crate::RegisterSpec for CFG_SPEC {
515    type Ux = u32;
516}
517#[doc = "`read()` method returns [cfg::R](R) reader structure"]
518impl crate::Readable for CFG_SPEC {
519    type Reader = R;
520}
521#[doc = "`write(|w| ..)` method takes [cfg::W](W) writer structure"]
522impl crate::Writable for CFG_SPEC {
523    type Writer = W;
524}
525#[doc = "`reset()` method sets CFG to value 0"]
526impl crate::Resettable for CFG_SPEC {
527    #[inline(always)]
528    fn reset_value() -> Self::Ux {
529        0
530    }
531}