efm32tg11b_pac/efm32tg11b540/usart0/
timecmp1.rs

1#[doc = "Register `TIMECMP1` reader"]
2pub struct R(crate::R<TIMECMP1_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<TIMECMP1_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<TIMECMP1_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<TIMECMP1_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `TIMECMP1` writer"]
17pub struct W(crate::W<TIMECMP1_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<TIMECMP1_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<TIMECMP1_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<TIMECMP1_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `TCMPVAL` reader - Timer Comparator 1"]
38pub type TCMPVAL_R = crate::FieldReader<u8, u8>;
39#[doc = "Field `TCMPVAL` writer - Timer Comparator 1"]
40pub type TCMPVAL_W<'a, const O: u8> = crate::FieldWriter<'a, u32, TIMECMP1_SPEC, u8, u8, 8, O>;
41#[doc = "Field `TSTART` reader - Timer Start Source"]
42pub type TSTART_R = crate::FieldReader<u8, TSTART_A>;
43#[doc = "Timer Start Source\n\nValue on reset: 0"]
44#[derive(Clone, Copy, Debug, PartialEq, Eq)]
45#[repr(u8)]
46pub enum TSTART_A {
47    #[doc = "0: Comparator 1 is disabled"]
48    DISABLE = 0,
49    #[doc = "1: Comparator 1 and timer are started at TX end of frame"]
50    TXEOF = 1,
51    #[doc = "2: Comparator 1 and timer are started at TX Complete"]
52    TXC = 2,
53    #[doc = "3: Comparator 1 and timer are started at RX going going Active (default: low)"]
54    RXACT = 3,
55    #[doc = "4: Comparator 1 and timer are started at RX end of frame"]
56    RXEOF = 4,
57}
58impl From<TSTART_A> for u8 {
59    #[inline(always)]
60    fn from(variant: TSTART_A) -> Self {
61        variant as _
62    }
63}
64impl TSTART_R {
65    #[doc = "Get enumerated values variant"]
66    #[inline(always)]
67    pub fn variant(&self) -> Option<TSTART_A> {
68        match self.bits {
69            0 => Some(TSTART_A::DISABLE),
70            1 => Some(TSTART_A::TXEOF),
71            2 => Some(TSTART_A::TXC),
72            3 => Some(TSTART_A::RXACT),
73            4 => Some(TSTART_A::RXEOF),
74            _ => None,
75        }
76    }
77    #[doc = "Checks if the value of the field is `DISABLE`"]
78    #[inline(always)]
79    pub fn is_disable(&self) -> bool {
80        *self == TSTART_A::DISABLE
81    }
82    #[doc = "Checks if the value of the field is `TXEOF`"]
83    #[inline(always)]
84    pub fn is_txeof(&self) -> bool {
85        *self == TSTART_A::TXEOF
86    }
87    #[doc = "Checks if the value of the field is `TXC`"]
88    #[inline(always)]
89    pub fn is_txc(&self) -> bool {
90        *self == TSTART_A::TXC
91    }
92    #[doc = "Checks if the value of the field is `RXACT`"]
93    #[inline(always)]
94    pub fn is_rxact(&self) -> bool {
95        *self == TSTART_A::RXACT
96    }
97    #[doc = "Checks if the value of the field is `RXEOF`"]
98    #[inline(always)]
99    pub fn is_rxeof(&self) -> bool {
100        *self == TSTART_A::RXEOF
101    }
102}
103#[doc = "Field `TSTART` writer - Timer Start Source"]
104pub type TSTART_W<'a, const O: u8> = crate::FieldWriter<'a, u32, TIMECMP1_SPEC, u8, TSTART_A, 3, O>;
105impl<'a, const O: u8> TSTART_W<'a, O> {
106    #[doc = "Comparator 1 is disabled"]
107    #[inline(always)]
108    pub fn disable(self) -> &'a mut W {
109        self.variant(TSTART_A::DISABLE)
110    }
111    #[doc = "Comparator 1 and timer are started at TX end of frame"]
112    #[inline(always)]
113    pub fn txeof(self) -> &'a mut W {
114        self.variant(TSTART_A::TXEOF)
115    }
116    #[doc = "Comparator 1 and timer are started at TX Complete"]
117    #[inline(always)]
118    pub fn txc(self) -> &'a mut W {
119        self.variant(TSTART_A::TXC)
120    }
121    #[doc = "Comparator 1 and timer are started at RX going going Active (default: low)"]
122    #[inline(always)]
123    pub fn rxact(self) -> &'a mut W {
124        self.variant(TSTART_A::RXACT)
125    }
126    #[doc = "Comparator 1 and timer are started at RX end of frame"]
127    #[inline(always)]
128    pub fn rxeof(self) -> &'a mut W {
129        self.variant(TSTART_A::RXEOF)
130    }
131}
132#[doc = "Field `TSTOP` reader - Source Used to Disable Comparator 1"]
133pub type TSTOP_R = crate::FieldReader<u8, TSTOP_A>;
134#[doc = "Source Used to Disable Comparator 1\n\nValue on reset: 0"]
135#[derive(Clone, Copy, Debug, PartialEq, Eq)]
136#[repr(u8)]
137pub enum TSTOP_A {
138    #[doc = "0: Comparator 1 is disabled when the counter equals TCMPVAL and triggers a TCMP1 event"]
139    TCMP1 = 0,
140    #[doc = "1: Comparator 1 is disabled at TX start TX Engine"]
141    TXST = 1,
142    #[doc = "2: Comparator 1 is disabled on RX going going Active (default: low)"]
143    RXACT = 2,
144    #[doc = "3: Comparator 1 is disabled on RX going Inactive"]
145    RXACTN = 3,
146}
147impl From<TSTOP_A> for u8 {
148    #[inline(always)]
149    fn from(variant: TSTOP_A) -> Self {
150        variant as _
151    }
152}
153impl TSTOP_R {
154    #[doc = "Get enumerated values variant"]
155    #[inline(always)]
156    pub fn variant(&self) -> Option<TSTOP_A> {
157        match self.bits {
158            0 => Some(TSTOP_A::TCMP1),
159            1 => Some(TSTOP_A::TXST),
160            2 => Some(TSTOP_A::RXACT),
161            3 => Some(TSTOP_A::RXACTN),
162            _ => None,
163        }
164    }
165    #[doc = "Checks if the value of the field is `TCMP1`"]
166    #[inline(always)]
167    pub fn is_tcmp1(&self) -> bool {
168        *self == TSTOP_A::TCMP1
169    }
170    #[doc = "Checks if the value of the field is `TXST`"]
171    #[inline(always)]
172    pub fn is_txst(&self) -> bool {
173        *self == TSTOP_A::TXST
174    }
175    #[doc = "Checks if the value of the field is `RXACT`"]
176    #[inline(always)]
177    pub fn is_rxact(&self) -> bool {
178        *self == TSTOP_A::RXACT
179    }
180    #[doc = "Checks if the value of the field is `RXACTN`"]
181    #[inline(always)]
182    pub fn is_rxactn(&self) -> bool {
183        *self == TSTOP_A::RXACTN
184    }
185}
186#[doc = "Field `TSTOP` writer - Source Used to Disable Comparator 1"]
187pub type TSTOP_W<'a, const O: u8> = crate::FieldWriter<'a, u32, TIMECMP1_SPEC, u8, TSTOP_A, 3, O>;
188impl<'a, const O: u8> TSTOP_W<'a, O> {
189    #[doc = "Comparator 1 is disabled when the counter equals TCMPVAL and triggers a TCMP1 event"]
190    #[inline(always)]
191    pub fn tcmp1(self) -> &'a mut W {
192        self.variant(TSTOP_A::TCMP1)
193    }
194    #[doc = "Comparator 1 is disabled at TX start TX Engine"]
195    #[inline(always)]
196    pub fn txst(self) -> &'a mut W {
197        self.variant(TSTOP_A::TXST)
198    }
199    #[doc = "Comparator 1 is disabled on RX going going Active (default: low)"]
200    #[inline(always)]
201    pub fn rxact(self) -> &'a mut W {
202        self.variant(TSTOP_A::RXACT)
203    }
204    #[doc = "Comparator 1 is disabled on RX going Inactive"]
205    #[inline(always)]
206    pub fn rxactn(self) -> &'a mut W {
207        self.variant(TSTOP_A::RXACTN)
208    }
209}
210#[doc = "Field `RESTARTEN` reader - Restart Timer on TCMP1"]
211pub type RESTARTEN_R = crate::BitReader<bool>;
212#[doc = "Field `RESTARTEN` writer - Restart Timer on TCMP1"]
213pub type RESTARTEN_W<'a, const O: u8> = crate::BitWriter<'a, u32, TIMECMP1_SPEC, bool, O>;
214impl R {
215    #[doc = "Bits 0:7 - Timer Comparator 1"]
216    #[inline(always)]
217    pub fn tcmpval(&self) -> TCMPVAL_R {
218        TCMPVAL_R::new((self.bits & 0xff) as u8)
219    }
220    #[doc = "Bits 16:18 - Timer Start Source"]
221    #[inline(always)]
222    pub fn tstart(&self) -> TSTART_R {
223        TSTART_R::new(((self.bits >> 16) & 7) as u8)
224    }
225    #[doc = "Bits 20:22 - Source Used to Disable Comparator 1"]
226    #[inline(always)]
227    pub fn tstop(&self) -> TSTOP_R {
228        TSTOP_R::new(((self.bits >> 20) & 7) as u8)
229    }
230    #[doc = "Bit 24 - Restart Timer on TCMP1"]
231    #[inline(always)]
232    pub fn restarten(&self) -> RESTARTEN_R {
233        RESTARTEN_R::new(((self.bits >> 24) & 1) != 0)
234    }
235}
236impl W {
237    #[doc = "Bits 0:7 - Timer Comparator 1"]
238    #[inline(always)]
239    #[must_use]
240    pub fn tcmpval(&mut self) -> TCMPVAL_W<0> {
241        TCMPVAL_W::new(self)
242    }
243    #[doc = "Bits 16:18 - Timer Start Source"]
244    #[inline(always)]
245    #[must_use]
246    pub fn tstart(&mut self) -> TSTART_W<16> {
247        TSTART_W::new(self)
248    }
249    #[doc = "Bits 20:22 - Source Used to Disable Comparator 1"]
250    #[inline(always)]
251    #[must_use]
252    pub fn tstop(&mut self) -> TSTOP_W<20> {
253        TSTOP_W::new(self)
254    }
255    #[doc = "Bit 24 - Restart Timer on TCMP1"]
256    #[inline(always)]
257    #[must_use]
258    pub fn restarten(&mut self) -> RESTARTEN_W<24> {
259        RESTARTEN_W::new(self)
260    }
261    #[doc = "Writes raw bits to the register."]
262    #[inline(always)]
263    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
264        self.0.bits(bits);
265        self
266    }
267}
268#[doc = "Used to Generate Interrupts and Various Delays\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 [timecmp1](index.html) module"]
269pub struct TIMECMP1_SPEC;
270impl crate::RegisterSpec for TIMECMP1_SPEC {
271    type Ux = u32;
272}
273#[doc = "`read()` method returns [timecmp1::R](R) reader structure"]
274impl crate::Readable for TIMECMP1_SPEC {
275    type Reader = R;
276}
277#[doc = "`write(|w| ..)` method takes [timecmp1::W](W) writer structure"]
278impl crate::Writable for TIMECMP1_SPEC {
279    type Writer = W;
280    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
281    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
282}
283#[doc = "`reset()` method sets TIMECMP1 to value 0"]
284impl crate::Resettable for TIMECMP1_SPEC {
285    const RESET_VALUE: Self::Ux = 0;
286}