xr806_pac/twi0/
twi_lcr.rs

1#[doc = "Register `TWI_LCR` reader"]
2pub struct R(crate::R<TWI_LCR_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<TWI_LCR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<TWI_LCR_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<TWI_LCR_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `TWI_LCR` writer"]
17pub struct W(crate::W<TWI_LCR_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<TWI_LCR_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<TWI_LCR_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<TWI_LCR_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Current State of TWI_SCL\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39pub enum SCL_STATE_A {
40    #[doc = "0: `0`"]
41    LOW = 0,
42    #[doc = "1: `1`"]
43    HIGH = 1,
44}
45impl From<SCL_STATE_A> for bool {
46    #[inline(always)]
47    fn from(variant: SCL_STATE_A) -> Self {
48        variant as u8 != 0
49    }
50}
51#[doc = "Field `scl_state` reader - Current State of TWI_SCL"]
52pub struct SCL_STATE_R(crate::FieldReader<bool, SCL_STATE_A>);
53impl SCL_STATE_R {
54    #[inline(always)]
55    pub(crate) fn new(bits: bool) -> Self {
56        SCL_STATE_R(crate::FieldReader::new(bits))
57    }
58    #[doc = r"Get enumerated values variant"]
59    #[inline(always)]
60    pub fn variant(&self) -> SCL_STATE_A {
61        match self.bits {
62            false => SCL_STATE_A::LOW,
63            true => SCL_STATE_A::HIGH,
64        }
65    }
66    #[doc = "Checks if the value of the field is `LOW`"]
67    #[inline(always)]
68    pub fn is_low(&self) -> bool {
69        **self == SCL_STATE_A::LOW
70    }
71    #[doc = "Checks if the value of the field is `HIGH`"]
72    #[inline(always)]
73    pub fn is_high(&self) -> bool {
74        **self == SCL_STATE_A::HIGH
75    }
76}
77impl core::ops::Deref for SCL_STATE_R {
78    type Target = crate::FieldReader<bool, SCL_STATE_A>;
79    #[inline(always)]
80    fn deref(&self) -> &Self::Target {
81        &self.0
82    }
83}
84#[doc = "Current State of TWI_SDA\n\nValue on reset: 0"]
85#[derive(Clone, Copy, Debug, PartialEq)]
86pub enum SDA_STATE_A {
87    #[doc = "0: `0`"]
88    LOW = 0,
89    #[doc = "1: `1`"]
90    HIGH = 1,
91}
92impl From<SDA_STATE_A> for bool {
93    #[inline(always)]
94    fn from(variant: SDA_STATE_A) -> Self {
95        variant as u8 != 0
96    }
97}
98#[doc = "Field `sda_state` reader - Current State of TWI_SDA"]
99pub struct SDA_STATE_R(crate::FieldReader<bool, SDA_STATE_A>);
100impl SDA_STATE_R {
101    #[inline(always)]
102    pub(crate) fn new(bits: bool) -> Self {
103        SDA_STATE_R(crate::FieldReader::new(bits))
104    }
105    #[doc = r"Get enumerated values variant"]
106    #[inline(always)]
107    pub fn variant(&self) -> SDA_STATE_A {
108        match self.bits {
109            false => SDA_STATE_A::LOW,
110            true => SDA_STATE_A::HIGH,
111        }
112    }
113    #[doc = "Checks if the value of the field is `LOW`"]
114    #[inline(always)]
115    pub fn is_low(&self) -> bool {
116        **self == SDA_STATE_A::LOW
117    }
118    #[doc = "Checks if the value of the field is `HIGH`"]
119    #[inline(always)]
120    pub fn is_high(&self) -> bool {
121        **self == SDA_STATE_A::HIGH
122    }
123}
124impl core::ops::Deref for SDA_STATE_R {
125    type Target = crate::FieldReader<bool, SDA_STATE_A>;
126    #[inline(always)]
127    fn deref(&self) -> &Self::Target {
128        &self.0
129    }
130}
131#[doc = "TWI_SCL Line State Control Bit\n\nValue on reset: 0"]
132#[derive(Clone, Copy, Debug, PartialEq)]
133pub enum SCL_CTL_A {
134    #[doc = "0: `0`"]
135    LOW = 0,
136    #[doc = "1: `1`"]
137    HIGH = 1,
138}
139impl From<SCL_CTL_A> for bool {
140    #[inline(always)]
141    fn from(variant: SCL_CTL_A) -> Self {
142        variant as u8 != 0
143    }
144}
145#[doc = "Field `scl_ctl` reader - TWI_SCL Line State Control Bit"]
146pub struct SCL_CTL_R(crate::FieldReader<bool, SCL_CTL_A>);
147impl SCL_CTL_R {
148    #[inline(always)]
149    pub(crate) fn new(bits: bool) -> Self {
150        SCL_CTL_R(crate::FieldReader::new(bits))
151    }
152    #[doc = r"Get enumerated values variant"]
153    #[inline(always)]
154    pub fn variant(&self) -> SCL_CTL_A {
155        match self.bits {
156            false => SCL_CTL_A::LOW,
157            true => SCL_CTL_A::HIGH,
158        }
159    }
160    #[doc = "Checks if the value of the field is `LOW`"]
161    #[inline(always)]
162    pub fn is_low(&self) -> bool {
163        **self == SCL_CTL_A::LOW
164    }
165    #[doc = "Checks if the value of the field is `HIGH`"]
166    #[inline(always)]
167    pub fn is_high(&self) -> bool {
168        **self == SCL_CTL_A::HIGH
169    }
170}
171impl core::ops::Deref for SCL_CTL_R {
172    type Target = crate::FieldReader<bool, SCL_CTL_A>;
173    #[inline(always)]
174    fn deref(&self) -> &Self::Target {
175        &self.0
176    }
177}
178#[doc = "Field `scl_ctl` writer - TWI_SCL Line State Control Bit"]
179pub struct SCL_CTL_W<'a> {
180    w: &'a mut W,
181}
182impl<'a> SCL_CTL_W<'a> {
183    #[doc = r"Writes `variant` to the field"]
184    #[inline(always)]
185    pub fn variant(self, variant: SCL_CTL_A) -> &'a mut W {
186        self.bit(variant.into())
187    }
188    #[doc = "`0`"]
189    #[inline(always)]
190    pub fn low(self) -> &'a mut W {
191        self.variant(SCL_CTL_A::LOW)
192    }
193    #[doc = "`1`"]
194    #[inline(always)]
195    pub fn high(self) -> &'a mut W {
196        self.variant(SCL_CTL_A::HIGH)
197    }
198    #[doc = r"Sets the field bit"]
199    #[inline(always)]
200    pub fn set_bit(self) -> &'a mut W {
201        self.bit(true)
202    }
203    #[doc = r"Clears the field bit"]
204    #[inline(always)]
205    pub fn clear_bit(self) -> &'a mut W {
206        self.bit(false)
207    }
208    #[doc = r"Writes raw bits to the field"]
209    #[inline(always)]
210    pub fn bit(self, value: bool) -> &'a mut W {
211        self.w.bits = (self.w.bits & !(0x01 << 3)) | ((value as u32 & 0x01) << 3);
212        self.w
213    }
214}
215#[doc = "TWI_SCL Line State Control Enable\n\nValue on reset: 0"]
216#[derive(Clone, Copy, Debug, PartialEq)]
217pub enum SCL_CTL_EN_A {
218    #[doc = "0: `0`"]
219    DISABLE = 0,
220    #[doc = "1: `1`"]
221    ENABLE = 1,
222}
223impl From<SCL_CTL_EN_A> for bool {
224    #[inline(always)]
225    fn from(variant: SCL_CTL_EN_A) -> Self {
226        variant as u8 != 0
227    }
228}
229#[doc = "Field `scl_ctl_en` reader - TWI_SCL Line State Control Enable"]
230pub struct SCL_CTL_EN_R(crate::FieldReader<bool, SCL_CTL_EN_A>);
231impl SCL_CTL_EN_R {
232    #[inline(always)]
233    pub(crate) fn new(bits: bool) -> Self {
234        SCL_CTL_EN_R(crate::FieldReader::new(bits))
235    }
236    #[doc = r"Get enumerated values variant"]
237    #[inline(always)]
238    pub fn variant(&self) -> SCL_CTL_EN_A {
239        match self.bits {
240            false => SCL_CTL_EN_A::DISABLE,
241            true => SCL_CTL_EN_A::ENABLE,
242        }
243    }
244    #[doc = "Checks if the value of the field is `DISABLE`"]
245    #[inline(always)]
246    pub fn is_disable(&self) -> bool {
247        **self == SCL_CTL_EN_A::DISABLE
248    }
249    #[doc = "Checks if the value of the field is `ENABLE`"]
250    #[inline(always)]
251    pub fn is_enable(&self) -> bool {
252        **self == SCL_CTL_EN_A::ENABLE
253    }
254}
255impl core::ops::Deref for SCL_CTL_EN_R {
256    type Target = crate::FieldReader<bool, SCL_CTL_EN_A>;
257    #[inline(always)]
258    fn deref(&self) -> &Self::Target {
259        &self.0
260    }
261}
262#[doc = "Field `scl_ctl_en` writer - TWI_SCL Line State Control Enable"]
263pub struct SCL_CTL_EN_W<'a> {
264    w: &'a mut W,
265}
266impl<'a> SCL_CTL_EN_W<'a> {
267    #[doc = r"Writes `variant` to the field"]
268    #[inline(always)]
269    pub fn variant(self, variant: SCL_CTL_EN_A) -> &'a mut W {
270        self.bit(variant.into())
271    }
272    #[doc = "`0`"]
273    #[inline(always)]
274    pub fn disable(self) -> &'a mut W {
275        self.variant(SCL_CTL_EN_A::DISABLE)
276    }
277    #[doc = "`1`"]
278    #[inline(always)]
279    pub fn enable(self) -> &'a mut W {
280        self.variant(SCL_CTL_EN_A::ENABLE)
281    }
282    #[doc = r"Sets the field bit"]
283    #[inline(always)]
284    pub fn set_bit(self) -> &'a mut W {
285        self.bit(true)
286    }
287    #[doc = r"Clears the field bit"]
288    #[inline(always)]
289    pub fn clear_bit(self) -> &'a mut W {
290        self.bit(false)
291    }
292    #[doc = r"Writes raw bits to the field"]
293    #[inline(always)]
294    pub fn bit(self, value: bool) -> &'a mut W {
295        self.w.bits = (self.w.bits & !(0x01 << 2)) | ((value as u32 & 0x01) << 2);
296        self.w
297    }
298}
299#[doc = "TWI_SDA Line State Control Bit\n\nValue on reset: 0"]
300#[derive(Clone, Copy, Debug, PartialEq)]
301pub enum SDA_CTL_A {
302    #[doc = "0: `0`"]
303    LOW = 0,
304    #[doc = "1: `1`"]
305    HIGH = 1,
306}
307impl From<SDA_CTL_A> for bool {
308    #[inline(always)]
309    fn from(variant: SDA_CTL_A) -> Self {
310        variant as u8 != 0
311    }
312}
313#[doc = "Field `sda_ctl` reader - TWI_SDA Line State Control Bit"]
314pub struct SDA_CTL_R(crate::FieldReader<bool, SDA_CTL_A>);
315impl SDA_CTL_R {
316    #[inline(always)]
317    pub(crate) fn new(bits: bool) -> Self {
318        SDA_CTL_R(crate::FieldReader::new(bits))
319    }
320    #[doc = r"Get enumerated values variant"]
321    #[inline(always)]
322    pub fn variant(&self) -> SDA_CTL_A {
323        match self.bits {
324            false => SDA_CTL_A::LOW,
325            true => SDA_CTL_A::HIGH,
326        }
327    }
328    #[doc = "Checks if the value of the field is `LOW`"]
329    #[inline(always)]
330    pub fn is_low(&self) -> bool {
331        **self == SDA_CTL_A::LOW
332    }
333    #[doc = "Checks if the value of the field is `HIGH`"]
334    #[inline(always)]
335    pub fn is_high(&self) -> bool {
336        **self == SDA_CTL_A::HIGH
337    }
338}
339impl core::ops::Deref for SDA_CTL_R {
340    type Target = crate::FieldReader<bool, SDA_CTL_A>;
341    #[inline(always)]
342    fn deref(&self) -> &Self::Target {
343        &self.0
344    }
345}
346#[doc = "Field `sda_ctl` writer - TWI_SDA Line State Control Bit"]
347pub struct SDA_CTL_W<'a> {
348    w: &'a mut W,
349}
350impl<'a> SDA_CTL_W<'a> {
351    #[doc = r"Writes `variant` to the field"]
352    #[inline(always)]
353    pub fn variant(self, variant: SDA_CTL_A) -> &'a mut W {
354        self.bit(variant.into())
355    }
356    #[doc = "`0`"]
357    #[inline(always)]
358    pub fn low(self) -> &'a mut W {
359        self.variant(SDA_CTL_A::LOW)
360    }
361    #[doc = "`1`"]
362    #[inline(always)]
363    pub fn high(self) -> &'a mut W {
364        self.variant(SDA_CTL_A::HIGH)
365    }
366    #[doc = r"Sets the field bit"]
367    #[inline(always)]
368    pub fn set_bit(self) -> &'a mut W {
369        self.bit(true)
370    }
371    #[doc = r"Clears the field bit"]
372    #[inline(always)]
373    pub fn clear_bit(self) -> &'a mut W {
374        self.bit(false)
375    }
376    #[doc = r"Writes raw bits to the field"]
377    #[inline(always)]
378    pub fn bit(self, value: bool) -> &'a mut W {
379        self.w.bits = (self.w.bits & !(0x01 << 1)) | ((value as u32 & 0x01) << 1);
380        self.w
381    }
382}
383#[doc = "TWI_SDA Line State Control Enable\n\nValue on reset: 0"]
384#[derive(Clone, Copy, Debug, PartialEq)]
385pub enum SDA_CTL_EN_A {
386    #[doc = "0: `0`"]
387    DISABLE = 0,
388    #[doc = "1: `1`"]
389    ENABLE = 1,
390}
391impl From<SDA_CTL_EN_A> for bool {
392    #[inline(always)]
393    fn from(variant: SDA_CTL_EN_A) -> Self {
394        variant as u8 != 0
395    }
396}
397#[doc = "Field `sda_ctl_en` reader - TWI_SDA Line State Control Enable"]
398pub struct SDA_CTL_EN_R(crate::FieldReader<bool, SDA_CTL_EN_A>);
399impl SDA_CTL_EN_R {
400    #[inline(always)]
401    pub(crate) fn new(bits: bool) -> Self {
402        SDA_CTL_EN_R(crate::FieldReader::new(bits))
403    }
404    #[doc = r"Get enumerated values variant"]
405    #[inline(always)]
406    pub fn variant(&self) -> SDA_CTL_EN_A {
407        match self.bits {
408            false => SDA_CTL_EN_A::DISABLE,
409            true => SDA_CTL_EN_A::ENABLE,
410        }
411    }
412    #[doc = "Checks if the value of the field is `DISABLE`"]
413    #[inline(always)]
414    pub fn is_disable(&self) -> bool {
415        **self == SDA_CTL_EN_A::DISABLE
416    }
417    #[doc = "Checks if the value of the field is `ENABLE`"]
418    #[inline(always)]
419    pub fn is_enable(&self) -> bool {
420        **self == SDA_CTL_EN_A::ENABLE
421    }
422}
423impl core::ops::Deref for SDA_CTL_EN_R {
424    type Target = crate::FieldReader<bool, SDA_CTL_EN_A>;
425    #[inline(always)]
426    fn deref(&self) -> &Self::Target {
427        &self.0
428    }
429}
430#[doc = "Field `sda_ctl_en` writer - TWI_SDA Line State Control Enable"]
431pub struct SDA_CTL_EN_W<'a> {
432    w: &'a mut W,
433}
434impl<'a> SDA_CTL_EN_W<'a> {
435    #[doc = r"Writes `variant` to the field"]
436    #[inline(always)]
437    pub fn variant(self, variant: SDA_CTL_EN_A) -> &'a mut W {
438        self.bit(variant.into())
439    }
440    #[doc = "`0`"]
441    #[inline(always)]
442    pub fn disable(self) -> &'a mut W {
443        self.variant(SDA_CTL_EN_A::DISABLE)
444    }
445    #[doc = "`1`"]
446    #[inline(always)]
447    pub fn enable(self) -> &'a mut W {
448        self.variant(SDA_CTL_EN_A::ENABLE)
449    }
450    #[doc = r"Sets the field bit"]
451    #[inline(always)]
452    pub fn set_bit(self) -> &'a mut W {
453        self.bit(true)
454    }
455    #[doc = r"Clears the field bit"]
456    #[inline(always)]
457    pub fn clear_bit(self) -> &'a mut W {
458        self.bit(false)
459    }
460    #[doc = r"Writes raw bits to the field"]
461    #[inline(always)]
462    pub fn bit(self, value: bool) -> &'a mut W {
463        self.w.bits = (self.w.bits & !0x01) | (value as u32 & 0x01);
464        self.w
465    }
466}
467impl R {
468    #[doc = "Bit 5 - Current State of TWI_SCL"]
469    #[inline(always)]
470    pub fn scl_state(&self) -> SCL_STATE_R {
471        SCL_STATE_R::new(((self.bits >> 5) & 0x01) != 0)
472    }
473    #[doc = "Bit 4 - Current State of TWI_SDA"]
474    #[inline(always)]
475    pub fn sda_state(&self) -> SDA_STATE_R {
476        SDA_STATE_R::new(((self.bits >> 4) & 0x01) != 0)
477    }
478    #[doc = "Bit 3 - TWI_SCL Line State Control Bit"]
479    #[inline(always)]
480    pub fn scl_ctl(&self) -> SCL_CTL_R {
481        SCL_CTL_R::new(((self.bits >> 3) & 0x01) != 0)
482    }
483    #[doc = "Bit 2 - TWI_SCL Line State Control Enable"]
484    #[inline(always)]
485    pub fn scl_ctl_en(&self) -> SCL_CTL_EN_R {
486        SCL_CTL_EN_R::new(((self.bits >> 2) & 0x01) != 0)
487    }
488    #[doc = "Bit 1 - TWI_SDA Line State Control Bit"]
489    #[inline(always)]
490    pub fn sda_ctl(&self) -> SDA_CTL_R {
491        SDA_CTL_R::new(((self.bits >> 1) & 0x01) != 0)
492    }
493    #[doc = "Bit 0 - TWI_SDA Line State Control Enable"]
494    #[inline(always)]
495    pub fn sda_ctl_en(&self) -> SDA_CTL_EN_R {
496        SDA_CTL_EN_R::new((self.bits & 0x01) != 0)
497    }
498}
499impl W {
500    #[doc = "Bit 3 - TWI_SCL Line State Control Bit"]
501    #[inline(always)]
502    pub fn scl_ctl(&mut self) -> SCL_CTL_W {
503        SCL_CTL_W { w: self }
504    }
505    #[doc = "Bit 2 - TWI_SCL Line State Control Enable"]
506    #[inline(always)]
507    pub fn scl_ctl_en(&mut self) -> SCL_CTL_EN_W {
508        SCL_CTL_EN_W { w: self }
509    }
510    #[doc = "Bit 1 - TWI_SDA Line State Control Bit"]
511    #[inline(always)]
512    pub fn sda_ctl(&mut self) -> SDA_CTL_W {
513        SDA_CTL_W { w: self }
514    }
515    #[doc = "Bit 0 - TWI_SDA Line State Control Enable"]
516    #[inline(always)]
517    pub fn sda_ctl_en(&mut self) -> SDA_CTL_EN_W {
518        SDA_CTL_EN_W { w: self }
519    }
520    #[doc = "Writes raw bits to the register."]
521    #[inline(always)]
522    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
523        self.0.bits(bits);
524        self
525    }
526}
527#[doc = "TWI Line 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 [twi_lcr](index.html) module"]
528pub struct TWI_LCR_SPEC;
529impl crate::RegisterSpec for TWI_LCR_SPEC {
530    type Ux = u32;
531}
532#[doc = "`read()` method returns [twi_lcr::R](R) reader structure"]
533impl crate::Readable for TWI_LCR_SPEC {
534    type Reader = R;
535}
536#[doc = "`write(|w| ..)` method takes [twi_lcr::W](W) writer structure"]
537impl crate::Writable for TWI_LCR_SPEC {
538    type Writer = W;
539}
540#[doc = "`reset()` method sets TWI_LCR to value 0"]
541impl crate::Resettable for TWI_LCR_SPEC {
542    #[inline(always)]
543    fn reset_value() -> Self::Ux {
544        0
545    }
546}