efm32pg12_pac/adc0/
cal.rs

1#[doc = "Reader of register CAL"]
2pub type R = crate::R<u32, super::CAL>;
3#[doc = "Writer for register CAL"]
4pub type W = crate::W<u32, super::CAL>;
5#[doc = "Register CAL `reset()`'s with value 0x4078_4078"]
6impl crate::ResetValue for super::CAL {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0x4078_4078
11    }
12}
13#[doc = "Reader of field `SINGLEOFFSET`"]
14pub type SINGLEOFFSET_R = crate::R<u8, u8>;
15#[doc = "Write proxy for field `SINGLEOFFSET`"]
16pub struct SINGLEOFFSET_W<'a> {
17    w: &'a mut W,
18}
19impl<'a> SINGLEOFFSET_W<'a> {
20    #[doc = r"Writes raw bits to the field"]
21    #[inline(always)]
22    pub unsafe fn bits(self, value: u8) -> &'a mut W {
23        self.w.bits = (self.w.bits & !0x0f) | ((value as u32) & 0x0f);
24        self.w
25    }
26}
27#[doc = "Reader of field `SINGLEOFFSETINV`"]
28pub type SINGLEOFFSETINV_R = crate::R<u8, u8>;
29#[doc = "Write proxy for field `SINGLEOFFSETINV`"]
30pub struct SINGLEOFFSETINV_W<'a> {
31    w: &'a mut W,
32}
33impl<'a> SINGLEOFFSETINV_W<'a> {
34    #[doc = r"Writes raw bits to the field"]
35    #[inline(always)]
36    pub unsafe fn bits(self, value: u8) -> &'a mut W {
37        self.w.bits = (self.w.bits & !(0x0f << 4)) | (((value as u32) & 0x0f) << 4);
38        self.w
39    }
40}
41#[doc = "Reader of field `SINGLEGAIN`"]
42pub type SINGLEGAIN_R = crate::R<u8, u8>;
43#[doc = "Write proxy for field `SINGLEGAIN`"]
44pub struct SINGLEGAIN_W<'a> {
45    w: &'a mut W,
46}
47impl<'a> SINGLEGAIN_W<'a> {
48    #[doc = r"Writes raw bits to the field"]
49    #[inline(always)]
50    pub unsafe fn bits(self, value: u8) -> &'a mut W {
51        self.w.bits = (self.w.bits & !(0x7f << 8)) | (((value as u32) & 0x7f) << 8);
52        self.w
53    }
54}
55#[doc = "Reader of field `OFFSETINVMODE`"]
56pub type OFFSETINVMODE_R = crate::R<bool, bool>;
57#[doc = "Write proxy for field `OFFSETINVMODE`"]
58pub struct OFFSETINVMODE_W<'a> {
59    w: &'a mut W,
60}
61impl<'a> OFFSETINVMODE_W<'a> {
62    #[doc = r"Sets the field bit"]
63    #[inline(always)]
64    pub fn set_bit(self) -> &'a mut W {
65        self.bit(true)
66    }
67    #[doc = r"Clears the field bit"]
68    #[inline(always)]
69    pub fn clear_bit(self) -> &'a mut W {
70        self.bit(false)
71    }
72    #[doc = r"Writes raw bits to the field"]
73    #[inline(always)]
74    pub fn bit(self, value: bool) -> &'a mut W {
75        self.w.bits = (self.w.bits & !(0x01 << 15)) | (((value as u32) & 0x01) << 15);
76        self.w
77    }
78}
79#[doc = "Reader of field `SCANOFFSET`"]
80pub type SCANOFFSET_R = crate::R<u8, u8>;
81#[doc = "Write proxy for field `SCANOFFSET`"]
82pub struct SCANOFFSET_W<'a> {
83    w: &'a mut W,
84}
85impl<'a> SCANOFFSET_W<'a> {
86    #[doc = r"Writes raw bits to the field"]
87    #[inline(always)]
88    pub unsafe fn bits(self, value: u8) -> &'a mut W {
89        self.w.bits = (self.w.bits & !(0x0f << 16)) | (((value as u32) & 0x0f) << 16);
90        self.w
91    }
92}
93#[doc = "Reader of field `SCANOFFSETINV`"]
94pub type SCANOFFSETINV_R = crate::R<u8, u8>;
95#[doc = "Write proxy for field `SCANOFFSETINV`"]
96pub struct SCANOFFSETINV_W<'a> {
97    w: &'a mut W,
98}
99impl<'a> SCANOFFSETINV_W<'a> {
100    #[doc = r"Writes raw bits to the field"]
101    #[inline(always)]
102    pub unsafe fn bits(self, value: u8) -> &'a mut W {
103        self.w.bits = (self.w.bits & !(0x0f << 20)) | (((value as u32) & 0x0f) << 20);
104        self.w
105    }
106}
107#[doc = "Reader of field `SCANGAIN`"]
108pub type SCANGAIN_R = crate::R<u8, u8>;
109#[doc = "Write proxy for field `SCANGAIN`"]
110pub struct SCANGAIN_W<'a> {
111    w: &'a mut W,
112}
113impl<'a> SCANGAIN_W<'a> {
114    #[doc = r"Writes raw bits to the field"]
115    #[inline(always)]
116    pub unsafe fn bits(self, value: u8) -> &'a mut W {
117        self.w.bits = (self.w.bits & !(0x7f << 24)) | (((value as u32) & 0x7f) << 24);
118        self.w
119    }
120}
121#[doc = "Reader of field `CALEN`"]
122pub type CALEN_R = crate::R<bool, bool>;
123#[doc = "Write proxy for field `CALEN`"]
124pub struct CALEN_W<'a> {
125    w: &'a mut W,
126}
127impl<'a> CALEN_W<'a> {
128    #[doc = r"Sets the field bit"]
129    #[inline(always)]
130    pub fn set_bit(self) -> &'a mut W {
131        self.bit(true)
132    }
133    #[doc = r"Clears the field bit"]
134    #[inline(always)]
135    pub fn clear_bit(self) -> &'a mut W {
136        self.bit(false)
137    }
138    #[doc = r"Writes raw bits to the field"]
139    #[inline(always)]
140    pub fn bit(self, value: bool) -> &'a mut W {
141        self.w.bits = (self.w.bits & !(0x01 << 31)) | (((value as u32) & 0x01) << 31);
142        self.w
143    }
144}
145impl R {
146    #[doc = "Bits 0:3 - Single Mode Offset Calibration Value for Differential or Positive Single-ended Mode"]
147    #[inline(always)]
148    pub fn singleoffset(&self) -> SINGLEOFFSET_R {
149        SINGLEOFFSET_R::new((self.bits & 0x0f) as u8)
150    }
151    #[doc = "Bits 4:7 - Single Mode Offset Calibration Value for Negative Single-ended Mode"]
152    #[inline(always)]
153    pub fn singleoffsetinv(&self) -> SINGLEOFFSETINV_R {
154        SINGLEOFFSETINV_R::new(((self.bits >> 4) & 0x0f) as u8)
155    }
156    #[doc = "Bits 8:14 - Single Mode Gain Calibration Value"]
157    #[inline(always)]
158    pub fn singlegain(&self) -> SINGLEGAIN_R {
159        SINGLEGAIN_R::new(((self.bits >> 8) & 0x7f) as u8)
160    }
161    #[doc = "Bit 15 - Negative Single-ended Offset Calibration is Enabled"]
162    #[inline(always)]
163    pub fn offsetinvmode(&self) -> OFFSETINVMODE_R {
164        OFFSETINVMODE_R::new(((self.bits >> 15) & 0x01) != 0)
165    }
166    #[doc = "Bits 16:19 - Scan Mode Offset Calibration Value for Differential or Positive Single-ended Mode"]
167    #[inline(always)]
168    pub fn scanoffset(&self) -> SCANOFFSET_R {
169        SCANOFFSET_R::new(((self.bits >> 16) & 0x0f) as u8)
170    }
171    #[doc = "Bits 20:23 - Scan Mode Offset Calibration Value for Negative Single-ended Mode"]
172    #[inline(always)]
173    pub fn scanoffsetinv(&self) -> SCANOFFSETINV_R {
174        SCANOFFSETINV_R::new(((self.bits >> 20) & 0x0f) as u8)
175    }
176    #[doc = "Bits 24:30 - Scan Mode Gain Calibration Value"]
177    #[inline(always)]
178    pub fn scangain(&self) -> SCANGAIN_R {
179        SCANGAIN_R::new(((self.bits >> 24) & 0x7f) as u8)
180    }
181    #[doc = "Bit 31 - Calibration Mode is Enabled"]
182    #[inline(always)]
183    pub fn calen(&self) -> CALEN_R {
184        CALEN_R::new(((self.bits >> 31) & 0x01) != 0)
185    }
186}
187impl W {
188    #[doc = "Bits 0:3 - Single Mode Offset Calibration Value for Differential or Positive Single-ended Mode"]
189    #[inline(always)]
190    pub fn singleoffset(&mut self) -> SINGLEOFFSET_W {
191        SINGLEOFFSET_W { w: self }
192    }
193    #[doc = "Bits 4:7 - Single Mode Offset Calibration Value for Negative Single-ended Mode"]
194    #[inline(always)]
195    pub fn singleoffsetinv(&mut self) -> SINGLEOFFSETINV_W {
196        SINGLEOFFSETINV_W { w: self }
197    }
198    #[doc = "Bits 8:14 - Single Mode Gain Calibration Value"]
199    #[inline(always)]
200    pub fn singlegain(&mut self) -> SINGLEGAIN_W {
201        SINGLEGAIN_W { w: self }
202    }
203    #[doc = "Bit 15 - Negative Single-ended Offset Calibration is Enabled"]
204    #[inline(always)]
205    pub fn offsetinvmode(&mut self) -> OFFSETINVMODE_W {
206        OFFSETINVMODE_W { w: self }
207    }
208    #[doc = "Bits 16:19 - Scan Mode Offset Calibration Value for Differential or Positive Single-ended Mode"]
209    #[inline(always)]
210    pub fn scanoffset(&mut self) -> SCANOFFSET_W {
211        SCANOFFSET_W { w: self }
212    }
213    #[doc = "Bits 20:23 - Scan Mode Offset Calibration Value for Negative Single-ended Mode"]
214    #[inline(always)]
215    pub fn scanoffsetinv(&mut self) -> SCANOFFSETINV_W {
216        SCANOFFSETINV_W { w: self }
217    }
218    #[doc = "Bits 24:30 - Scan Mode Gain Calibration Value"]
219    #[inline(always)]
220    pub fn scangain(&mut self) -> SCANGAIN_W {
221        SCANGAIN_W { w: self }
222    }
223    #[doc = "Bit 31 - Calibration Mode is Enabled"]
224    #[inline(always)]
225    pub fn calen(&mut self) -> CALEN_W {
226        CALEN_W { w: self }
227    }
228}