efm32pg12_pac/usart0/
timecmp2.rs

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