efm32pg1b_pac/usart0/
timecmp1.rs

1///Register `TIMECMP1` reader
2pub type R = crate::R<TIMECMP1rs>;
3///Register `TIMECMP1` writer
4pub type W = crate::W<TIMECMP1rs>;
5///Field `TCMPVAL` reader - Timer Comparator 1
6pub type TcmpvalR = crate::FieldReader;
7///Field `TCMPVAL` writer - Timer Comparator 1
8pub type TcmpvalW<'a, REG> = crate::FieldWriter<'a, REG, 8>;
9///Timer Start Source
10///
11///Value on reset: 0
12#[cfg_attr(feature = "defmt", derive(defmt::Format))]
13#[derive(Clone, Copy, Debug, PartialEq, Eq)]
14#[repr(u8)]
15pub enum TSTART {
16    ///0: Comparator 1 is disabled
17    Disable = 0,
18    ///1: Comparator 1 and timer are started at TX end of frame
19    Txeof = 1,
20    ///2: Comparator 1 and timer are started at TX Complete
21    Txc = 2,
22    ///3: Comparator 1 and timer are started at RX going going Active (default: low)
23    Rxact = 3,
24    ///4: Comparator 1 and timer are started at RX end of frame
25    Rxeof = 4,
26}
27impl From<TSTART> for u8 {
28    #[inline(always)]
29    fn from(variant: TSTART) -> Self {
30        variant as _
31    }
32}
33impl crate::FieldSpec for TSTART {
34    type Ux = u8;
35}
36impl crate::IsEnum for TSTART {}
37///Field `TSTART` reader - Timer Start Source
38pub type TstartR = crate::FieldReader<TSTART>;
39impl TstartR {
40    ///Get enumerated values variant
41    #[inline(always)]
42    pub const fn variant(&self) -> Option<TSTART> {
43        match self.bits {
44            0 => Some(TSTART::Disable),
45            1 => Some(TSTART::Txeof),
46            2 => Some(TSTART::Txc),
47            3 => Some(TSTART::Rxact),
48            4 => Some(TSTART::Rxeof),
49            _ => None,
50        }
51    }
52    ///Comparator 1 is disabled
53    #[inline(always)]
54    pub fn is_disable(&self) -> bool {
55        *self == TSTART::Disable
56    }
57    ///Comparator 1 and timer are started at TX end of frame
58    #[inline(always)]
59    pub fn is_txeof(&self) -> bool {
60        *self == TSTART::Txeof
61    }
62    ///Comparator 1 and timer are started at TX Complete
63    #[inline(always)]
64    pub fn is_txc(&self) -> bool {
65        *self == TSTART::Txc
66    }
67    ///Comparator 1 and timer are started at RX going going Active (default: low)
68    #[inline(always)]
69    pub fn is_rxact(&self) -> bool {
70        *self == TSTART::Rxact
71    }
72    ///Comparator 1 and timer are started at RX end of frame
73    #[inline(always)]
74    pub fn is_rxeof(&self) -> bool {
75        *self == TSTART::Rxeof
76    }
77}
78///Field `TSTART` writer - Timer Start Source
79pub type TstartW<'a, REG> = crate::FieldWriter<'a, REG, 3, TSTART>;
80impl<'a, REG> TstartW<'a, REG>
81where
82    REG: crate::Writable + crate::RegisterSpec,
83    REG::Ux: From<u8>,
84{
85    ///Comparator 1 is disabled
86    #[inline(always)]
87    pub fn disable(self) -> &'a mut crate::W<REG> {
88        self.variant(TSTART::Disable)
89    }
90    ///Comparator 1 and timer are started at TX end of frame
91    #[inline(always)]
92    pub fn txeof(self) -> &'a mut crate::W<REG> {
93        self.variant(TSTART::Txeof)
94    }
95    ///Comparator 1 and timer are started at TX Complete
96    #[inline(always)]
97    pub fn txc(self) -> &'a mut crate::W<REG> {
98        self.variant(TSTART::Txc)
99    }
100    ///Comparator 1 and timer are started at RX going going Active (default: low)
101    #[inline(always)]
102    pub fn rxact(self) -> &'a mut crate::W<REG> {
103        self.variant(TSTART::Rxact)
104    }
105    ///Comparator 1 and timer are started at RX end of frame
106    #[inline(always)]
107    pub fn rxeof(self) -> &'a mut crate::W<REG> {
108        self.variant(TSTART::Rxeof)
109    }
110}
111///Source Used to Disable Comparator 1
112///
113///Value on reset: 0
114#[cfg_attr(feature = "defmt", derive(defmt::Format))]
115#[derive(Clone, Copy, Debug, PartialEq, Eq)]
116#[repr(u8)]
117pub enum TSTOP {
118    ///0: Comparator 1 is disabled when the counter equals TCMPVAL and triggers a TCMP1 event
119    Tcmp1 = 0,
120    ///1: Comparator 1 is disabled at TX start TX Engine
121    Txst = 1,
122    ///2: Comparator 1 is disabled on RX going going Active (default: low)
123    Rxact = 2,
124    ///3: Comparator 1 is disabled on RX going Inactive
125    Rxactn = 3,
126}
127impl From<TSTOP> for u8 {
128    #[inline(always)]
129    fn from(variant: TSTOP) -> Self {
130        variant as _
131    }
132}
133impl crate::FieldSpec for TSTOP {
134    type Ux = u8;
135}
136impl crate::IsEnum for TSTOP {}
137///Field `TSTOP` reader - Source Used to Disable Comparator 1
138pub type TstopR = crate::FieldReader<TSTOP>;
139impl TstopR {
140    ///Get enumerated values variant
141    #[inline(always)]
142    pub const fn variant(&self) -> Option<TSTOP> {
143        match self.bits {
144            0 => Some(TSTOP::Tcmp1),
145            1 => Some(TSTOP::Txst),
146            2 => Some(TSTOP::Rxact),
147            3 => Some(TSTOP::Rxactn),
148            _ => None,
149        }
150    }
151    ///Comparator 1 is disabled when the counter equals TCMPVAL and triggers a TCMP1 event
152    #[inline(always)]
153    pub fn is_tcmp1(&self) -> bool {
154        *self == TSTOP::Tcmp1
155    }
156    ///Comparator 1 is disabled at TX start TX Engine
157    #[inline(always)]
158    pub fn is_txst(&self) -> bool {
159        *self == TSTOP::Txst
160    }
161    ///Comparator 1 is disabled on RX going going Active (default: low)
162    #[inline(always)]
163    pub fn is_rxact(&self) -> bool {
164        *self == TSTOP::Rxact
165    }
166    ///Comparator 1 is disabled on RX going Inactive
167    #[inline(always)]
168    pub fn is_rxactn(&self) -> bool {
169        *self == TSTOP::Rxactn
170    }
171}
172///Field `TSTOP` writer - Source Used to Disable Comparator 1
173pub type TstopW<'a, REG> = crate::FieldWriter<'a, REG, 3, TSTOP>;
174impl<'a, REG> TstopW<'a, REG>
175where
176    REG: crate::Writable + crate::RegisterSpec,
177    REG::Ux: From<u8>,
178{
179    ///Comparator 1 is disabled when the counter equals TCMPVAL and triggers a TCMP1 event
180    #[inline(always)]
181    pub fn tcmp1(self) -> &'a mut crate::W<REG> {
182        self.variant(TSTOP::Tcmp1)
183    }
184    ///Comparator 1 is disabled at TX start TX Engine
185    #[inline(always)]
186    pub fn txst(self) -> &'a mut crate::W<REG> {
187        self.variant(TSTOP::Txst)
188    }
189    ///Comparator 1 is disabled on RX going going Active (default: low)
190    #[inline(always)]
191    pub fn rxact(self) -> &'a mut crate::W<REG> {
192        self.variant(TSTOP::Rxact)
193    }
194    ///Comparator 1 is disabled on RX going Inactive
195    #[inline(always)]
196    pub fn rxactn(self) -> &'a mut crate::W<REG> {
197        self.variant(TSTOP::Rxactn)
198    }
199}
200///Field `RESTARTEN` reader - Restart Timer on TCMP1
201pub type RestartenR = crate::BitReader;
202///Field `RESTARTEN` writer - Restart Timer on TCMP1
203pub type RestartenW<'a, REG> = crate::BitWriter<'a, REG>;
204impl R {
205    ///Bits 0:7 - Timer Comparator 1
206    #[inline(always)]
207    pub fn tcmpval(&self) -> TcmpvalR {
208        TcmpvalR::new((self.bits & 0xff) as u8)
209    }
210    ///Bits 16:18 - Timer Start Source
211    #[inline(always)]
212    pub fn tstart(&self) -> TstartR {
213        TstartR::new(((self.bits >> 16) & 7) as u8)
214    }
215    ///Bits 20:22 - Source Used to Disable Comparator 1
216    #[inline(always)]
217    pub fn tstop(&self) -> TstopR {
218        TstopR::new(((self.bits >> 20) & 7) as u8)
219    }
220    ///Bit 24 - Restart Timer on TCMP1
221    #[inline(always)]
222    pub fn restarten(&self) -> RestartenR {
223        RestartenR::new(((self.bits >> 24) & 1) != 0)
224    }
225}
226impl core::fmt::Debug for R {
227    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
228        f.debug_struct("TIMECMP1")
229            .field("tcmpval", &self.tcmpval())
230            .field("tstart", &self.tstart())
231            .field("tstop", &self.tstop())
232            .field("restarten", &self.restarten())
233            .finish()
234    }
235}
236impl W {
237    ///Bits 0:7 - Timer Comparator 1
238    #[inline(always)]
239    pub fn tcmpval(&mut self) -> TcmpvalW<TIMECMP1rs> {
240        TcmpvalW::new(self, 0)
241    }
242    ///Bits 16:18 - Timer Start Source
243    #[inline(always)]
244    pub fn tstart(&mut self) -> TstartW<TIMECMP1rs> {
245        TstartW::new(self, 16)
246    }
247    ///Bits 20:22 - Source Used to Disable Comparator 1
248    #[inline(always)]
249    pub fn tstop(&mut self) -> TstopW<TIMECMP1rs> {
250        TstopW::new(self, 20)
251    }
252    ///Bit 24 - Restart Timer on TCMP1
253    #[inline(always)]
254    pub fn restarten(&mut self) -> RestartenW<TIMECMP1rs> {
255        RestartenW::new(self, 24)
256    }
257}
258///Used to Generate Interrupts and Various Delays
259///
260///You can [`read`](crate::Reg::read) this register and get [`timecmp1::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`timecmp1::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api).
261pub struct TIMECMP1rs;
262impl crate::RegisterSpec for TIMECMP1rs {
263    type Ux = u32;
264}
265///`read()` method returns [`timecmp1::R`](R) reader structure
266impl crate::Readable for TIMECMP1rs {}
267///`write(|w| ..)` method takes [`timecmp1::W`](W) writer structure
268impl crate::Writable for TIMECMP1rs {
269    type Safety = crate::Unsafe;
270    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
271    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
272}
273///`reset()` method sets TIMECMP1 to value 0
274impl crate::Resettable for TIMECMP1rs {
275    const RESET_VALUE: u32 = 0;
276}