py32f0/py32f002b/adc/
ccsr.rs

1///Register `CCSR` reader
2pub struct R(crate::R<CCSR_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CCSR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CCSR_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CCSR_SPEC>) -> Self {
13        R(reader)
14    }
15}
16///Register `CCSR` writer
17pub struct W(crate::W<CCSR_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CCSR_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<CCSR_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CCSR_SPEC>) -> Self {
34        W(writer)
35    }
36}
37///Field `CALSEL` reader - Calibration contents selection
38pub type CALSEL_R = crate::BitReader<CALSEL_A>;
39/**Calibration contents selection
40
41Value on reset: 0*/
42#[derive(Clone, Copy, Debug, PartialEq, Eq)]
43pub enum CALSEL_A {
44    ///0: Calibrate offset and linearity
45    OffsetAndLinearity = 0,
46    ///1: Calibrate offset only
47    OffsetOnly = 1,
48}
49impl From<CALSEL_A> for bool {
50    #[inline(always)]
51    fn from(variant: CALSEL_A) -> Self {
52        variant as u8 != 0
53    }
54}
55impl CALSEL_R {
56    ///Get enumerated values variant
57    #[inline(always)]
58    pub fn variant(&self) -> CALSEL_A {
59        match self.bits {
60            false => CALSEL_A::OffsetAndLinearity,
61            true => CALSEL_A::OffsetOnly,
62        }
63    }
64    ///Checks if the value of the field is `OffsetAndLinearity`
65    #[inline(always)]
66    pub fn is_offset_and_linearity(&self) -> bool {
67        *self == CALSEL_A::OffsetAndLinearity
68    }
69    ///Checks if the value of the field is `OffsetOnly`
70    #[inline(always)]
71    pub fn is_offset_only(&self) -> bool {
72        *self == CALSEL_A::OffsetOnly
73    }
74}
75///Field `CALSEL` writer - Calibration contents selection
76pub type CALSEL_W<'a, const O: u8> = crate::BitWriter<'a, u32, CCSR_SPEC, CALSEL_A, O>;
77impl<'a, const O: u8> CALSEL_W<'a, O> {
78    ///Calibrate offset and linearity
79    #[inline(always)]
80    pub fn offset_and_linearity(self) -> &'a mut W {
81        self.variant(CALSEL_A::OffsetAndLinearity)
82    }
83    ///Calibrate offset only
84    #[inline(always)]
85    pub fn offset_only(self) -> &'a mut W {
86        self.variant(CALSEL_A::OffsetOnly)
87    }
88}
89///Field `CALSMP` reader - Calibration sample time selection
90pub type CALSMP_R = crate::FieldReader<u8, CALSMP_A>;
91/**Calibration sample time selection
92
93Value on reset: 0*/
94#[derive(Clone, Copy, Debug, PartialEq, Eq)]
95#[repr(u8)]
96pub enum CALSMP_A {
97    ///0: Calibration sample time is 2 cycles
98    TowCycles = 0,
99    ///1: Calibration sample time is 4 cycles
100    FourCycles = 1,
101    ///2: Calibration sample time is 8 cycles
102    EightCycles = 2,
103    ///3: Calibration sample time is 1 cycles
104    OneCycles = 3,
105}
106impl From<CALSMP_A> for u8 {
107    #[inline(always)]
108    fn from(variant: CALSMP_A) -> Self {
109        variant as _
110    }
111}
112impl CALSMP_R {
113    ///Get enumerated values variant
114    #[inline(always)]
115    pub fn variant(&self) -> CALSMP_A {
116        match self.bits {
117            0 => CALSMP_A::TowCycles,
118            1 => CALSMP_A::FourCycles,
119            2 => CALSMP_A::EightCycles,
120            3 => CALSMP_A::OneCycles,
121            _ => unreachable!(),
122        }
123    }
124    ///Checks if the value of the field is `TowCycles`
125    #[inline(always)]
126    pub fn is_tow_cycles(&self) -> bool {
127        *self == CALSMP_A::TowCycles
128    }
129    ///Checks if the value of the field is `FourCycles`
130    #[inline(always)]
131    pub fn is_four_cycles(&self) -> bool {
132        *self == CALSMP_A::FourCycles
133    }
134    ///Checks if the value of the field is `EightCycles`
135    #[inline(always)]
136    pub fn is_eight_cycles(&self) -> bool {
137        *self == CALSMP_A::EightCycles
138    }
139    ///Checks if the value of the field is `OneCycles`
140    #[inline(always)]
141    pub fn is_one_cycles(&self) -> bool {
142        *self == CALSMP_A::OneCycles
143    }
144}
145///Field `CALSMP` writer - Calibration sample time selection
146pub type CALSMP_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u32, CCSR_SPEC, u8, CALSMP_A, 2, O>;
147impl<'a, const O: u8> CALSMP_W<'a, O> {
148    ///Calibration sample time is 2 cycles
149    #[inline(always)]
150    pub fn tow_cycles(self) -> &'a mut W {
151        self.variant(CALSMP_A::TowCycles)
152    }
153    ///Calibration sample time is 4 cycles
154    #[inline(always)]
155    pub fn four_cycles(self) -> &'a mut W {
156        self.variant(CALSMP_A::FourCycles)
157    }
158    ///Calibration sample time is 8 cycles
159    #[inline(always)]
160    pub fn eight_cycles(self) -> &'a mut W {
161        self.variant(CALSMP_A::EightCycles)
162    }
163    ///Calibration sample time is 1 cycles
164    #[inline(always)]
165    pub fn one_cycles(self) -> &'a mut W {
166        self.variant(CALSMP_A::OneCycles)
167    }
168}
169///Field `CALBYP` reader - desc CALBYP
170pub type CALBYP_R = crate::BitReader<bool>;
171///Field `CALBYP` writer - desc CALBYP
172pub type CALBYP_W<'a, const O: u8> = crate::BitWriter<'a, u32, CCSR_SPEC, bool, O>;
173///Field `CALSET` reader - Calibration factor selection
174pub type CALSET_R = crate::BitReader<bool>;
175///Field `CALSET` writer - Calibration factor selection
176pub type CALSET_W<'a, const O: u8> = crate::BitWriter<'a, u32, CCSR_SPEC, bool, O>;
177///Field `OFFSUC` reader - desc OFFSUC
178pub type OFFSUC_R = crate::BitReader<OFFSUCR_A>;
179/**desc OFFSUC
180
181Value on reset: 0*/
182#[derive(Clone, Copy, Debug, PartialEq, Eq)]
183pub enum OFFSUCR_A {
184    ///0: Calibration failed
185    Failed = 0,
186    ///1: Calibration succeed
187    Succeed = 1,
188}
189impl From<OFFSUCR_A> for bool {
190    #[inline(always)]
191    fn from(variant: OFFSUCR_A) -> Self {
192        variant as u8 != 0
193    }
194}
195impl OFFSUC_R {
196    ///Get enumerated values variant
197    #[inline(always)]
198    pub fn variant(&self) -> OFFSUCR_A {
199        match self.bits {
200            false => OFFSUCR_A::Failed,
201            true => OFFSUCR_A::Succeed,
202        }
203    }
204    ///Checks if the value of the field is `Failed`
205    #[inline(always)]
206    pub fn is_failed(&self) -> bool {
207        *self == OFFSUCR_A::Failed
208    }
209    ///Checks if the value of the field is `Succeed`
210    #[inline(always)]
211    pub fn is_succeed(&self) -> bool {
212        *self == OFFSUCR_A::Succeed
213    }
214}
215/**desc OFFSUC
216
217Value on reset: 0*/
218#[derive(Clone, Copy, Debug, PartialEq, Eq)]
219pub enum OFFSUCW_AW {
220    ///1: Clear the calibration succeed flag
221    Clear = 1,
222}
223impl From<OFFSUCW_AW> for bool {
224    #[inline(always)]
225    fn from(variant: OFFSUCW_AW) -> Self {
226        variant as u8 != 0
227    }
228}
229///Field `OFFSUC` writer - desc OFFSUC
230pub type OFFSUC_W<'a, const O: u8> = crate::BitWriter<'a, u32, CCSR_SPEC, OFFSUCW_AW, O>;
231impl<'a, const O: u8> OFFSUC_W<'a, O> {
232    ///Clear the calibration succeed flag
233    #[inline(always)]
234    pub fn clear(self) -> &'a mut W {
235        self.variant(OFFSUCW_AW::Clear)
236    }
237}
238///Field `CALSUC` reader - desc CALSUC
239pub type CALSUC_R = crate::BitReader<CALSUCR_A>;
240/**desc CALSUC
241
242Value on reset: 0*/
243#[derive(Clone, Copy, Debug, PartialEq, Eq)]
244pub enum CALSUCR_A {
245    ///0: Calibration failed
246    Failed = 0,
247    ///1: Calibration succeed
248    Succeed = 1,
249}
250impl From<CALSUCR_A> for bool {
251    #[inline(always)]
252    fn from(variant: CALSUCR_A) -> Self {
253        variant as u8 != 0
254    }
255}
256impl CALSUC_R {
257    ///Get enumerated values variant
258    #[inline(always)]
259    pub fn variant(&self) -> CALSUCR_A {
260        match self.bits {
261            false => CALSUCR_A::Failed,
262            true => CALSUCR_A::Succeed,
263        }
264    }
265    ///Checks if the value of the field is `Failed`
266    #[inline(always)]
267    pub fn is_failed(&self) -> bool {
268        *self == CALSUCR_A::Failed
269    }
270    ///Checks if the value of the field is `Succeed`
271    #[inline(always)]
272    pub fn is_succeed(&self) -> bool {
273        *self == CALSUCR_A::Succeed
274    }
275}
276/**desc CALSUC
277
278Value on reset: 0*/
279#[derive(Clone, Copy, Debug, PartialEq, Eq)]
280pub enum CALSUCW_AW {
281    ///1: Clear the calibration succeed flag
282    Clear = 1,
283}
284impl From<CALSUCW_AW> for bool {
285    #[inline(always)]
286    fn from(variant: CALSUCW_AW) -> Self {
287        variant as u8 != 0
288    }
289}
290///Field `CALSUC` writer - desc CALSUC
291pub type CALSUC_W<'a, const O: u8> = crate::BitWriter<'a, u32, CCSR_SPEC, CALSUCW_AW, O>;
292impl<'a, const O: u8> CALSUC_W<'a, O> {
293    ///Clear the calibration succeed flag
294    #[inline(always)]
295    pub fn clear(self) -> &'a mut W {
296        self.variant(CALSUCW_AW::Clear)
297    }
298}
299///Field `CALON` reader - Calibration flag
300pub type CALON_R = crate::BitReader<CALONR_A>;
301/**Calibration flag
302
303Value on reset: 0*/
304#[derive(Clone, Copy, Debug, PartialEq, Eq)]
305pub enum CALONR_A {
306    ///0: Calibration off
307    Off = 0,
308    ///1: Calibration on
309    On = 1,
310}
311impl From<CALONR_A> for bool {
312    #[inline(always)]
313    fn from(variant: CALONR_A) -> Self {
314        variant as u8 != 0
315    }
316}
317impl CALON_R {
318    ///Get enumerated values variant
319    #[inline(always)]
320    pub fn variant(&self) -> CALONR_A {
321        match self.bits {
322            false => CALONR_A::Off,
323            true => CALONR_A::On,
324        }
325    }
326    ///Checks if the value of the field is `Off`
327    #[inline(always)]
328    pub fn is_off(&self) -> bool {
329        *self == CALONR_A::Off
330    }
331    ///Checks if the value of the field is `On`
332    #[inline(always)]
333    pub fn is_on(&self) -> bool {
334        *self == CALONR_A::On
335    }
336}
337impl R {
338    ///Bit 11 - Calibration contents selection
339    #[inline(always)]
340    pub fn calsel(&self) -> CALSEL_R {
341        CALSEL_R::new(((self.bits >> 11) & 1) != 0)
342    }
343    ///Bits 12:13 - Calibration sample time selection
344    #[inline(always)]
345    pub fn calsmp(&self) -> CALSMP_R {
346        CALSMP_R::new(((self.bits >> 12) & 3) as u8)
347    }
348    ///Bit 14 - desc CALBYP
349    #[inline(always)]
350    pub fn calbyp(&self) -> CALBYP_R {
351        CALBYP_R::new(((self.bits >> 14) & 1) != 0)
352    }
353    ///Bit 15 - Calibration factor selection
354    #[inline(always)]
355    pub fn calset(&self) -> CALSET_R {
356        CALSET_R::new(((self.bits >> 15) & 1) != 0)
357    }
358    ///Bit 29 - desc OFFSUC
359    #[inline(always)]
360    pub fn offsuc(&self) -> OFFSUC_R {
361        OFFSUC_R::new(((self.bits >> 29) & 1) != 0)
362    }
363    ///Bit 30 - desc CALSUC
364    #[inline(always)]
365    pub fn calsuc(&self) -> CALSUC_R {
366        CALSUC_R::new(((self.bits >> 30) & 1) != 0)
367    }
368    ///Bit 31 - Calibration flag
369    #[inline(always)]
370    pub fn calon(&self) -> CALON_R {
371        CALON_R::new(((self.bits >> 31) & 1) != 0)
372    }
373}
374impl W {
375    ///Bit 11 - Calibration contents selection
376    #[inline(always)]
377    #[must_use]
378    pub fn calsel(&mut self) -> CALSEL_W<11> {
379        CALSEL_W::new(self)
380    }
381    ///Bits 12:13 - Calibration sample time selection
382    #[inline(always)]
383    #[must_use]
384    pub fn calsmp(&mut self) -> CALSMP_W<12> {
385        CALSMP_W::new(self)
386    }
387    ///Bit 14 - desc CALBYP
388    #[inline(always)]
389    #[must_use]
390    pub fn calbyp(&mut self) -> CALBYP_W<14> {
391        CALBYP_W::new(self)
392    }
393    ///Bit 15 - Calibration factor selection
394    #[inline(always)]
395    #[must_use]
396    pub fn calset(&mut self) -> CALSET_W<15> {
397        CALSET_W::new(self)
398    }
399    ///Bit 29 - desc OFFSUC
400    #[inline(always)]
401    #[must_use]
402    pub fn offsuc(&mut self) -> OFFSUC_W<29> {
403        OFFSUC_W::new(self)
404    }
405    ///Bit 30 - desc CALSUC
406    #[inline(always)]
407    #[must_use]
408    pub fn calsuc(&mut self) -> CALSUC_W<30> {
409        CALSUC_W::new(self)
410    }
411    ///Writes raw bits to the register.
412    #[inline(always)]
413    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
414        self.0.bits(bits);
415        self
416    }
417}
418/**ADC calibration configuration and status register
419
420This 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).
421
422For information about available fields see [ccsr](index.html) module*/
423pub struct CCSR_SPEC;
424impl crate::RegisterSpec for CCSR_SPEC {
425    type Ux = u32;
426}
427///`read()` method returns [ccsr::R](R) reader structure
428impl crate::Readable for CCSR_SPEC {
429    type Reader = R;
430}
431///`write(|w| ..)` method takes [ccsr::W](W) writer structure
432impl crate::Writable for CCSR_SPEC {
433    type Writer = W;
434    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
435    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
436}
437///`reset()` method sets CCSR to value 0
438impl crate::Resettable for CCSR_SPEC {
439    const RESET_VALUE: Self::Ux = 0;
440}