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