efm32hg309f64_pac/idac0/
curprog.rs

1#[doc = "Register `CURPROG` reader"]
2pub struct R(crate::R<CURPROG_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CURPROG_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CURPROG_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CURPROG_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `CURPROG` writer"]
17pub struct W(crate::W<CURPROG_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CURPROG_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<CURPROG_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CURPROG_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `RANGESEL` reader - Current Range Select"]
38pub type RANGESEL_R = crate::FieldReader<u8, RANGESEL_A>;
39#[doc = "Current Range Select\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq)]
41#[repr(u8)]
42pub enum RANGESEL_A {
43    #[doc = "0: Current range set to 0 - 1.6 uA."]
44    RANGE0 = 0,
45    #[doc = "1: Current range set to 1.6 - 4.7 uA."]
46    RANGE1 = 1,
47    #[doc = "2: Current range set to 0.5 - 16 uA."]
48    RANGE2 = 2,
49    #[doc = "3: Current range set to 2 - 64 uA."]
50    RANGE3 = 3,
51}
52impl From<RANGESEL_A> for u8 {
53    #[inline(always)]
54    fn from(variant: RANGESEL_A) -> Self {
55        variant as _
56    }
57}
58impl RANGESEL_R {
59    #[doc = "Get enumerated values variant"]
60    #[inline(always)]
61    pub fn variant(&self) -> RANGESEL_A {
62        match self.bits {
63            0 => RANGESEL_A::RANGE0,
64            1 => RANGESEL_A::RANGE1,
65            2 => RANGESEL_A::RANGE2,
66            3 => RANGESEL_A::RANGE3,
67            _ => unreachable!(),
68        }
69    }
70    #[doc = "Checks if the value of the field is `RANGE0`"]
71    #[inline(always)]
72    pub fn is_range0(&self) -> bool {
73        *self == RANGESEL_A::RANGE0
74    }
75    #[doc = "Checks if the value of the field is `RANGE1`"]
76    #[inline(always)]
77    pub fn is_range1(&self) -> bool {
78        *self == RANGESEL_A::RANGE1
79    }
80    #[doc = "Checks if the value of the field is `RANGE2`"]
81    #[inline(always)]
82    pub fn is_range2(&self) -> bool {
83        *self == RANGESEL_A::RANGE2
84    }
85    #[doc = "Checks if the value of the field is `RANGE3`"]
86    #[inline(always)]
87    pub fn is_range3(&self) -> bool {
88        *self == RANGESEL_A::RANGE3
89    }
90}
91#[doc = "Field `RANGESEL` writer - Current Range Select"]
92pub type RANGESEL_W<'a, const O: u8> =
93    crate::FieldWriterSafe<'a, u32, CURPROG_SPEC, u8, RANGESEL_A, 2, O>;
94impl<'a, const O: u8> RANGESEL_W<'a, O> {
95    #[doc = "Current range set to 0 - 1.6 uA."]
96    #[inline(always)]
97    pub fn range0(self) -> &'a mut W {
98        self.variant(RANGESEL_A::RANGE0)
99    }
100    #[doc = "Current range set to 1.6 - 4.7 uA."]
101    #[inline(always)]
102    pub fn range1(self) -> &'a mut W {
103        self.variant(RANGESEL_A::RANGE1)
104    }
105    #[doc = "Current range set to 0.5 - 16 uA."]
106    #[inline(always)]
107    pub fn range2(self) -> &'a mut W {
108        self.variant(RANGESEL_A::RANGE2)
109    }
110    #[doc = "Current range set to 2 - 64 uA."]
111    #[inline(always)]
112    pub fn range3(self) -> &'a mut W {
113        self.variant(RANGESEL_A::RANGE3)
114    }
115}
116#[doc = "Field `STEPSEL` reader - Current Step Size Select"]
117pub type STEPSEL_R = crate::FieldReader<u8, u8>;
118#[doc = "Field `STEPSEL` writer - Current Step Size Select"]
119pub type STEPSEL_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CURPROG_SPEC, u8, u8, 5, O>;
120impl R {
121    #[doc = "Bits 0:1 - Current Range Select"]
122    #[inline(always)]
123    pub fn rangesel(&self) -> RANGESEL_R {
124        RANGESEL_R::new((self.bits & 3) as u8)
125    }
126    #[doc = "Bits 8:12 - Current Step Size Select"]
127    #[inline(always)]
128    pub fn stepsel(&self) -> STEPSEL_R {
129        STEPSEL_R::new(((self.bits >> 8) & 0x1f) as u8)
130    }
131}
132impl W {
133    #[doc = "Bits 0:1 - Current Range Select"]
134    #[inline(always)]
135    pub fn rangesel(&mut self) -> RANGESEL_W<0> {
136        RANGESEL_W::new(self)
137    }
138    #[doc = "Bits 8:12 - Current Step Size Select"]
139    #[inline(always)]
140    pub fn stepsel(&mut self) -> STEPSEL_W<8> {
141        STEPSEL_W::new(self)
142    }
143    #[doc = "Writes raw bits to the register."]
144    #[inline(always)]
145    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
146        self.0.bits(bits);
147        self
148    }
149}
150#[doc = "Current Programming Register\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 [curprog](index.html) module"]
151pub struct CURPROG_SPEC;
152impl crate::RegisterSpec for CURPROG_SPEC {
153    type Ux = u32;
154}
155#[doc = "`read()` method returns [curprog::R](R) reader structure"]
156impl crate::Readable for CURPROG_SPEC {
157    type Reader = R;
158}
159#[doc = "`write(|w| ..)` method takes [curprog::W](W) writer structure"]
160impl crate::Writable for CURPROG_SPEC {
161    type Writer = W;
162}
163#[doc = "`reset()` method sets CURPROG to value 0"]
164impl crate::Resettable for CURPROG_SPEC {
165    #[inline(always)]
166    fn reset_value() -> Self::Ux {
167        0
168    }
169}