1#[doc = "Register `CFG0` reader"]
2pub struct R(crate::R<CFG0_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CFG0_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CFG0_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CFG0_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `CFG0` writer"]
17pub struct W(crate::W<CFG0_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CFG0_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<CFG0_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CFG0_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Filter order\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39#[repr(u8)]
40pub enum FORDER_A {
41    #[doc = "0: Second order filter."]
42    SECOND = 0,
43    #[doc = "1: Third order filter."]
44    THIRD = 1,
45    #[doc = "2: Fourth order filter."]
46    FOURTH = 2,
47    #[doc = "3: Fifth order filter."]
48    FIFTH = 3,
49}
50impl From<FORDER_A> for u8 {
51    #[inline(always)]
52    fn from(variant: FORDER_A) -> Self {
53        variant as _
54    }
55}
56#[doc = "Field `FORDER` reader - Filter order"]
57pub type FORDER_R = crate::FieldReader<u8, FORDER_A>;
58impl FORDER_R {
59    #[doc = "Get enumerated values variant"]
60    #[inline(always)]
61    pub fn variant(&self) -> FORDER_A {
62        match self.bits {
63            0 => FORDER_A::SECOND,
64            1 => FORDER_A::THIRD,
65            2 => FORDER_A::FOURTH,
66            3 => FORDER_A::FIFTH,
67            _ => unreachable!(),
68        }
69    }
70    #[doc = "Checks if the value of the field is `SECOND`"]
71    #[inline(always)]
72    pub fn is_second(&self) -> bool {
73        *self == FORDER_A::SECOND
74    }
75    #[doc = "Checks if the value of the field is `THIRD`"]
76    #[inline(always)]
77    pub fn is_third(&self) -> bool {
78        *self == FORDER_A::THIRD
79    }
80    #[doc = "Checks if the value of the field is `FOURTH`"]
81    #[inline(always)]
82    pub fn is_fourth(&self) -> bool {
83        *self == FORDER_A::FOURTH
84    }
85    #[doc = "Checks if the value of the field is `FIFTH`"]
86    #[inline(always)]
87    pub fn is_fifth(&self) -> bool {
88        *self == FORDER_A::FIFTH
89    }
90}
91#[doc = "Field `FORDER` writer - Filter order"]
92pub type FORDER_W<'a> = crate::FieldWriterSafe<'a, u32, CFG0_SPEC, u8, FORDER_A, 2, 0>;
93impl<'a> FORDER_W<'a> {
94    #[doc = "Second order filter."]
95    #[inline(always)]
96    pub fn second(self) -> &'a mut W {
97        self.variant(FORDER_A::SECOND)
98    }
99    #[doc = "Third order filter."]
100    #[inline(always)]
101    pub fn third(self) -> &'a mut W {
102        self.variant(FORDER_A::THIRD)
103    }
104    #[doc = "Fourth order filter."]
105    #[inline(always)]
106    pub fn fourth(self) -> &'a mut W {
107        self.variant(FORDER_A::FOURTH)
108    }
109    #[doc = "Fifth order filter."]
110    #[inline(always)]
111    pub fn fifth(self) -> &'a mut W {
112        self.variant(FORDER_A::FIFTH)
113    }
114}
115#[doc = "Number of Channels\n\nValue on reset: 0"]
116#[derive(Clone, Copy, Debug, PartialEq)]
117#[repr(u8)]
118pub enum NUMCH_A {
119    #[doc = "0: Only one Channel."]
120    ONE = 0,
121    #[doc = "1: Two Channels."]
122    TWO = 1,
123    #[doc = "2: Three Channels."]
124    THREE = 2,
125    #[doc = "3: Four Channels."]
126    FOUR = 3,
127}
128impl From<NUMCH_A> for u8 {
129    #[inline(always)]
130    fn from(variant: NUMCH_A) -> Self {
131        variant as _
132    }
133}
134#[doc = "Field `NUMCH` reader - Number of Channels"]
135pub type NUMCH_R = crate::FieldReader<u8, NUMCH_A>;
136impl NUMCH_R {
137    #[doc = "Get enumerated values variant"]
138    #[inline(always)]
139    pub fn variant(&self) -> NUMCH_A {
140        match self.bits {
141            0 => NUMCH_A::ONE,
142            1 => NUMCH_A::TWO,
143            2 => NUMCH_A::THREE,
144            3 => NUMCH_A::FOUR,
145            _ => unreachable!(),
146        }
147    }
148    #[doc = "Checks if the value of the field is `ONE`"]
149    #[inline(always)]
150    pub fn is_one(&self) -> bool {
151        *self == NUMCH_A::ONE
152    }
153    #[doc = "Checks if the value of the field is `TWO`"]
154    #[inline(always)]
155    pub fn is_two(&self) -> bool {
156        *self == NUMCH_A::TWO
157    }
158    #[doc = "Checks if the value of the field is `THREE`"]
159    #[inline(always)]
160    pub fn is_three(&self) -> bool {
161        *self == NUMCH_A::THREE
162    }
163    #[doc = "Checks if the value of the field is `FOUR`"]
164    #[inline(always)]
165    pub fn is_four(&self) -> bool {
166        *self == NUMCH_A::FOUR
167    }
168}
169#[doc = "Field `NUMCH` writer - Number of Channels"]
170pub type NUMCH_W<'a> = crate::FieldWriterSafe<'a, u32, CFG0_SPEC, u8, NUMCH_A, 2, 4>;
171impl<'a> NUMCH_W<'a> {
172    #[doc = "Only one Channel."]
173    #[inline(always)]
174    pub fn one(self) -> &'a mut W {
175        self.variant(NUMCH_A::ONE)
176    }
177    #[doc = "Two Channels."]
178    #[inline(always)]
179    pub fn two(self) -> &'a mut W {
180        self.variant(NUMCH_A::TWO)
181    }
182    #[doc = "Three Channels."]
183    #[inline(always)]
184    pub fn three(self) -> &'a mut W {
185        self.variant(NUMCH_A::THREE)
186    }
187    #[doc = "Four Channels."]
188    #[inline(always)]
189    pub fn four(self) -> &'a mut W {
190        self.variant(NUMCH_A::FOUR)
191    }
192}
193#[doc = "Filter output format\n\nValue on reset: 0"]
194#[derive(Clone, Copy, Debug, PartialEq)]
195#[repr(u8)]
196pub enum DATAFORMAT_A {
197    #[doc = "0: Right aligned 16-bit, left bits are sign extended."]
198    RIGHT16 = 0,
199    #[doc = "1: Pack two 16-bit samples into one 32-bit word."]
200    DOUBLE16 = 1,
201    #[doc = "2: Right aligned 24bit, left bits are sign extended."]
202    RIGHT24 = 2,
203    #[doc = "3: 32 bit data."]
204    FULL32BIT = 3,
205    #[doc = "4: Left aligned 16-bit, right bits are zeros."]
206    LEFT16 = 4,
207    #[doc = "5: Left aligned 24-bit, right bits are zeros."]
208    LEFT24 = 5,
209    #[doc = "6: RAW 32 bit data from Integrator."]
210    RAW32BIT = 6,
211}
212impl From<DATAFORMAT_A> for u8 {
213    #[inline(always)]
214    fn from(variant: DATAFORMAT_A) -> Self {
215        variant as _
216    }
217}
218#[doc = "Field `DATAFORMAT` reader - Filter output format"]
219pub type DATAFORMAT_R = crate::FieldReader<u8, DATAFORMAT_A>;
220impl DATAFORMAT_R {
221    #[doc = "Get enumerated values variant"]
222    #[inline(always)]
223    pub fn variant(&self) -> Option<DATAFORMAT_A> {
224        match self.bits {
225            0 => Some(DATAFORMAT_A::RIGHT16),
226            1 => Some(DATAFORMAT_A::DOUBLE16),
227            2 => Some(DATAFORMAT_A::RIGHT24),
228            3 => Some(DATAFORMAT_A::FULL32BIT),
229            4 => Some(DATAFORMAT_A::LEFT16),
230            5 => Some(DATAFORMAT_A::LEFT24),
231            6 => Some(DATAFORMAT_A::RAW32BIT),
232            _ => None,
233        }
234    }
235    #[doc = "Checks if the value of the field is `RIGHT16`"]
236    #[inline(always)]
237    pub fn is_right16(&self) -> bool {
238        *self == DATAFORMAT_A::RIGHT16
239    }
240    #[doc = "Checks if the value of the field is `DOUBLE16`"]
241    #[inline(always)]
242    pub fn is_double16(&self) -> bool {
243        *self == DATAFORMAT_A::DOUBLE16
244    }
245    #[doc = "Checks if the value of the field is `RIGHT24`"]
246    #[inline(always)]
247    pub fn is_right24(&self) -> bool {
248        *self == DATAFORMAT_A::RIGHT24
249    }
250    #[doc = "Checks if the value of the field is `FULL32BIT`"]
251    #[inline(always)]
252    pub fn is_full32bit(&self) -> bool {
253        *self == DATAFORMAT_A::FULL32BIT
254    }
255    #[doc = "Checks if the value of the field is `LEFT16`"]
256    #[inline(always)]
257    pub fn is_left16(&self) -> bool {
258        *self == DATAFORMAT_A::LEFT16
259    }
260    #[doc = "Checks if the value of the field is `LEFT24`"]
261    #[inline(always)]
262    pub fn is_left24(&self) -> bool {
263        *self == DATAFORMAT_A::LEFT24
264    }
265    #[doc = "Checks if the value of the field is `RAW32BIT`"]
266    #[inline(always)]
267    pub fn is_raw32bit(&self) -> bool {
268        *self == DATAFORMAT_A::RAW32BIT
269    }
270}
271#[doc = "Field `DATAFORMAT` writer - Filter output format"]
272pub type DATAFORMAT_W<'a> = crate::FieldWriter<'a, u32, CFG0_SPEC, u8, DATAFORMAT_A, 3, 8>;
273impl<'a> DATAFORMAT_W<'a> {
274    #[doc = "Right aligned 16-bit, left bits are sign extended."]
275    #[inline(always)]
276    pub fn right16(self) -> &'a mut W {
277        self.variant(DATAFORMAT_A::RIGHT16)
278    }
279    #[doc = "Pack two 16-bit samples into one 32-bit word."]
280    #[inline(always)]
281    pub fn double16(self) -> &'a mut W {
282        self.variant(DATAFORMAT_A::DOUBLE16)
283    }
284    #[doc = "Right aligned 24bit, left bits are sign extended."]
285    #[inline(always)]
286    pub fn right24(self) -> &'a mut W {
287        self.variant(DATAFORMAT_A::RIGHT24)
288    }
289    #[doc = "32 bit data."]
290    #[inline(always)]
291    pub fn full32bit(self) -> &'a mut W {
292        self.variant(DATAFORMAT_A::FULL32BIT)
293    }
294    #[doc = "Left aligned 16-bit, right bits are zeros."]
295    #[inline(always)]
296    pub fn left16(self) -> &'a mut W {
297        self.variant(DATAFORMAT_A::LEFT16)
298    }
299    #[doc = "Left aligned 24-bit, right bits are zeros."]
300    #[inline(always)]
301    pub fn left24(self) -> &'a mut W {
302        self.variant(DATAFORMAT_A::LEFT24)
303    }
304    #[doc = "RAW 32 bit data from Integrator."]
305    #[inline(always)]
306    pub fn raw32bit(self) -> &'a mut W {
307        self.variant(DATAFORMAT_A::RAW32BIT)
308    }
309}
310#[doc = "Data Valid level in FIFO\n\nValue on reset: 0"]
311#[derive(Clone, Copy, Debug, PartialEq)]
312#[repr(u8)]
313pub enum FIFODVL_A {
314    #[doc = "0: Atleast one word."]
315    ONE = 0,
316    #[doc = "1: Two words."]
317    TWO = 1,
318    #[doc = "2: Three words."]
319    THREE = 2,
320    #[doc = "3: Four words."]
321    FOUR = 3,
322}
323impl From<FIFODVL_A> for u8 {
324    #[inline(always)]
325    fn from(variant: FIFODVL_A) -> Self {
326        variant as _
327    }
328}
329#[doc = "Field `FIFODVL` reader - Data Valid level in FIFO"]
330pub type FIFODVL_R = crate::FieldReader<u8, FIFODVL_A>;
331impl FIFODVL_R {
332    #[doc = "Get enumerated values variant"]
333    #[inline(always)]
334    pub fn variant(&self) -> FIFODVL_A {
335        match self.bits {
336            0 => FIFODVL_A::ONE,
337            1 => FIFODVL_A::TWO,
338            2 => FIFODVL_A::THREE,
339            3 => FIFODVL_A::FOUR,
340            _ => unreachable!(),
341        }
342    }
343    #[doc = "Checks if the value of the field is `ONE`"]
344    #[inline(always)]
345    pub fn is_one(&self) -> bool {
346        *self == FIFODVL_A::ONE
347    }
348    #[doc = "Checks if the value of the field is `TWO`"]
349    #[inline(always)]
350    pub fn is_two(&self) -> bool {
351        *self == FIFODVL_A::TWO
352    }
353    #[doc = "Checks if the value of the field is `THREE`"]
354    #[inline(always)]
355    pub fn is_three(&self) -> bool {
356        *self == FIFODVL_A::THREE
357    }
358    #[doc = "Checks if the value of the field is `FOUR`"]
359    #[inline(always)]
360    pub fn is_four(&self) -> bool {
361        *self == FIFODVL_A::FOUR
362    }
363}
364#[doc = "Field `FIFODVL` writer - Data Valid level in FIFO"]
365pub type FIFODVL_W<'a> = crate::FieldWriterSafe<'a, u32, CFG0_SPEC, u8, FIFODVL_A, 2, 12>;
366impl<'a> FIFODVL_W<'a> {
367    #[doc = "Atleast one word."]
368    #[inline(always)]
369    pub fn one(self) -> &'a mut W {
370        self.variant(FIFODVL_A::ONE)
371    }
372    #[doc = "Two words."]
373    #[inline(always)]
374    pub fn two(self) -> &'a mut W {
375        self.variant(FIFODVL_A::TWO)
376    }
377    #[doc = "Three words."]
378    #[inline(always)]
379    pub fn three(self) -> &'a mut W {
380        self.variant(FIFODVL_A::THREE)
381    }
382    #[doc = "Four words."]
383    #[inline(always)]
384    pub fn four(self) -> &'a mut W {
385        self.variant(FIFODVL_A::FOUR)
386    }
387}
388#[doc = "Field `STEREOMODECH01` reader - Stereo mode CH01"]
389pub type STEREOMODECH01_R = crate::BitReader<bool>;
390#[doc = "Field `STEREOMODECH01` writer - Stereo mode CH01"]
391pub type STEREOMODECH01_W<'a> = crate::BitWriter<'a, u32, CFG0_SPEC, bool, 16>;
392#[doc = "Field `STEREOMODECH23` reader - Stereo mode CH23"]
393pub type STEREOMODECH23_R = crate::BitReader<bool>;
394#[doc = "Field `STEREOMODECH23` writer - Stereo mode CH23"]
395pub type STEREOMODECH23_W<'a> = crate::BitWriter<'a, u32, CFG0_SPEC, bool, 17>;
396#[doc = "Field `CH0CLKPOL` reader - CH0 CLK Polarity"]
397pub type CH0CLKPOL_R = crate::BitReader<bool>;
398#[doc = "Field `CH0CLKPOL` writer - CH0 CLK Polarity"]
399pub type CH0CLKPOL_W<'a> = crate::BitWriter<'a, u32, CFG0_SPEC, bool, 24>;
400#[doc = "Field `CH1CLKPOL` reader - CH1 CLK Polarity"]
401pub type CH1CLKPOL_R = crate::BitReader<bool>;
402#[doc = "Field `CH1CLKPOL` writer - CH1 CLK Polarity"]
403pub type CH1CLKPOL_W<'a> = crate::BitWriter<'a, u32, CFG0_SPEC, bool, 25>;
404#[doc = "Field `CH2CLKPOL` reader - CH2 CLK Polarity"]
405pub type CH2CLKPOL_R = crate::BitReader<bool>;
406#[doc = "Field `CH2CLKPOL` writer - CH2 CLK Polarity"]
407pub type CH2CLKPOL_W<'a> = crate::BitWriter<'a, u32, CFG0_SPEC, bool, 26>;
408#[doc = "Field `CH3CLKPOL` reader - CH3 CLK Polarity"]
409pub type CH3CLKPOL_R = crate::BitReader<bool>;
410#[doc = "Field `CH3CLKPOL` writer - CH3 CLK Polarity"]
411pub type CH3CLKPOL_W<'a> = crate::BitWriter<'a, u32, CFG0_SPEC, bool, 27>;
412impl R {
413    #[doc = "Bits 0:1 - Filter order"]
414    #[inline(always)]
415    pub fn forder(&self) -> FORDER_R {
416        FORDER_R::new((self.bits & 3) as u8)
417    }
418    #[doc = "Bits 4:5 - Number of Channels"]
419    #[inline(always)]
420    pub fn numch(&self) -> NUMCH_R {
421        NUMCH_R::new(((self.bits >> 4) & 3) as u8)
422    }
423    #[doc = "Bits 8:10 - Filter output format"]
424    #[inline(always)]
425    pub fn dataformat(&self) -> DATAFORMAT_R {
426        DATAFORMAT_R::new(((self.bits >> 8) & 7) as u8)
427    }
428    #[doc = "Bits 12:13 - Data Valid level in FIFO"]
429    #[inline(always)]
430    pub fn fifodvl(&self) -> FIFODVL_R {
431        FIFODVL_R::new(((self.bits >> 12) & 3) as u8)
432    }
433    #[doc = "Bit 16 - Stereo mode CH01"]
434    #[inline(always)]
435    pub fn stereomodech01(&self) -> STEREOMODECH01_R {
436        STEREOMODECH01_R::new(((self.bits >> 16) & 1) != 0)
437    }
438    #[doc = "Bit 17 - Stereo mode CH23"]
439    #[inline(always)]
440    pub fn stereomodech23(&self) -> STEREOMODECH23_R {
441        STEREOMODECH23_R::new(((self.bits >> 17) & 1) != 0)
442    }
443    #[doc = "Bit 24 - CH0 CLK Polarity"]
444    #[inline(always)]
445    pub fn ch0clkpol(&self) -> CH0CLKPOL_R {
446        CH0CLKPOL_R::new(((self.bits >> 24) & 1) != 0)
447    }
448    #[doc = "Bit 25 - CH1 CLK Polarity"]
449    #[inline(always)]
450    pub fn ch1clkpol(&self) -> CH1CLKPOL_R {
451        CH1CLKPOL_R::new(((self.bits >> 25) & 1) != 0)
452    }
453    #[doc = "Bit 26 - CH2 CLK Polarity"]
454    #[inline(always)]
455    pub fn ch2clkpol(&self) -> CH2CLKPOL_R {
456        CH2CLKPOL_R::new(((self.bits >> 26) & 1) != 0)
457    }
458    #[doc = "Bit 27 - CH3 CLK Polarity"]
459    #[inline(always)]
460    pub fn ch3clkpol(&self) -> CH3CLKPOL_R {
461        CH3CLKPOL_R::new(((self.bits >> 27) & 1) != 0)
462    }
463}
464impl W {
465    #[doc = "Bits 0:1 - Filter order"]
466    #[inline(always)]
467    pub fn forder(&mut self) -> FORDER_W {
468        FORDER_W::new(self)
469    }
470    #[doc = "Bits 4:5 - Number of Channels"]
471    #[inline(always)]
472    pub fn numch(&mut self) -> NUMCH_W {
473        NUMCH_W::new(self)
474    }
475    #[doc = "Bits 8:10 - Filter output format"]
476    #[inline(always)]
477    pub fn dataformat(&mut self) -> DATAFORMAT_W {
478        DATAFORMAT_W::new(self)
479    }
480    #[doc = "Bits 12:13 - Data Valid level in FIFO"]
481    #[inline(always)]
482    pub fn fifodvl(&mut self) -> FIFODVL_W {
483        FIFODVL_W::new(self)
484    }
485    #[doc = "Bit 16 - Stereo mode CH01"]
486    #[inline(always)]
487    pub fn stereomodech01(&mut self) -> STEREOMODECH01_W {
488        STEREOMODECH01_W::new(self)
489    }
490    #[doc = "Bit 17 - Stereo mode CH23"]
491    #[inline(always)]
492    pub fn stereomodech23(&mut self) -> STEREOMODECH23_W {
493        STEREOMODECH23_W::new(self)
494    }
495    #[doc = "Bit 24 - CH0 CLK Polarity"]
496    #[inline(always)]
497    pub fn ch0clkpol(&mut self) -> CH0CLKPOL_W {
498        CH0CLKPOL_W::new(self)
499    }
500    #[doc = "Bit 25 - CH1 CLK Polarity"]
501    #[inline(always)]
502    pub fn ch1clkpol(&mut self) -> CH1CLKPOL_W {
503        CH1CLKPOL_W::new(self)
504    }
505    #[doc = "Bit 26 - CH2 CLK Polarity"]
506    #[inline(always)]
507    pub fn ch2clkpol(&mut self) -> CH2CLKPOL_W {
508        CH2CLKPOL_W::new(self)
509    }
510    #[doc = "Bit 27 - CH3 CLK Polarity"]
511    #[inline(always)]
512    pub fn ch3clkpol(&mut self) -> CH3CLKPOL_W {
513        CH3CLKPOL_W::new(self)
514    }
515    #[doc = "Writes raw bits to the register."]
516    #[inline(always)]
517    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
518        self.0.bits(bits);
519        self
520    }
521}
522#[doc = "PDM Core Configuration Register0\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 [cfg0](index.html) module"]
523pub struct CFG0_SPEC;
524impl crate::RegisterSpec for CFG0_SPEC {
525    type Ux = u32;
526}
527#[doc = "`read()` method returns [cfg0::R](R) reader structure"]
528impl crate::Readable for CFG0_SPEC {
529    type Reader = R;
530}
531#[doc = "`write(|w| ..)` method takes [cfg0::W](W) writer structure"]
532impl crate::Writable for CFG0_SPEC {
533    type Writer = W;
534}
535#[doc = "`reset()` method sets CFG0 to value 0"]
536impl crate::Resettable for CFG0_SPEC {
537    #[inline(always)]
538    fn reset_value() -> Self::Ux {
539        0
540    }
541}