atsamd51g/adc0/
ctrlb.rs

1#[doc = "Register `CTRLB` reader"]
2pub type R = crate::R<CtrlbSpec>;
3#[doc = "Register `CTRLB` writer"]
4pub type W = crate::W<CtrlbSpec>;
5#[doc = "Field `LEFTADJ` reader - Left-Adjusted Result"]
6pub type LeftadjR = crate::BitReader;
7#[doc = "Field `LEFTADJ` writer - Left-Adjusted Result"]
8pub type LeftadjW<'a, REG> = crate::BitWriter<'a, REG>;
9#[doc = "Field `FREERUN` reader - Free Running Mode"]
10pub type FreerunR = crate::BitReader;
11#[doc = "Field `FREERUN` writer - Free Running Mode"]
12pub type FreerunW<'a, REG> = crate::BitWriter<'a, REG>;
13#[doc = "Field `CORREN` reader - Digital Correction Logic Enable"]
14pub type CorrenR = crate::BitReader;
15#[doc = "Field `CORREN` writer - Digital Correction Logic Enable"]
16pub type CorrenW<'a, REG> = crate::BitWriter<'a, REG>;
17#[doc = "Conversion Result Resolution\n\nValue on reset: 0"]
18#[derive(Clone, Copy, Debug, PartialEq, Eq)]
19#[repr(u8)]
20pub enum Resselselect {
21    #[doc = "0: 12-bit result"]
22    _12bit = 0,
23    #[doc = "1: For averaging mode output"]
24    _16bit = 1,
25    #[doc = "2: 10-bit result"]
26    _10bit = 2,
27    #[doc = "3: 8-bit result"]
28    _8bit = 3,
29}
30impl From<Resselselect> for u8 {
31    #[inline(always)]
32    fn from(variant: Resselselect) -> Self {
33        variant as _
34    }
35}
36impl crate::FieldSpec for Resselselect {
37    type Ux = u8;
38}
39impl crate::IsEnum for Resselselect {}
40#[doc = "Field `RESSEL` reader - Conversion Result Resolution"]
41pub type ResselR = crate::FieldReader<Resselselect>;
42impl ResselR {
43    #[doc = "Get enumerated values variant"]
44    #[inline(always)]
45    pub const fn variant(&self) -> Resselselect {
46        match self.bits {
47            0 => Resselselect::_12bit,
48            1 => Resselselect::_16bit,
49            2 => Resselselect::_10bit,
50            3 => Resselselect::_8bit,
51            _ => unreachable!(),
52        }
53    }
54    #[doc = "12-bit result"]
55    #[inline(always)]
56    pub fn is_12bit(&self) -> bool {
57        *self == Resselselect::_12bit
58    }
59    #[doc = "For averaging mode output"]
60    #[inline(always)]
61    pub fn is_16bit(&self) -> bool {
62        *self == Resselselect::_16bit
63    }
64    #[doc = "10-bit result"]
65    #[inline(always)]
66    pub fn is_10bit(&self) -> bool {
67        *self == Resselselect::_10bit
68    }
69    #[doc = "8-bit result"]
70    #[inline(always)]
71    pub fn is_8bit(&self) -> bool {
72        *self == Resselselect::_8bit
73    }
74}
75#[doc = "Field `RESSEL` writer - Conversion Result Resolution"]
76pub type ResselW<'a, REG> = crate::FieldWriter<'a, REG, 2, Resselselect, crate::Safe>;
77impl<'a, REG> ResselW<'a, REG>
78where
79    REG: crate::Writable + crate::RegisterSpec,
80    REG::Ux: From<u8>,
81{
82    #[doc = "12-bit result"]
83    #[inline(always)]
84    pub fn _12bit(self) -> &'a mut crate::W<REG> {
85        self.variant(Resselselect::_12bit)
86    }
87    #[doc = "For averaging mode output"]
88    #[inline(always)]
89    pub fn _16bit(self) -> &'a mut crate::W<REG> {
90        self.variant(Resselselect::_16bit)
91    }
92    #[doc = "10-bit result"]
93    #[inline(always)]
94    pub fn _10bit(self) -> &'a mut crate::W<REG> {
95        self.variant(Resselselect::_10bit)
96    }
97    #[doc = "8-bit result"]
98    #[inline(always)]
99    pub fn _8bit(self) -> &'a mut crate::W<REG> {
100        self.variant(Resselselect::_8bit)
101    }
102}
103#[doc = "Window Monitor Mode\n\nValue on reset: 0"]
104#[derive(Clone, Copy, Debug, PartialEq, Eq)]
105#[repr(u8)]
106pub enum Winmodeselect {
107    #[doc = "0: No window mode (default)"]
108    Disable = 0,
109    #[doc = "1: RESULT > WINLT"]
110    Mode1 = 1,
111    #[doc = "2: RESULT &lt; WINUT"]
112    Mode2 = 2,
113    #[doc = "3: WINLT &lt; RESULT &lt; WINUT"]
114    Mode3 = 3,
115    #[doc = "4: !(WINLT &lt; RESULT &lt; WINUT)"]
116    Mode4 = 4,
117}
118impl From<Winmodeselect> for u8 {
119    #[inline(always)]
120    fn from(variant: Winmodeselect) -> Self {
121        variant as _
122    }
123}
124impl crate::FieldSpec for Winmodeselect {
125    type Ux = u8;
126}
127impl crate::IsEnum for Winmodeselect {}
128#[doc = "Field `WINMODE` reader - Window Monitor Mode"]
129pub type WinmodeR = crate::FieldReader<Winmodeselect>;
130impl WinmodeR {
131    #[doc = "Get enumerated values variant"]
132    #[inline(always)]
133    pub const fn variant(&self) -> Option<Winmodeselect> {
134        match self.bits {
135            0 => Some(Winmodeselect::Disable),
136            1 => Some(Winmodeselect::Mode1),
137            2 => Some(Winmodeselect::Mode2),
138            3 => Some(Winmodeselect::Mode3),
139            4 => Some(Winmodeselect::Mode4),
140            _ => None,
141        }
142    }
143    #[doc = "No window mode (default)"]
144    #[inline(always)]
145    pub fn is_disable(&self) -> bool {
146        *self == Winmodeselect::Disable
147    }
148    #[doc = "RESULT > WINLT"]
149    #[inline(always)]
150    pub fn is_mode1(&self) -> bool {
151        *self == Winmodeselect::Mode1
152    }
153    #[doc = "RESULT &lt; WINUT"]
154    #[inline(always)]
155    pub fn is_mode2(&self) -> bool {
156        *self == Winmodeselect::Mode2
157    }
158    #[doc = "WINLT &lt; RESULT &lt; WINUT"]
159    #[inline(always)]
160    pub fn is_mode3(&self) -> bool {
161        *self == Winmodeselect::Mode3
162    }
163    #[doc = "!(WINLT &lt; RESULT &lt; WINUT)"]
164    #[inline(always)]
165    pub fn is_mode4(&self) -> bool {
166        *self == Winmodeselect::Mode4
167    }
168}
169#[doc = "Field `WINMODE` writer - Window Monitor Mode"]
170pub type WinmodeW<'a, REG> = crate::FieldWriter<'a, REG, 3, Winmodeselect>;
171impl<'a, REG> WinmodeW<'a, REG>
172where
173    REG: crate::Writable + crate::RegisterSpec,
174    REG::Ux: From<u8>,
175{
176    #[doc = "No window mode (default)"]
177    #[inline(always)]
178    pub fn disable(self) -> &'a mut crate::W<REG> {
179        self.variant(Winmodeselect::Disable)
180    }
181    #[doc = "RESULT > WINLT"]
182    #[inline(always)]
183    pub fn mode1(self) -> &'a mut crate::W<REG> {
184        self.variant(Winmodeselect::Mode1)
185    }
186    #[doc = "RESULT &lt; WINUT"]
187    #[inline(always)]
188    pub fn mode2(self) -> &'a mut crate::W<REG> {
189        self.variant(Winmodeselect::Mode2)
190    }
191    #[doc = "WINLT &lt; RESULT &lt; WINUT"]
192    #[inline(always)]
193    pub fn mode3(self) -> &'a mut crate::W<REG> {
194        self.variant(Winmodeselect::Mode3)
195    }
196    #[doc = "!(WINLT &lt; RESULT &lt; WINUT)"]
197    #[inline(always)]
198    pub fn mode4(self) -> &'a mut crate::W<REG> {
199        self.variant(Winmodeselect::Mode4)
200    }
201}
202#[doc = "Field `WINSS` reader - Window Single Sample"]
203pub type WinssR = crate::BitReader;
204#[doc = "Field `WINSS` writer - Window Single Sample"]
205pub type WinssW<'a, REG> = crate::BitWriter<'a, REG>;
206impl R {
207    #[doc = "Bit 0 - Left-Adjusted Result"]
208    #[inline(always)]
209    pub fn leftadj(&self) -> LeftadjR {
210        LeftadjR::new((self.bits & 1) != 0)
211    }
212    #[doc = "Bit 1 - Free Running Mode"]
213    #[inline(always)]
214    pub fn freerun(&self) -> FreerunR {
215        FreerunR::new(((self.bits >> 1) & 1) != 0)
216    }
217    #[doc = "Bit 2 - Digital Correction Logic Enable"]
218    #[inline(always)]
219    pub fn corren(&self) -> CorrenR {
220        CorrenR::new(((self.bits >> 2) & 1) != 0)
221    }
222    #[doc = "Bits 3:4 - Conversion Result Resolution"]
223    #[inline(always)]
224    pub fn ressel(&self) -> ResselR {
225        ResselR::new(((self.bits >> 3) & 3) as u8)
226    }
227    #[doc = "Bits 8:10 - Window Monitor Mode"]
228    #[inline(always)]
229    pub fn winmode(&self) -> WinmodeR {
230        WinmodeR::new(((self.bits >> 8) & 7) as u8)
231    }
232    #[doc = "Bit 11 - Window Single Sample"]
233    #[inline(always)]
234    pub fn winss(&self) -> WinssR {
235        WinssR::new(((self.bits >> 11) & 1) != 0)
236    }
237}
238impl W {
239    #[doc = "Bit 0 - Left-Adjusted Result"]
240    #[inline(always)]
241    #[must_use]
242    pub fn leftadj(&mut self) -> LeftadjW<CtrlbSpec> {
243        LeftadjW::new(self, 0)
244    }
245    #[doc = "Bit 1 - Free Running Mode"]
246    #[inline(always)]
247    #[must_use]
248    pub fn freerun(&mut self) -> FreerunW<CtrlbSpec> {
249        FreerunW::new(self, 1)
250    }
251    #[doc = "Bit 2 - Digital Correction Logic Enable"]
252    #[inline(always)]
253    #[must_use]
254    pub fn corren(&mut self) -> CorrenW<CtrlbSpec> {
255        CorrenW::new(self, 2)
256    }
257    #[doc = "Bits 3:4 - Conversion Result Resolution"]
258    #[inline(always)]
259    #[must_use]
260    pub fn ressel(&mut self) -> ResselW<CtrlbSpec> {
261        ResselW::new(self, 3)
262    }
263    #[doc = "Bits 8:10 - Window Monitor Mode"]
264    #[inline(always)]
265    #[must_use]
266    pub fn winmode(&mut self) -> WinmodeW<CtrlbSpec> {
267        WinmodeW::new(self, 8)
268    }
269    #[doc = "Bit 11 - Window Single Sample"]
270    #[inline(always)]
271    #[must_use]
272    pub fn winss(&mut self) -> WinssW<CtrlbSpec> {
273        WinssW::new(self, 11)
274    }
275}
276#[doc = "Control B\n\nYou can [`read`](crate::Reg::read) this register and get [`ctrlb::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`ctrlb::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
277pub struct CtrlbSpec;
278impl crate::RegisterSpec for CtrlbSpec {
279    type Ux = u16;
280}
281#[doc = "`read()` method returns [`ctrlb::R`](R) reader structure"]
282impl crate::Readable for CtrlbSpec {}
283#[doc = "`write(|w| ..)` method takes [`ctrlb::W`](W) writer structure"]
284impl crate::Writable for CtrlbSpec {
285    type Safety = crate::Unsafe;
286    const ZERO_TO_MODIFY_FIELDS_BITMAP: u16 = 0;
287    const ONE_TO_MODIFY_FIELDS_BITMAP: u16 = 0;
288}
289#[doc = "`reset()` method sets CTRLB to value 0"]
290impl crate::Resettable for CtrlbSpec {
291    const RESET_VALUE: u16 = 0;
292}