1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
#[doc = "Register `OVSAMPCTL` reader"]
pub type R = crate::R<OvsampctlSpec>;
#[doc = "Register `OVSAMPCTL` writer"]
pub type W = crate::W<OvsampctlSpec>;
#[doc = "Oversampler Enable\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Ovsen {
    #[doc = "0: Oversampling disabled"]
    Disabled = 0,
    #[doc = "1: Oversampling enabled"]
    Enabled = 1,
}
impl From<Ovsen> for bool {
    #[inline(always)]
    fn from(variant: Ovsen) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `OVSEN` reader - Oversampler Enable"]
pub type OvsenR = crate::BitReader<Ovsen>;
impl OvsenR {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub const fn variant(&self) -> Ovsen {
        match self.bits {
            false => Ovsen::Disabled,
            true => Ovsen::Enabled,
        }
    }
    #[doc = "Oversampling disabled"]
    #[inline(always)]
    pub fn is_disabled(&self) -> bool {
        *self == Ovsen::Disabled
    }
    #[doc = "Oversampling enabled"]
    #[inline(always)]
    pub fn is_enabled(&self) -> bool {
        *self == Ovsen::Enabled
    }
}
#[doc = "Field `OVSEN` writer - Oversampler Enable"]
pub type OvsenW<'a, REG> = crate::BitWriter<'a, REG, Ovsen>;
impl<'a, REG> OvsenW<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
    #[doc = "Oversampling disabled"]
    #[inline(always)]
    pub fn disabled(self) -> &'a mut crate::W<REG> {
        self.variant(Ovsen::Disabled)
    }
    #[doc = "Oversampling enabled"]
    #[inline(always)]
    pub fn enabled(self) -> &'a mut crate::W<REG> {
        self.variant(Ovsen::Enabled)
    }
}
#[doc = "Oversampling ratio\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum Ovsr {
    #[doc = "0: 2x"]
    Times2 = 0,
    #[doc = "1: 4x"]
    Times4 = 1,
    #[doc = "2: 8x"]
    Times8 = 2,
    #[doc = "3: 16x"]
    Times16 = 3,
    #[doc = "4: 32x"]
    Times32 = 4,
    #[doc = "5: 64x"]
    Times64 = 5,
    #[doc = "6: 128x"]
    Times128 = 6,
    #[doc = "7: 256x"]
    Times256 = 7,
}
impl From<Ovsr> for u8 {
    #[inline(always)]
    fn from(variant: Ovsr) -> Self {
        variant as _
    }
}
impl crate::FieldSpec for Ovsr {
    type Ux = u8;
}
#[doc = "Field `OVSR` reader - Oversampling ratio"]
pub type OvsrR = crate::FieldReader<Ovsr>;
impl OvsrR {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub const fn variant(&self) -> Ovsr {
        match self.bits {
            0 => Ovsr::Times2,
            1 => Ovsr::Times4,
            2 => Ovsr::Times8,
            3 => Ovsr::Times16,
            4 => Ovsr::Times32,
            5 => Ovsr::Times64,
            6 => Ovsr::Times128,
            7 => Ovsr::Times256,
            _ => unreachable!(),
        }
    }
    #[doc = "2x"]
    #[inline(always)]
    pub fn is_times2(&self) -> bool {
        *self == Ovsr::Times2
    }
    #[doc = "4x"]
    #[inline(always)]
    pub fn is_times4(&self) -> bool {
        *self == Ovsr::Times4
    }
    #[doc = "8x"]
    #[inline(always)]
    pub fn is_times8(&self) -> bool {
        *self == Ovsr::Times8
    }
    #[doc = "16x"]
    #[inline(always)]
    pub fn is_times16(&self) -> bool {
        *self == Ovsr::Times16
    }
    #[doc = "32x"]
    #[inline(always)]
    pub fn is_times32(&self) -> bool {
        *self == Ovsr::Times32
    }
    #[doc = "64x"]
    #[inline(always)]
    pub fn is_times64(&self) -> bool {
        *self == Ovsr::Times64
    }
    #[doc = "128x"]
    #[inline(always)]
    pub fn is_times128(&self) -> bool {
        *self == Ovsr::Times128
    }
    #[doc = "256x"]
    #[inline(always)]
    pub fn is_times256(&self) -> bool {
        *self == Ovsr::Times256
    }
}
#[doc = "Field `OVSR` writer - Oversampling ratio"]
pub type OvsrW<'a, REG> = crate::FieldWriterSafe<'a, REG, 3, Ovsr>;
impl<'a, REG> OvsrW<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
    REG::Ux: From<u8>,
{
    #[doc = "2x"]
    #[inline(always)]
    pub fn times2(self) -> &'a mut crate::W<REG> {
        self.variant(Ovsr::Times2)
    }
    #[doc = "4x"]
    #[inline(always)]
    pub fn times4(self) -> &'a mut crate::W<REG> {
        self.variant(Ovsr::Times4)
    }
    #[doc = "8x"]
    #[inline(always)]
    pub fn times8(self) -> &'a mut crate::W<REG> {
        self.variant(Ovsr::Times8)
    }
    #[doc = "16x"]
    #[inline(always)]
    pub fn times16(self) -> &'a mut crate::W<REG> {
        self.variant(Ovsr::Times16)
    }
    #[doc = "32x"]
    #[inline(always)]
    pub fn times32(self) -> &'a mut crate::W<REG> {
        self.variant(Ovsr::Times32)
    }
    #[doc = "64x"]
    #[inline(always)]
    pub fn times64(self) -> &'a mut crate::W<REG> {
        self.variant(Ovsr::Times64)
    }
    #[doc = "128x"]
    #[inline(always)]
    pub fn times128(self) -> &'a mut crate::W<REG> {
        self.variant(Ovsr::Times128)
    }
    #[doc = "256x"]
    #[inline(always)]
    pub fn times256(self) -> &'a mut crate::W<REG> {
        self.variant(Ovsr::Times256)
    }
}
#[doc = "Field `OVSS` reader - Oversampling shift"]
pub type OvssR = crate::FieldReader;
#[doc = "Field `OVSS` writer - Oversampling shift"]
pub type OvssW<'a, REG> = crate::FieldWriter<'a, REG, 4>;
#[doc = "Triggered Oversampling\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Tovs {
    #[doc = "0: All oversampled conversions are done consecutively"]
    Consecutive = 0,
    #[doc = "1: Each oversampled conversion needs a trigger"]
    Individual = 1,
}
impl From<Tovs> for bool {
    #[inline(always)]
    fn from(variant: Tovs) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `TOVS` reader - Triggered Oversampling"]
pub type TovsR = crate::BitReader<Tovs>;
impl TovsR {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub const fn variant(&self) -> Tovs {
        match self.bits {
            false => Tovs::Consecutive,
            true => Tovs::Individual,
        }
    }
    #[doc = "All oversampled conversions are done consecutively"]
    #[inline(always)]
    pub fn is_consecutive(&self) -> bool {
        *self == Tovs::Consecutive
    }
    #[doc = "Each oversampled conversion needs a trigger"]
    #[inline(always)]
    pub fn is_individual(&self) -> bool {
        *self == Tovs::Individual
    }
}
#[doc = "Field `TOVS` writer - Triggered Oversampling"]
pub type TovsW<'a, REG> = crate::BitWriter<'a, REG, Tovs>;
impl<'a, REG> TovsW<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
    #[doc = "All oversampled conversions are done consecutively"]
    #[inline(always)]
    pub fn consecutive(self) -> &'a mut crate::W<REG> {
        self.variant(Tovs::Consecutive)
    }
    #[doc = "Each oversampled conversion needs a trigger"]
    #[inline(always)]
    pub fn individual(self) -> &'a mut crate::W<REG> {
        self.variant(Tovs::Individual)
    }
}
impl R {
    #[doc = "Bit 0 - Oversampler Enable"]
    #[inline(always)]
    pub fn ovsen(&self) -> OvsenR {
        OvsenR::new((self.bits & 1) != 0)
    }
    #[doc = "Bits 2:4 - Oversampling ratio"]
    #[inline(always)]
    pub fn ovsr(&self) -> OvsrR {
        OvsrR::new(((self.bits >> 2) & 7) as u8)
    }
    #[doc = "Bits 5:8 - Oversampling shift"]
    #[inline(always)]
    pub fn ovss(&self) -> OvssR {
        OvssR::new(((self.bits >> 5) & 0x0f) as u8)
    }
    #[doc = "Bit 9 - Triggered Oversampling"]
    #[inline(always)]
    pub fn tovs(&self) -> TovsR {
        TovsR::new(((self.bits >> 9) & 1) != 0)
    }
}
impl W {
    #[doc = "Bit 0 - Oversampler Enable"]
    #[inline(always)]
    #[must_use]
    pub fn ovsen(&mut self) -> OvsenW<OvsampctlSpec> {
        OvsenW::new(self, 0)
    }
    #[doc = "Bits 2:4 - Oversampling ratio"]
    #[inline(always)]
    #[must_use]
    pub fn ovsr(&mut self) -> OvsrW<OvsampctlSpec> {
        OvsrW::new(self, 2)
    }
    #[doc = "Bits 5:8 - Oversampling shift"]
    #[inline(always)]
    #[must_use]
    pub fn ovss(&mut self) -> OvssW<OvsampctlSpec> {
        OvssW::new(self, 5)
    }
    #[doc = "Bit 9 - Triggered Oversampling"]
    #[inline(always)]
    #[must_use]
    pub fn tovs(&mut self) -> TovsW<OvsampctlSpec> {
        TovsW::new(self, 9)
    }
}
#[doc = "oversample control register\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`ovsampctl::R`](R).  You can [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero) this register using [`ovsampctl::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
pub struct OvsampctlSpec;
impl crate::RegisterSpec for OvsampctlSpec {
    type Ux = u32;
}
#[doc = "`read()` method returns [`ovsampctl::R`](R) reader structure"]
impl crate::Readable for OvsampctlSpec {}
#[doc = "`write(|w| ..)` method takes [`ovsampctl::W`](W) writer structure"]
impl crate::Writable for OvsampctlSpec {
    type Safety = crate::Unsafe;
    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
}
#[doc = "`reset()` method sets OVSAMPCTL to value 0"]
impl crate::Resettable for OvsampctlSpec {
    const RESET_VALUE: u32 = 0;
}