py32f0/py32f040/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 - desc CALSEL
38pub type CALSEL_R = crate::BitReader<CALSEL_A>;
39/**desc CALSEL
40
41Value on reset: 0*/
42#[derive(Clone, Copy, Debug, PartialEq, Eq)]
43pub enum CALSEL_A {
44    ///0: Calibration of OFFSET and linearity
45    OffsetLinearity = 0,
46    ///1: Calibration of OFFSET only
47    Offset = 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::OffsetLinearity,
61            true => CALSEL_A::Offset,
62        }
63    }
64    ///Checks if the value of the field is `OffsetLinearity`
65    #[inline(always)]
66    pub fn is_offset_linearity(&self) -> bool {
67        *self == CALSEL_A::OffsetLinearity
68    }
69    ///Checks if the value of the field is `Offset`
70    #[inline(always)]
71    pub fn is_offset(&self) -> bool {
72        *self == CALSEL_A::Offset
73    }
74}
75///Field `CALSEL` writer - desc CALSEL
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    ///Calibration of OFFSET and linearity
79    #[inline(always)]
80    pub fn offset_linearity(self) -> &'a mut W {
81        self.variant(CALSEL_A::OffsetLinearity)
82    }
83    ///Calibration of OFFSET only
84    #[inline(always)]
85    pub fn offset(self) -> &'a mut W {
86        self.variant(CALSEL_A::Offset)
87    }
88}
89///Field `CALSMP` reader - desc CALSMP
90pub type CALSMP_R = crate::FieldReader<u8, CALSMP_A>;
91/**desc CALSMP
92
93Value on reset: 0*/
94#[derive(Clone, Copy, Debug, PartialEq, Eq)]
95#[repr(u8)]
96pub enum CALSMP_A {
97    ///0: 1 ADC clock period
98    Clock1 = 0,
99    ///1: 2 ADC clock periods
100    Clock2 = 1,
101    ///2: 4 ADC clock periods
102    Clock4 = 2,
103    ///3: 8 ADC clock periods
104    Clock8 = 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::Clock1,
118            1 => CALSMP_A::Clock2,
119            2 => CALSMP_A::Clock4,
120            3 => CALSMP_A::Clock8,
121            _ => unreachable!(),
122        }
123    }
124    ///Checks if the value of the field is `Clock1`
125    #[inline(always)]
126    pub fn is_clock1(&self) -> bool {
127        *self == CALSMP_A::Clock1
128    }
129    ///Checks if the value of the field is `Clock2`
130    #[inline(always)]
131    pub fn is_clock2(&self) -> bool {
132        *self == CALSMP_A::Clock2
133    }
134    ///Checks if the value of the field is `Clock4`
135    #[inline(always)]
136    pub fn is_clock4(&self) -> bool {
137        *self == CALSMP_A::Clock4
138    }
139    ///Checks if the value of the field is `Clock8`
140    #[inline(always)]
141    pub fn is_clock8(&self) -> bool {
142        *self == CALSMP_A::Clock8
143    }
144}
145///Field `CALSMP` writer - desc CALSMP
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    ///1 ADC clock period
149    #[inline(always)]
150    pub fn clock1(self) -> &'a mut W {
151        self.variant(CALSMP_A::Clock1)
152    }
153    ///2 ADC clock periods
154    #[inline(always)]
155    pub fn clock2(self) -> &'a mut W {
156        self.variant(CALSMP_A::Clock2)
157    }
158    ///4 ADC clock periods
159    #[inline(always)]
160    pub fn clock4(self) -> &'a mut W {
161        self.variant(CALSMP_A::Clock4)
162    }
163    ///8 ADC clock periods
164    #[inline(always)]
165    pub fn clock8(self) -> &'a mut W {
166        self.variant(CALSMP_A::Clock8)
167    }
168}
169///Field `CALBYP` reader - desc CALBYP
170pub type CALBYP_R = crate::BitReader<CALBYPR_A>;
171/**desc CALBYP
172
173Value on reset: 0*/
174#[derive(Clone, Copy, Debug, PartialEq, Eq)]
175pub enum CALBYPR_A {
176    ///0: Calibration factor bypass not successful
177    Valid = 0,
178    ///1: Calibration factor bypass successful
179    NotValid = 1,
180}
181impl From<CALBYPR_A> for bool {
182    #[inline(always)]
183    fn from(variant: CALBYPR_A) -> Self {
184        variant as u8 != 0
185    }
186}
187impl CALBYP_R {
188    ///Get enumerated values variant
189    #[inline(always)]
190    pub fn variant(&self) -> CALBYPR_A {
191        match self.bits {
192            false => CALBYPR_A::Valid,
193            true => CALBYPR_A::NotValid,
194        }
195    }
196    ///Checks if the value of the field is `Valid`
197    #[inline(always)]
198    pub fn is_valid(&self) -> bool {
199        *self == CALBYPR_A::Valid
200    }
201    ///Checks if the value of the field is `NotValid`
202    #[inline(always)]
203    pub fn is_not_valid(&self) -> bool {
204        *self == CALBYPR_A::NotValid
205    }
206}
207/**desc CALBYP
208
209Value on reset: 0*/
210#[derive(Clone, Copy, Debug, PartialEq, Eq)]
211pub enum CALBYPW_AW {
212    ///1: Clear
213    Clear = 1,
214}
215impl From<CALBYPW_AW> for bool {
216    #[inline(always)]
217    fn from(variant: CALBYPW_AW) -> Self {
218        variant as u8 != 0
219    }
220}
221///Field `CALBYP` writer - desc CALBYP
222pub type CALBYP_W<'a, const O: u8> = crate::BitWriter<'a, u32, CCSR_SPEC, CALBYPW_AW, O>;
223impl<'a, const O: u8> CALBYP_W<'a, O> {
224    ///Clear
225    #[inline(always)]
226    pub fn clear(self) -> &'a mut W {
227        self.variant(CALBYPW_AW::Clear)
228    }
229}
230///Field `CALSET` reader - desc CALSET
231pub type CALSET_R = crate::BitReader<CALSETR_A>;
232/**desc CALSET
233
234Value on reset: 0*/
235#[derive(Clone, Copy, Debug, PartialEq, Eq)]
236pub enum CALSETR_A {
237    ///0: Capacitance factor selection valid
238    Valid = 0,
239    ///1: Capacitance factor not valid
240    NotValid = 1,
241}
242impl From<CALSETR_A> for bool {
243    #[inline(always)]
244    fn from(variant: CALSETR_A) -> Self {
245        variant as u8 != 0
246    }
247}
248impl CALSET_R {
249    ///Get enumerated values variant
250    #[inline(always)]
251    pub fn variant(&self) -> CALSETR_A {
252        match self.bits {
253            false => CALSETR_A::Valid,
254            true => CALSETR_A::NotValid,
255        }
256    }
257    ///Checks if the value of the field is `Valid`
258    #[inline(always)]
259    pub fn is_valid(&self) -> bool {
260        *self == CALSETR_A::Valid
261    }
262    ///Checks if the value of the field is `NotValid`
263    #[inline(always)]
264    pub fn is_not_valid(&self) -> bool {
265        *self == CALSETR_A::NotValid
266    }
267}
268/**desc CALSET
269
270Value on reset: 0*/
271#[derive(Clone, Copy, Debug, PartialEq, Eq)]
272pub enum CALSETW_AW {
273    ///1: Clear
274    Clear = 1,
275}
276impl From<CALSETW_AW> for bool {
277    #[inline(always)]
278    fn from(variant: CALSETW_AW) -> Self {
279        variant as u8 != 0
280    }
281}
282///Field `CALSET` writer - desc CALSET
283pub type CALSET_W<'a, const O: u8> = crate::BitWriter<'a, u32, CCSR_SPEC, CALSETW_AW, O>;
284impl<'a, const O: u8> CALSET_W<'a, O> {
285    ///Clear
286    #[inline(always)]
287    pub fn clear(self) -> &'a mut W {
288        self.variant(CALSETW_AW::Clear)
289    }
290}
291///Field `OFFSUC` reader - desc OFFSUC
292pub type OFFSUC_R = crate::BitReader<OFFSUCR_A>;
293/**desc OFFSUC
294
295Value on reset: 0*/
296#[derive(Clone, Copy, Debug, PartialEq, Eq)]
297pub enum OFFSUCR_A {
298    ///0: Offset calibration not successful
299    NotSuccessful = 0,
300    ///1: Offset calibration successful
301    Successful = 1,
302}
303impl From<OFFSUCR_A> for bool {
304    #[inline(always)]
305    fn from(variant: OFFSUCR_A) -> Self {
306        variant as u8 != 0
307    }
308}
309impl OFFSUC_R {
310    ///Get enumerated values variant
311    #[inline(always)]
312    pub fn variant(&self) -> OFFSUCR_A {
313        match self.bits {
314            false => OFFSUCR_A::NotSuccessful,
315            true => OFFSUCR_A::Successful,
316        }
317    }
318    ///Checks if the value of the field is `NotSuccessful`
319    #[inline(always)]
320    pub fn is_not_successful(&self) -> bool {
321        *self == OFFSUCR_A::NotSuccessful
322    }
323    ///Checks if the value of the field is `Successful`
324    #[inline(always)]
325    pub fn is_successful(&self) -> bool {
326        *self == OFFSUCR_A::Successful
327    }
328}
329/**desc OFFSUC
330
331Value on reset: 0*/
332#[derive(Clone, Copy, Debug, PartialEq, Eq)]
333pub enum OFFSUCW_AW {
334    ///1: Set to zero
335    Clear = 1,
336}
337impl From<OFFSUCW_AW> for bool {
338    #[inline(always)]
339    fn from(variant: OFFSUCW_AW) -> Self {
340        variant as u8 != 0
341    }
342}
343///Field `OFFSUC` writer - desc OFFSUC
344pub type OFFSUC_W<'a, const O: u8> = crate::BitWriter<'a, u32, CCSR_SPEC, OFFSUCW_AW, O>;
345impl<'a, const O: u8> OFFSUC_W<'a, O> {
346    ///Set to zero
347    #[inline(always)]
348    pub fn clear(self) -> &'a mut W {
349        self.variant(OFFSUCW_AW::Clear)
350    }
351}
352///Field `CAPSUC` reader - desc CALFAIL
353pub type CAPSUC_R = crate::BitReader<CAPSUCR_A>;
354/**desc CALFAIL
355
356Value on reset: 0*/
357#[derive(Clone, Copy, Debug, PartialEq, Eq)]
358pub enum CAPSUCR_A {
359    ///0: Capacitance calibration not successful
360    NotSuccessful = 0,
361    ///1: Capacitance calibration successful
362    Successful = 1,
363}
364impl From<CAPSUCR_A> for bool {
365    #[inline(always)]
366    fn from(variant: CAPSUCR_A) -> Self {
367        variant as u8 != 0
368    }
369}
370impl CAPSUC_R {
371    ///Get enumerated values variant
372    #[inline(always)]
373    pub fn variant(&self) -> CAPSUCR_A {
374        match self.bits {
375            false => CAPSUCR_A::NotSuccessful,
376            true => CAPSUCR_A::Successful,
377        }
378    }
379    ///Checks if the value of the field is `NotSuccessful`
380    #[inline(always)]
381    pub fn is_not_successful(&self) -> bool {
382        *self == CAPSUCR_A::NotSuccessful
383    }
384    ///Checks if the value of the field is `Successful`
385    #[inline(always)]
386    pub fn is_successful(&self) -> bool {
387        *self == CAPSUCR_A::Successful
388    }
389}
390/**desc CALFAIL
391
392Value on reset: 0*/
393#[derive(Clone, Copy, Debug, PartialEq, Eq)]
394pub enum CAPSUCW_AW {
395    ///1: Set to zero
396    Clear = 1,
397}
398impl From<CAPSUCW_AW> for bool {
399    #[inline(always)]
400    fn from(variant: CAPSUCW_AW) -> Self {
401        variant as u8 != 0
402    }
403}
404///Field `CAPSUC` writer - desc CALFAIL
405pub type CAPSUC_W<'a, const O: u8> = crate::BitWriter<'a, u32, CCSR_SPEC, CAPSUCW_AW, O>;
406impl<'a, const O: u8> CAPSUC_W<'a, O> {
407    ///Set to zero
408    #[inline(always)]
409    pub fn clear(self) -> &'a mut W {
410        self.variant(CAPSUCW_AW::Clear)
411    }
412}
413///Field `CALON` reader - desc CALON
414pub type CALON_R = crate::BitReader<CALON_A>;
415/**desc CALON
416
417Value on reset: 0*/
418#[derive(Clone, Copy, Debug, PartialEq, Eq)]
419pub enum CALON_A {
420    ///0: ADC calibration in progress
421    InProgress = 0,
422    ///1: ADC calibration completed or has not been initiated
423    Completed = 1,
424}
425impl From<CALON_A> for bool {
426    #[inline(always)]
427    fn from(variant: CALON_A) -> Self {
428        variant as u8 != 0
429    }
430}
431impl CALON_R {
432    ///Get enumerated values variant
433    #[inline(always)]
434    pub fn variant(&self) -> CALON_A {
435        match self.bits {
436            false => CALON_A::InProgress,
437            true => CALON_A::Completed,
438        }
439    }
440    ///Checks if the value of the field is `InProgress`
441    #[inline(always)]
442    pub fn is_in_progress(&self) -> bool {
443        *self == CALON_A::InProgress
444    }
445    ///Checks if the value of the field is `Completed`
446    #[inline(always)]
447    pub fn is_completed(&self) -> bool {
448        *self == CALON_A::Completed
449    }
450}
451impl R {
452    ///Bit 11 - desc CALSEL
453    #[inline(always)]
454    pub fn calsel(&self) -> CALSEL_R {
455        CALSEL_R::new(((self.bits >> 11) & 1) != 0)
456    }
457    ///Bits 12:13 - desc CALSMP
458    #[inline(always)]
459    pub fn calsmp(&self) -> CALSMP_R {
460        CALSMP_R::new(((self.bits >> 12) & 3) as u8)
461    }
462    ///Bit 14 - desc CALBYP
463    #[inline(always)]
464    pub fn calbyp(&self) -> CALBYP_R {
465        CALBYP_R::new(((self.bits >> 14) & 1) != 0)
466    }
467    ///Bit 15 - desc CALSET
468    #[inline(always)]
469    pub fn calset(&self) -> CALSET_R {
470        CALSET_R::new(((self.bits >> 15) & 1) != 0)
471    }
472    ///Bit 29 - desc OFFSUC
473    #[inline(always)]
474    pub fn offsuc(&self) -> OFFSUC_R {
475        OFFSUC_R::new(((self.bits >> 29) & 1) != 0)
476    }
477    ///Bit 30 - desc CALFAIL
478    #[inline(always)]
479    pub fn capsuc(&self) -> CAPSUC_R {
480        CAPSUC_R::new(((self.bits >> 30) & 1) != 0)
481    }
482    ///Bit 31 - desc CALON
483    #[inline(always)]
484    pub fn calon(&self) -> CALON_R {
485        CALON_R::new(((self.bits >> 31) & 1) != 0)
486    }
487}
488impl W {
489    ///Bit 11 - desc CALSEL
490    #[inline(always)]
491    #[must_use]
492    pub fn calsel(&mut self) -> CALSEL_W<11> {
493        CALSEL_W::new(self)
494    }
495    ///Bits 12:13 - desc CALSMP
496    #[inline(always)]
497    #[must_use]
498    pub fn calsmp(&mut self) -> CALSMP_W<12> {
499        CALSMP_W::new(self)
500    }
501    ///Bit 14 - desc CALBYP
502    #[inline(always)]
503    #[must_use]
504    pub fn calbyp(&mut self) -> CALBYP_W<14> {
505        CALBYP_W::new(self)
506    }
507    ///Bit 15 - desc CALSET
508    #[inline(always)]
509    #[must_use]
510    pub fn calset(&mut self) -> CALSET_W<15> {
511        CALSET_W::new(self)
512    }
513    ///Bit 29 - desc OFFSUC
514    #[inline(always)]
515    #[must_use]
516    pub fn offsuc(&mut self) -> OFFSUC_W<29> {
517        OFFSUC_W::new(self)
518    }
519    ///Bit 30 - desc CALFAIL
520    #[inline(always)]
521    #[must_use]
522    pub fn capsuc(&mut self) -> CAPSUC_W<30> {
523        CAPSUC_W::new(self)
524    }
525    ///Writes raw bits to the register.
526    #[inline(always)]
527    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
528        self.0.bits(bits);
529        self
530    }
531}
532/**desc CCSR
533
534This 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).
535
536For information about available fields see [ccsr](index.html) module*/
537pub struct CCSR_SPEC;
538impl crate::RegisterSpec for CCSR_SPEC {
539    type Ux = u32;
540}
541///`read()` method returns [ccsr::R](R) reader structure
542impl crate::Readable for CCSR_SPEC {
543    type Reader = R;
544}
545///`write(|w| ..)` method takes [ccsr::W](W) writer structure
546impl crate::Writable for CCSR_SPEC {
547    type Writer = W;
548    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
549    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
550}
551///`reset()` method sets CCSR to value 0
552impl crate::Resettable for CCSR_SPEC {
553    const RESET_VALUE: Self::Ux = 0;
554}