efm32pg22_pac/efm32pg22c200/usart1_ns/
irctrl.rs

1#[doc = "Register `IRCTRL` reader"]
2pub struct R(crate::R<IRCTRL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<IRCTRL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<IRCTRL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<IRCTRL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `IRCTRL` writer"]
17pub struct W(crate::W<IRCTRL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<IRCTRL_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<IRCTRL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<IRCTRL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `IREN` reader - Enable IrDA Module"]
38pub type IREN_R = crate::BitReader<bool>;
39#[doc = "Field `IREN` writer - Enable IrDA Module"]
40pub type IREN_W<'a, const O: u8> = crate::BitWriter<'a, u32, IRCTRL_SPEC, bool, O>;
41#[doc = "Field `IRPW` reader - IrDA TX Pulse Width"]
42pub type IRPW_R = crate::FieldReader<u8, IRPW_A>;
43#[doc = "IrDA TX Pulse Width\n\nValue on reset: 0"]
44#[derive(Clone, Copy, Debug, PartialEq, Eq)]
45#[repr(u8)]
46pub enum IRPW_A {
47    #[doc = "0: IrDA pulse width is 1/16 for OVS=0 and 1/8 for OVS=1"]
48    ONE = 0,
49    #[doc = "1: IrDA pulse width is 2/16 for OVS=0 and 2/8 for OVS=1"]
50    TWO = 1,
51    #[doc = "2: IrDA pulse width is 3/16 for OVS=0 and 3/8 for OVS=1"]
52    THREE = 2,
53    #[doc = "3: IrDA pulse width is 4/16 for OVS=0 and 4/8 for OVS=1"]
54    FOUR = 3,
55}
56impl From<IRPW_A> for u8 {
57    #[inline(always)]
58    fn from(variant: IRPW_A) -> Self {
59        variant as _
60    }
61}
62impl IRPW_R {
63    #[doc = "Get enumerated values variant"]
64    #[inline(always)]
65    pub fn variant(&self) -> IRPW_A {
66        match self.bits {
67            0 => IRPW_A::ONE,
68            1 => IRPW_A::TWO,
69            2 => IRPW_A::THREE,
70            3 => IRPW_A::FOUR,
71            _ => unreachable!(),
72        }
73    }
74    #[doc = "Checks if the value of the field is `ONE`"]
75    #[inline(always)]
76    pub fn is_one(&self) -> bool {
77        *self == IRPW_A::ONE
78    }
79    #[doc = "Checks if the value of the field is `TWO`"]
80    #[inline(always)]
81    pub fn is_two(&self) -> bool {
82        *self == IRPW_A::TWO
83    }
84    #[doc = "Checks if the value of the field is `THREE`"]
85    #[inline(always)]
86    pub fn is_three(&self) -> bool {
87        *self == IRPW_A::THREE
88    }
89    #[doc = "Checks if the value of the field is `FOUR`"]
90    #[inline(always)]
91    pub fn is_four(&self) -> bool {
92        *self == IRPW_A::FOUR
93    }
94}
95#[doc = "Field `IRPW` writer - IrDA TX Pulse Width"]
96pub type IRPW_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u32, IRCTRL_SPEC, u8, IRPW_A, 2, O>;
97impl<'a, const O: u8> IRPW_W<'a, O> {
98    #[doc = "IrDA pulse width is 1/16 for OVS=0 and 1/8 for OVS=1"]
99    #[inline(always)]
100    pub fn one(self) -> &'a mut W {
101        self.variant(IRPW_A::ONE)
102    }
103    #[doc = "IrDA pulse width is 2/16 for OVS=0 and 2/8 for OVS=1"]
104    #[inline(always)]
105    pub fn two(self) -> &'a mut W {
106        self.variant(IRPW_A::TWO)
107    }
108    #[doc = "IrDA pulse width is 3/16 for OVS=0 and 3/8 for OVS=1"]
109    #[inline(always)]
110    pub fn three(self) -> &'a mut W {
111        self.variant(IRPW_A::THREE)
112    }
113    #[doc = "IrDA pulse width is 4/16 for OVS=0 and 4/8 for OVS=1"]
114    #[inline(always)]
115    pub fn four(self) -> &'a mut W {
116        self.variant(IRPW_A::FOUR)
117    }
118}
119#[doc = "Field `IRFILT` reader - IrDA RX Filter"]
120pub type IRFILT_R = crate::BitReader<IRFILT_A>;
121#[doc = "IrDA RX Filter\n\nValue on reset: 0"]
122#[derive(Clone, Copy, Debug, PartialEq, Eq)]
123pub enum IRFILT_A {
124    #[doc = "0: No filter enabled"]
125    DISABLE = 0,
126    #[doc = "1: Filter enabled. IrDA pulse must be high for at least 5 consecutive clock cycles to be detected"]
127    ENABLE = 1,
128}
129impl From<IRFILT_A> for bool {
130    #[inline(always)]
131    fn from(variant: IRFILT_A) -> Self {
132        variant as u8 != 0
133    }
134}
135impl IRFILT_R {
136    #[doc = "Get enumerated values variant"]
137    #[inline(always)]
138    pub fn variant(&self) -> IRFILT_A {
139        match self.bits {
140            false => IRFILT_A::DISABLE,
141            true => IRFILT_A::ENABLE,
142        }
143    }
144    #[doc = "Checks if the value of the field is `DISABLE`"]
145    #[inline(always)]
146    pub fn is_disable(&self) -> bool {
147        *self == IRFILT_A::DISABLE
148    }
149    #[doc = "Checks if the value of the field is `ENABLE`"]
150    #[inline(always)]
151    pub fn is_enable(&self) -> bool {
152        *self == IRFILT_A::ENABLE
153    }
154}
155#[doc = "Field `IRFILT` writer - IrDA RX Filter"]
156pub type IRFILT_W<'a, const O: u8> = crate::BitWriter<'a, u32, IRCTRL_SPEC, IRFILT_A, O>;
157impl<'a, const O: u8> IRFILT_W<'a, O> {
158    #[doc = "No filter enabled"]
159    #[inline(always)]
160    pub fn disable(self) -> &'a mut W {
161        self.variant(IRFILT_A::DISABLE)
162    }
163    #[doc = "Filter enabled. IrDA pulse must be high for at least 5 consecutive clock cycles to be detected"]
164    #[inline(always)]
165    pub fn enable(self) -> &'a mut W {
166        self.variant(IRFILT_A::ENABLE)
167    }
168}
169impl R {
170    #[doc = "Bit 0 - Enable IrDA Module"]
171    #[inline(always)]
172    pub fn iren(&self) -> IREN_R {
173        IREN_R::new((self.bits & 1) != 0)
174    }
175    #[doc = "Bits 1:2 - IrDA TX Pulse Width"]
176    #[inline(always)]
177    pub fn irpw(&self) -> IRPW_R {
178        IRPW_R::new(((self.bits >> 1) & 3) as u8)
179    }
180    #[doc = "Bit 3 - IrDA RX Filter"]
181    #[inline(always)]
182    pub fn irfilt(&self) -> IRFILT_R {
183        IRFILT_R::new(((self.bits >> 3) & 1) != 0)
184    }
185}
186impl W {
187    #[doc = "Bit 0 - Enable IrDA Module"]
188    #[inline(always)]
189    #[must_use]
190    pub fn iren(&mut self) -> IREN_W<0> {
191        IREN_W::new(self)
192    }
193    #[doc = "Bits 1:2 - IrDA TX Pulse Width"]
194    #[inline(always)]
195    #[must_use]
196    pub fn irpw(&mut self) -> IRPW_W<1> {
197        IRPW_W::new(self)
198    }
199    #[doc = "Bit 3 - IrDA RX Filter"]
200    #[inline(always)]
201    #[must_use]
202    pub fn irfilt(&mut self) -> IRFILT_W<3> {
203        IRFILT_W::new(self)
204    }
205    #[doc = "Writes raw bits to the register."]
206    #[inline(always)]
207    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
208        self.0.bits(bits);
209        self
210    }
211}
212#[doc = "No Description\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 [irctrl](index.html) module"]
213pub struct IRCTRL_SPEC;
214impl crate::RegisterSpec for IRCTRL_SPEC {
215    type Ux = u32;
216}
217#[doc = "`read()` method returns [irctrl::R](R) reader structure"]
218impl crate::Readable for IRCTRL_SPEC {
219    type Reader = R;
220}
221#[doc = "`write(|w| ..)` method takes [irctrl::W](W) writer structure"]
222impl crate::Writable for IRCTRL_SPEC {
223    type Writer = W;
224    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
225    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
226}
227#[doc = "`reset()` method sets IRCTRL to value 0"]
228impl crate::Resettable for IRCTRL_SPEC {
229    const RESET_VALUE: Self::Ux = 0;
230}