atsamd21g/tcc0/
waveb.rs

1#[doc = "Register `WAVEB` reader"]
2pub type R = crate::R<WavebSpec>;
3#[doc = "Register `WAVEB` writer"]
4pub type W = crate::W<WavebSpec>;
5#[doc = "Waveform Generation Buffer\n\nValue on reset: 0"]
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7#[repr(u8)]
8pub enum Wavegenbselect {
9    #[doc = "0: Normal frequency"]
10    Nfrq = 0,
11    #[doc = "1: Match frequency"]
12    Mfrq = 1,
13    #[doc = "2: Normal PWM"]
14    Npwm = 2,
15    #[doc = "4: Dual-slope critical"]
16    Dscritical = 4,
17    #[doc = "5: Dual-slope with interrupt/event condition when COUNT reaches ZERO"]
18    Dsbottom = 5,
19    #[doc = "6: Dual-slope with interrupt/event condition when COUNT reaches ZERO or TOP"]
20    Dsboth = 6,
21    #[doc = "7: Dual-slope with interrupt/event condition when COUNT reaches TOP"]
22    Dstop = 7,
23}
24impl From<Wavegenbselect> for u8 {
25    #[inline(always)]
26    fn from(variant: Wavegenbselect) -> Self {
27        variant as _
28    }
29}
30impl crate::FieldSpec for Wavegenbselect {
31    type Ux = u8;
32}
33impl crate::IsEnum for Wavegenbselect {}
34#[doc = "Field `WAVEGENB` reader - Waveform Generation Buffer"]
35pub type WavegenbR = crate::FieldReader<Wavegenbselect>;
36impl WavegenbR {
37    #[doc = "Get enumerated values variant"]
38    #[inline(always)]
39    pub const fn variant(&self) -> Option<Wavegenbselect> {
40        match self.bits {
41            0 => Some(Wavegenbselect::Nfrq),
42            1 => Some(Wavegenbselect::Mfrq),
43            2 => Some(Wavegenbselect::Npwm),
44            4 => Some(Wavegenbselect::Dscritical),
45            5 => Some(Wavegenbselect::Dsbottom),
46            6 => Some(Wavegenbselect::Dsboth),
47            7 => Some(Wavegenbselect::Dstop),
48            _ => None,
49        }
50    }
51    #[doc = "Normal frequency"]
52    #[inline(always)]
53    pub fn is_nfrq(&self) -> bool {
54        *self == Wavegenbselect::Nfrq
55    }
56    #[doc = "Match frequency"]
57    #[inline(always)]
58    pub fn is_mfrq(&self) -> bool {
59        *self == Wavegenbselect::Mfrq
60    }
61    #[doc = "Normal PWM"]
62    #[inline(always)]
63    pub fn is_npwm(&self) -> bool {
64        *self == Wavegenbselect::Npwm
65    }
66    #[doc = "Dual-slope critical"]
67    #[inline(always)]
68    pub fn is_dscritical(&self) -> bool {
69        *self == Wavegenbselect::Dscritical
70    }
71    #[doc = "Dual-slope with interrupt/event condition when COUNT reaches ZERO"]
72    #[inline(always)]
73    pub fn is_dsbottom(&self) -> bool {
74        *self == Wavegenbselect::Dsbottom
75    }
76    #[doc = "Dual-slope with interrupt/event condition when COUNT reaches ZERO or TOP"]
77    #[inline(always)]
78    pub fn is_dsboth(&self) -> bool {
79        *self == Wavegenbselect::Dsboth
80    }
81    #[doc = "Dual-slope with interrupt/event condition when COUNT reaches TOP"]
82    #[inline(always)]
83    pub fn is_dstop(&self) -> bool {
84        *self == Wavegenbselect::Dstop
85    }
86}
87#[doc = "Field `WAVEGENB` writer - Waveform Generation Buffer"]
88pub type WavegenbW<'a, REG> = crate::FieldWriter<'a, REG, 3, Wavegenbselect>;
89impl<'a, REG> WavegenbW<'a, REG>
90where
91    REG: crate::Writable + crate::RegisterSpec,
92    REG::Ux: From<u8>,
93{
94    #[doc = "Normal frequency"]
95    #[inline(always)]
96    pub fn nfrq(self) -> &'a mut crate::W<REG> {
97        self.variant(Wavegenbselect::Nfrq)
98    }
99    #[doc = "Match frequency"]
100    #[inline(always)]
101    pub fn mfrq(self) -> &'a mut crate::W<REG> {
102        self.variant(Wavegenbselect::Mfrq)
103    }
104    #[doc = "Normal PWM"]
105    #[inline(always)]
106    pub fn npwm(self) -> &'a mut crate::W<REG> {
107        self.variant(Wavegenbselect::Npwm)
108    }
109    #[doc = "Dual-slope critical"]
110    #[inline(always)]
111    pub fn dscritical(self) -> &'a mut crate::W<REG> {
112        self.variant(Wavegenbselect::Dscritical)
113    }
114    #[doc = "Dual-slope with interrupt/event condition when COUNT reaches ZERO"]
115    #[inline(always)]
116    pub fn dsbottom(self) -> &'a mut crate::W<REG> {
117        self.variant(Wavegenbselect::Dsbottom)
118    }
119    #[doc = "Dual-slope with interrupt/event condition when COUNT reaches ZERO or TOP"]
120    #[inline(always)]
121    pub fn dsboth(self) -> &'a mut crate::W<REG> {
122        self.variant(Wavegenbselect::Dsboth)
123    }
124    #[doc = "Dual-slope with interrupt/event condition when COUNT reaches TOP"]
125    #[inline(always)]
126    pub fn dstop(self) -> &'a mut crate::W<REG> {
127        self.variant(Wavegenbselect::Dstop)
128    }
129}
130#[doc = "Ramp Mode Buffer\n\nValue on reset: 0"]
131#[derive(Clone, Copy, Debug, PartialEq, Eq)]
132#[repr(u8)]
133pub enum Rampbselect {
134    #[doc = "0: RAMP1 operation"]
135    Ramp1 = 0,
136    #[doc = "1: Alternative RAMP2 operation"]
137    Ramp2a = 1,
138    #[doc = "2: RAMP2 operation"]
139    Ramp2 = 2,
140}
141impl From<Rampbselect> for u8 {
142    #[inline(always)]
143    fn from(variant: Rampbselect) -> Self {
144        variant as _
145    }
146}
147impl crate::FieldSpec for Rampbselect {
148    type Ux = u8;
149}
150impl crate::IsEnum for Rampbselect {}
151#[doc = "Field `RAMPB` reader - Ramp Mode Buffer"]
152pub type RampbR = crate::FieldReader<Rampbselect>;
153impl RampbR {
154    #[doc = "Get enumerated values variant"]
155    #[inline(always)]
156    pub const fn variant(&self) -> Option<Rampbselect> {
157        match self.bits {
158            0 => Some(Rampbselect::Ramp1),
159            1 => Some(Rampbselect::Ramp2a),
160            2 => Some(Rampbselect::Ramp2),
161            _ => None,
162        }
163    }
164    #[doc = "RAMP1 operation"]
165    #[inline(always)]
166    pub fn is_ramp1(&self) -> bool {
167        *self == Rampbselect::Ramp1
168    }
169    #[doc = "Alternative RAMP2 operation"]
170    #[inline(always)]
171    pub fn is_ramp2a(&self) -> bool {
172        *self == Rampbselect::Ramp2a
173    }
174    #[doc = "RAMP2 operation"]
175    #[inline(always)]
176    pub fn is_ramp2(&self) -> bool {
177        *self == Rampbselect::Ramp2
178    }
179}
180#[doc = "Field `RAMPB` writer - Ramp Mode Buffer"]
181pub type RampbW<'a, REG> = crate::FieldWriter<'a, REG, 2, Rampbselect>;
182impl<'a, REG> RampbW<'a, REG>
183where
184    REG: crate::Writable + crate::RegisterSpec,
185    REG::Ux: From<u8>,
186{
187    #[doc = "RAMP1 operation"]
188    #[inline(always)]
189    pub fn ramp1(self) -> &'a mut crate::W<REG> {
190        self.variant(Rampbselect::Ramp1)
191    }
192    #[doc = "Alternative RAMP2 operation"]
193    #[inline(always)]
194    pub fn ramp2a(self) -> &'a mut crate::W<REG> {
195        self.variant(Rampbselect::Ramp2a)
196    }
197    #[doc = "RAMP2 operation"]
198    #[inline(always)]
199    pub fn ramp2(self) -> &'a mut crate::W<REG> {
200        self.variant(Rampbselect::Ramp2)
201    }
202}
203#[doc = "Field `CIPERENB` reader - Circular Period Enable Buffer"]
204pub type CiperenbR = crate::BitReader;
205#[doc = "Field `CIPERENB` writer - Circular Period Enable Buffer"]
206pub type CiperenbW<'a, REG> = crate::BitWriter<'a, REG>;
207#[doc = "Field `CICCENB0` reader - Circular Channel 0 Enable Buffer"]
208pub type Ciccenb0R = crate::BitReader;
209#[doc = "Field `CICCENB0` writer - Circular Channel 0 Enable Buffer"]
210pub type Ciccenb0W<'a, REG> = crate::BitWriter<'a, REG>;
211#[doc = "Field `CICCENB1` reader - Circular Channel 1 Enable Buffer"]
212pub type Ciccenb1R = crate::BitReader;
213#[doc = "Field `CICCENB1` writer - Circular Channel 1 Enable Buffer"]
214pub type Ciccenb1W<'a, REG> = crate::BitWriter<'a, REG>;
215#[doc = "Field `CICCENB2` reader - Circular Channel 2 Enable Buffer"]
216pub type Ciccenb2R = crate::BitReader;
217#[doc = "Field `CICCENB2` writer - Circular Channel 2 Enable Buffer"]
218pub type Ciccenb2W<'a, REG> = crate::BitWriter<'a, REG>;
219#[doc = "Field `CICCENB3` reader - Circular Channel 3 Enable Buffer"]
220pub type Ciccenb3R = crate::BitReader;
221#[doc = "Field `CICCENB3` writer - Circular Channel 3 Enable Buffer"]
222pub type Ciccenb3W<'a, REG> = crate::BitWriter<'a, REG>;
223#[doc = "Field `POLB0` reader - Channel 0 Polarity Buffer"]
224pub type Polb0R = crate::BitReader;
225#[doc = "Field `POLB0` writer - Channel 0 Polarity Buffer"]
226pub type Polb0W<'a, REG> = crate::BitWriter<'a, REG>;
227#[doc = "Field `POLB1` reader - Channel 1 Polarity Buffer"]
228pub type Polb1R = crate::BitReader;
229#[doc = "Field `POLB1` writer - Channel 1 Polarity Buffer"]
230pub type Polb1W<'a, REG> = crate::BitWriter<'a, REG>;
231#[doc = "Field `POLB2` reader - Channel 2 Polarity Buffer"]
232pub type Polb2R = crate::BitReader;
233#[doc = "Field `POLB2` writer - Channel 2 Polarity Buffer"]
234pub type Polb2W<'a, REG> = crate::BitWriter<'a, REG>;
235#[doc = "Field `POLB3` reader - Channel 3 Polarity Buffer"]
236pub type Polb3R = crate::BitReader;
237#[doc = "Field `POLB3` writer - Channel 3 Polarity Buffer"]
238pub type Polb3W<'a, REG> = crate::BitWriter<'a, REG>;
239#[doc = "Field `SWAPB0` reader - Swap DTI Output Pair 0 Buffer"]
240pub type Swapb0R = crate::BitReader;
241#[doc = "Field `SWAPB0` writer - Swap DTI Output Pair 0 Buffer"]
242pub type Swapb0W<'a, REG> = crate::BitWriter<'a, REG>;
243#[doc = "Field `SWAPB1` reader - Swap DTI Output Pair 1 Buffer"]
244pub type Swapb1R = crate::BitReader;
245#[doc = "Field `SWAPB1` writer - Swap DTI Output Pair 1 Buffer"]
246pub type Swapb1W<'a, REG> = crate::BitWriter<'a, REG>;
247#[doc = "Field `SWAPB2` reader - Swap DTI Output Pair 2 Buffer"]
248pub type Swapb2R = crate::BitReader;
249#[doc = "Field `SWAPB2` writer - Swap DTI Output Pair 2 Buffer"]
250pub type Swapb2W<'a, REG> = crate::BitWriter<'a, REG>;
251#[doc = "Field `SWAPB3` reader - Swap DTI Output Pair 3 Buffer"]
252pub type Swapb3R = crate::BitReader;
253#[doc = "Field `SWAPB3` writer - Swap DTI Output Pair 3 Buffer"]
254pub type Swapb3W<'a, REG> = crate::BitWriter<'a, REG>;
255impl R {
256    #[doc = "Bits 0:2 - Waveform Generation Buffer"]
257    #[inline(always)]
258    pub fn wavegenb(&self) -> WavegenbR {
259        WavegenbR::new((self.bits & 7) as u8)
260    }
261    #[doc = "Bits 4:5 - Ramp Mode Buffer"]
262    #[inline(always)]
263    pub fn rampb(&self) -> RampbR {
264        RampbR::new(((self.bits >> 4) & 3) as u8)
265    }
266    #[doc = "Bit 7 - Circular Period Enable Buffer"]
267    #[inline(always)]
268    pub fn ciperenb(&self) -> CiperenbR {
269        CiperenbR::new(((self.bits >> 7) & 1) != 0)
270    }
271    #[doc = "Bit 8 - Circular Channel 0 Enable Buffer"]
272    #[inline(always)]
273    pub fn ciccenb0(&self) -> Ciccenb0R {
274        Ciccenb0R::new(((self.bits >> 8) & 1) != 0)
275    }
276    #[doc = "Bit 9 - Circular Channel 1 Enable Buffer"]
277    #[inline(always)]
278    pub fn ciccenb1(&self) -> Ciccenb1R {
279        Ciccenb1R::new(((self.bits >> 9) & 1) != 0)
280    }
281    #[doc = "Bit 10 - Circular Channel 2 Enable Buffer"]
282    #[inline(always)]
283    pub fn ciccenb2(&self) -> Ciccenb2R {
284        Ciccenb2R::new(((self.bits >> 10) & 1) != 0)
285    }
286    #[doc = "Bit 11 - Circular Channel 3 Enable Buffer"]
287    #[inline(always)]
288    pub fn ciccenb3(&self) -> Ciccenb3R {
289        Ciccenb3R::new(((self.bits >> 11) & 1) != 0)
290    }
291    #[doc = "Bit 16 - Channel 0 Polarity Buffer"]
292    #[inline(always)]
293    pub fn polb0(&self) -> Polb0R {
294        Polb0R::new(((self.bits >> 16) & 1) != 0)
295    }
296    #[doc = "Bit 17 - Channel 1 Polarity Buffer"]
297    #[inline(always)]
298    pub fn polb1(&self) -> Polb1R {
299        Polb1R::new(((self.bits >> 17) & 1) != 0)
300    }
301    #[doc = "Bit 18 - Channel 2 Polarity Buffer"]
302    #[inline(always)]
303    pub fn polb2(&self) -> Polb2R {
304        Polb2R::new(((self.bits >> 18) & 1) != 0)
305    }
306    #[doc = "Bit 19 - Channel 3 Polarity Buffer"]
307    #[inline(always)]
308    pub fn polb3(&self) -> Polb3R {
309        Polb3R::new(((self.bits >> 19) & 1) != 0)
310    }
311    #[doc = "Bit 24 - Swap DTI Output Pair 0 Buffer"]
312    #[inline(always)]
313    pub fn swapb0(&self) -> Swapb0R {
314        Swapb0R::new(((self.bits >> 24) & 1) != 0)
315    }
316    #[doc = "Bit 25 - Swap DTI Output Pair 1 Buffer"]
317    #[inline(always)]
318    pub fn swapb1(&self) -> Swapb1R {
319        Swapb1R::new(((self.bits >> 25) & 1) != 0)
320    }
321    #[doc = "Bit 26 - Swap DTI Output Pair 2 Buffer"]
322    #[inline(always)]
323    pub fn swapb2(&self) -> Swapb2R {
324        Swapb2R::new(((self.bits >> 26) & 1) != 0)
325    }
326    #[doc = "Bit 27 - Swap DTI Output Pair 3 Buffer"]
327    #[inline(always)]
328    pub fn swapb3(&self) -> Swapb3R {
329        Swapb3R::new(((self.bits >> 27) & 1) != 0)
330    }
331}
332impl W {
333    #[doc = "Bits 0:2 - Waveform Generation Buffer"]
334    #[inline(always)]
335    #[must_use]
336    pub fn wavegenb(&mut self) -> WavegenbW<WavebSpec> {
337        WavegenbW::new(self, 0)
338    }
339    #[doc = "Bits 4:5 - Ramp Mode Buffer"]
340    #[inline(always)]
341    #[must_use]
342    pub fn rampb(&mut self) -> RampbW<WavebSpec> {
343        RampbW::new(self, 4)
344    }
345    #[doc = "Bit 7 - Circular Period Enable Buffer"]
346    #[inline(always)]
347    #[must_use]
348    pub fn ciperenb(&mut self) -> CiperenbW<WavebSpec> {
349        CiperenbW::new(self, 7)
350    }
351    #[doc = "Bit 8 - Circular Channel 0 Enable Buffer"]
352    #[inline(always)]
353    #[must_use]
354    pub fn ciccenb0(&mut self) -> Ciccenb0W<WavebSpec> {
355        Ciccenb0W::new(self, 8)
356    }
357    #[doc = "Bit 9 - Circular Channel 1 Enable Buffer"]
358    #[inline(always)]
359    #[must_use]
360    pub fn ciccenb1(&mut self) -> Ciccenb1W<WavebSpec> {
361        Ciccenb1W::new(self, 9)
362    }
363    #[doc = "Bit 10 - Circular Channel 2 Enable Buffer"]
364    #[inline(always)]
365    #[must_use]
366    pub fn ciccenb2(&mut self) -> Ciccenb2W<WavebSpec> {
367        Ciccenb2W::new(self, 10)
368    }
369    #[doc = "Bit 11 - Circular Channel 3 Enable Buffer"]
370    #[inline(always)]
371    #[must_use]
372    pub fn ciccenb3(&mut self) -> Ciccenb3W<WavebSpec> {
373        Ciccenb3W::new(self, 11)
374    }
375    #[doc = "Bit 16 - Channel 0 Polarity Buffer"]
376    #[inline(always)]
377    #[must_use]
378    pub fn polb0(&mut self) -> Polb0W<WavebSpec> {
379        Polb0W::new(self, 16)
380    }
381    #[doc = "Bit 17 - Channel 1 Polarity Buffer"]
382    #[inline(always)]
383    #[must_use]
384    pub fn polb1(&mut self) -> Polb1W<WavebSpec> {
385        Polb1W::new(self, 17)
386    }
387    #[doc = "Bit 18 - Channel 2 Polarity Buffer"]
388    #[inline(always)]
389    #[must_use]
390    pub fn polb2(&mut self) -> Polb2W<WavebSpec> {
391        Polb2W::new(self, 18)
392    }
393    #[doc = "Bit 19 - Channel 3 Polarity Buffer"]
394    #[inline(always)]
395    #[must_use]
396    pub fn polb3(&mut self) -> Polb3W<WavebSpec> {
397        Polb3W::new(self, 19)
398    }
399    #[doc = "Bit 24 - Swap DTI Output Pair 0 Buffer"]
400    #[inline(always)]
401    #[must_use]
402    pub fn swapb0(&mut self) -> Swapb0W<WavebSpec> {
403        Swapb0W::new(self, 24)
404    }
405    #[doc = "Bit 25 - Swap DTI Output Pair 1 Buffer"]
406    #[inline(always)]
407    #[must_use]
408    pub fn swapb1(&mut self) -> Swapb1W<WavebSpec> {
409        Swapb1W::new(self, 25)
410    }
411    #[doc = "Bit 26 - Swap DTI Output Pair 2 Buffer"]
412    #[inline(always)]
413    #[must_use]
414    pub fn swapb2(&mut self) -> Swapb2W<WavebSpec> {
415        Swapb2W::new(self, 26)
416    }
417    #[doc = "Bit 27 - Swap DTI Output Pair 3 Buffer"]
418    #[inline(always)]
419    #[must_use]
420    pub fn swapb3(&mut self) -> Swapb3W<WavebSpec> {
421        Swapb3W::new(self, 27)
422    }
423}
424#[doc = "Waveform Control Buffer\n\nYou can [`read`](crate::Reg::read) this register and get [`waveb::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`waveb::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
425pub struct WavebSpec;
426impl crate::RegisterSpec for WavebSpec {
427    type Ux = u32;
428}
429#[doc = "`read()` method returns [`waveb::R`](R) reader structure"]
430impl crate::Readable for WavebSpec {}
431#[doc = "`write(|w| ..)` method takes [`waveb::W`](W) writer structure"]
432impl crate::Writable for WavebSpec {
433    type Safety = crate::Unsafe;
434    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
435    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
436}
437#[doc = "`reset()` method sets WAVEB to value 0"]
438impl crate::Resettable for WavebSpec {
439    const RESET_VALUE: u32 = 0;
440}