efm32tg11b_pac/efm32tg11b540/csen/
dmcfg.rs

1#[doc = "Register `DMCFG` reader"]
2pub struct R(crate::R<DMCFG_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<DMCFG_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<DMCFG_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<DMCFG_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `DMCFG` writer"]
17pub struct W(crate::W<DMCFG_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<DMCFG_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<DMCFG_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<DMCFG_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `DMG` reader - Delta Modulator Gain Step"]
38pub type DMG_R = crate::FieldReader<u8, u8>;
39#[doc = "Field `DMG` writer - Delta Modulator Gain Step"]
40pub type DMG_W<'a, const O: u8> = crate::FieldWriter<'a, u32, DMCFG_SPEC, u8, u8, 8, O>;
41#[doc = "Field `DMR` reader - Delta Modulator Gain Reduction Interval"]
42pub type DMR_R = crate::FieldReader<u8, u8>;
43#[doc = "Field `DMR` writer - Delta Modulator Gain Reduction Interval"]
44pub type DMR_W<'a, const O: u8> = crate::FieldWriter<'a, u32, DMCFG_SPEC, u8, u8, 4, O>;
45#[doc = "Field `DMCR` reader - Delta Modulator Conversion Rate"]
46pub type DMCR_R = crate::FieldReader<u8, u8>;
47#[doc = "Field `DMCR` writer - Delta Modulator Conversion Rate"]
48pub type DMCR_W<'a, const O: u8> = crate::FieldWriter<'a, u32, DMCFG_SPEC, u8, u8, 4, O>;
49#[doc = "Field `CRMODE` reader - Delta Modulator Conversion Resolution."]
50pub type CRMODE_R = crate::FieldReader<u8, CRMODE_A>;
51#[doc = "Delta Modulator Conversion Resolution.\n\nValue on reset: 0"]
52#[derive(Clone, Copy, Debug, PartialEq, Eq)]
53#[repr(u8)]
54pub enum CRMODE_A {
55    #[doc = "0: 10-bit delta modulator"]
56    DM10 = 0,
57    #[doc = "1: 12-bit delta modulator"]
58    DM12 = 1,
59    #[doc = "2: 14-bit delta modulator"]
60    DM14 = 2,
61    #[doc = "3: 16-bit delta modulator"]
62    DM16 = 3,
63}
64impl From<CRMODE_A> for u8 {
65    #[inline(always)]
66    fn from(variant: CRMODE_A) -> Self {
67        variant as _
68    }
69}
70impl CRMODE_R {
71    #[doc = "Get enumerated values variant"]
72    #[inline(always)]
73    pub fn variant(&self) -> CRMODE_A {
74        match self.bits {
75            0 => CRMODE_A::DM10,
76            1 => CRMODE_A::DM12,
77            2 => CRMODE_A::DM14,
78            3 => CRMODE_A::DM16,
79            _ => unreachable!(),
80        }
81    }
82    #[doc = "Checks if the value of the field is `DM10`"]
83    #[inline(always)]
84    pub fn is_dm10(&self) -> bool {
85        *self == CRMODE_A::DM10
86    }
87    #[doc = "Checks if the value of the field is `DM12`"]
88    #[inline(always)]
89    pub fn is_dm12(&self) -> bool {
90        *self == CRMODE_A::DM12
91    }
92    #[doc = "Checks if the value of the field is `DM14`"]
93    #[inline(always)]
94    pub fn is_dm14(&self) -> bool {
95        *self == CRMODE_A::DM14
96    }
97    #[doc = "Checks if the value of the field is `DM16`"]
98    #[inline(always)]
99    pub fn is_dm16(&self) -> bool {
100        *self == CRMODE_A::DM16
101    }
102}
103#[doc = "Field `CRMODE` writer - Delta Modulator Conversion Resolution."]
104pub type CRMODE_W<'a, const O: u8> =
105    crate::FieldWriterSafe<'a, u32, DMCFG_SPEC, u8, CRMODE_A, 2, O>;
106impl<'a, const O: u8> CRMODE_W<'a, O> {
107    #[doc = "10-bit delta modulator"]
108    #[inline(always)]
109    pub fn dm10(self) -> &'a mut W {
110        self.variant(CRMODE_A::DM10)
111    }
112    #[doc = "12-bit delta modulator"]
113    #[inline(always)]
114    pub fn dm12(self) -> &'a mut W {
115        self.variant(CRMODE_A::DM12)
116    }
117    #[doc = "14-bit delta modulator"]
118    #[inline(always)]
119    pub fn dm14(self) -> &'a mut W {
120        self.variant(CRMODE_A::DM14)
121    }
122    #[doc = "16-bit delta modulator"]
123    #[inline(always)]
124    pub fn dm16(self) -> &'a mut W {
125        self.variant(CRMODE_A::DM16)
126    }
127}
128#[doc = "Field `DMGRDIS` reader - Delta Modulation Gain Step Reduction Disable"]
129pub type DMGRDIS_R = crate::BitReader<bool>;
130#[doc = "Field `DMGRDIS` writer - Delta Modulation Gain Step Reduction Disable"]
131pub type DMGRDIS_W<'a, const O: u8> = crate::BitWriter<'a, u32, DMCFG_SPEC, bool, O>;
132impl R {
133    #[doc = "Bits 0:7 - Delta Modulator Gain Step"]
134    #[inline(always)]
135    pub fn dmg(&self) -> DMG_R {
136        DMG_R::new((self.bits & 0xff) as u8)
137    }
138    #[doc = "Bits 8:11 - Delta Modulator Gain Reduction Interval"]
139    #[inline(always)]
140    pub fn dmr(&self) -> DMR_R {
141        DMR_R::new(((self.bits >> 8) & 0x0f) as u8)
142    }
143    #[doc = "Bits 16:19 - Delta Modulator Conversion Rate"]
144    #[inline(always)]
145    pub fn dmcr(&self) -> DMCR_R {
146        DMCR_R::new(((self.bits >> 16) & 0x0f) as u8)
147    }
148    #[doc = "Bits 20:21 - Delta Modulator Conversion Resolution."]
149    #[inline(always)]
150    pub fn crmode(&self) -> CRMODE_R {
151        CRMODE_R::new(((self.bits >> 20) & 3) as u8)
152    }
153    #[doc = "Bit 28 - Delta Modulation Gain Step Reduction Disable"]
154    #[inline(always)]
155    pub fn dmgrdis(&self) -> DMGRDIS_R {
156        DMGRDIS_R::new(((self.bits >> 28) & 1) != 0)
157    }
158}
159impl W {
160    #[doc = "Bits 0:7 - Delta Modulator Gain Step"]
161    #[inline(always)]
162    #[must_use]
163    pub fn dmg(&mut self) -> DMG_W<0> {
164        DMG_W::new(self)
165    }
166    #[doc = "Bits 8:11 - Delta Modulator Gain Reduction Interval"]
167    #[inline(always)]
168    #[must_use]
169    pub fn dmr(&mut self) -> DMR_W<8> {
170        DMR_W::new(self)
171    }
172    #[doc = "Bits 16:19 - Delta Modulator Conversion Rate"]
173    #[inline(always)]
174    #[must_use]
175    pub fn dmcr(&mut self) -> DMCR_W<16> {
176        DMCR_W::new(self)
177    }
178    #[doc = "Bits 20:21 - Delta Modulator Conversion Resolution."]
179    #[inline(always)]
180    #[must_use]
181    pub fn crmode(&mut self) -> CRMODE_W<20> {
182        CRMODE_W::new(self)
183    }
184    #[doc = "Bit 28 - Delta Modulation Gain Step Reduction Disable"]
185    #[inline(always)]
186    #[must_use]
187    pub fn dmgrdis(&mut self) -> DMGRDIS_W<28> {
188        DMGRDIS_W::new(self)
189    }
190    #[doc = "Writes raw bits to the register."]
191    #[inline(always)]
192    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
193        self.0.bits(bits);
194        self
195    }
196}
197#[doc = "Delta Modulation Configuration\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 [dmcfg](index.html) module"]
198pub struct DMCFG_SPEC;
199impl crate::RegisterSpec for DMCFG_SPEC {
200    type Ux = u32;
201}
202#[doc = "`read()` method returns [dmcfg::R](R) reader structure"]
203impl crate::Readable for DMCFG_SPEC {
204    type Reader = R;
205}
206#[doc = "`write(|w| ..)` method takes [dmcfg::W](W) writer structure"]
207impl crate::Writable for DMCFG_SPEC {
208    type Writer = W;
209    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
210    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
211}
212#[doc = "`reset()` method sets DMCFG to value 0"]
213impl crate::Resettable for DMCFG_SPEC {
214    const RESET_VALUE: Self::Ux = 0;
215}