atsamd11c/sysctrl/
osc8m.rs
1#[doc = "Register `OSC8M` reader"]
2pub type R = crate::R<Osc8mSpec>;
3#[doc = "Register `OSC8M` writer"]
4pub type W = crate::W<Osc8mSpec>;
5#[doc = "Field `ENABLE` reader - Oscillator Enable"]
6pub type EnableR = crate::BitReader;
7#[doc = "Field `ENABLE` writer - Oscillator Enable"]
8pub type EnableW<'a, REG> = crate::BitWriter<'a, REG>;
9#[doc = "Field `RUNSTDBY` reader - Run in Standby"]
10pub type RunstdbyR = crate::BitReader;
11#[doc = "Field `RUNSTDBY` writer - Run in Standby"]
12pub type RunstdbyW<'a, REG> = crate::BitWriter<'a, REG>;
13#[doc = "Field `ONDEMAND` reader - On Demand Control"]
14pub type OndemandR = crate::BitReader;
15#[doc = "Field `ONDEMAND` writer - On Demand Control"]
16pub type OndemandW<'a, REG> = crate::BitWriter<'a, REG>;
17#[doc = "Oscillator Prescaler\n\nValue on reset: 3"]
18#[derive(Clone, Copy, Debug, PartialEq, Eq)]
19#[repr(u8)]
20pub enum Prescselect {
21 #[doc = "0: 1"]
22 _0 = 0,
23 #[doc = "1: 2"]
24 _1 = 1,
25 #[doc = "2: 4"]
26 _2 = 2,
27 #[doc = "3: 8"]
28 _3 = 3,
29}
30impl From<Prescselect> for u8 {
31 #[inline(always)]
32 fn from(variant: Prescselect) -> Self {
33 variant as _
34 }
35}
36impl crate::FieldSpec for Prescselect {
37 type Ux = u8;
38}
39impl crate::IsEnum for Prescselect {}
40#[doc = "Field `PRESC` reader - Oscillator Prescaler"]
41pub type PrescR = crate::FieldReader<Prescselect>;
42impl PrescR {
43 #[doc = "Get enumerated values variant"]
44 #[inline(always)]
45 pub const fn variant(&self) -> Prescselect {
46 match self.bits {
47 0 => Prescselect::_0,
48 1 => Prescselect::_1,
49 2 => Prescselect::_2,
50 3 => Prescselect::_3,
51 _ => unreachable!(),
52 }
53 }
54 #[doc = "1"]
55 #[inline(always)]
56 pub fn is_0(&self) -> bool {
57 *self == Prescselect::_0
58 }
59 #[doc = "2"]
60 #[inline(always)]
61 pub fn is_1(&self) -> bool {
62 *self == Prescselect::_1
63 }
64 #[doc = "4"]
65 #[inline(always)]
66 pub fn is_2(&self) -> bool {
67 *self == Prescselect::_2
68 }
69 #[doc = "8"]
70 #[inline(always)]
71 pub fn is_3(&self) -> bool {
72 *self == Prescselect::_3
73 }
74}
75#[doc = "Field `PRESC` writer - Oscillator Prescaler"]
76pub type PrescW<'a, REG> = crate::FieldWriter<'a, REG, 2, Prescselect, crate::Safe>;
77impl<'a, REG> PrescW<'a, REG>
78where
79 REG: crate::Writable + crate::RegisterSpec,
80 REG::Ux: From<u8>,
81{
82 #[doc = "1"]
83 #[inline(always)]
84 pub fn _0(self) -> &'a mut crate::W<REG> {
85 self.variant(Prescselect::_0)
86 }
87 #[doc = "2"]
88 #[inline(always)]
89 pub fn _1(self) -> &'a mut crate::W<REG> {
90 self.variant(Prescselect::_1)
91 }
92 #[doc = "4"]
93 #[inline(always)]
94 pub fn _2(self) -> &'a mut crate::W<REG> {
95 self.variant(Prescselect::_2)
96 }
97 #[doc = "8"]
98 #[inline(always)]
99 pub fn _3(self) -> &'a mut crate::W<REG> {
100 self.variant(Prescselect::_3)
101 }
102}
103#[doc = "Field `CALIB` reader - Oscillator Calibration"]
104pub type CalibR = crate::FieldReader<u16>;
105#[doc = "Field `CALIB` writer - Oscillator Calibration"]
106pub type CalibW<'a, REG> = crate::FieldWriter<'a, REG, 12, u16>;
107#[doc = "Oscillator Frequency Range\n\nValue on reset: 2"]
108#[derive(Clone, Copy, Debug, PartialEq, Eq)]
109#[repr(u8)]
110pub enum Frangeselect {
111 #[doc = "0: 4 to 6MHz"]
112 _0 = 0,
113 #[doc = "1: 6 to 8MHz"]
114 _1 = 1,
115 #[doc = "2: 8 to 11MHz"]
116 _2 = 2,
117 #[doc = "3: 11 to 15MHz"]
118 _3 = 3,
119}
120impl From<Frangeselect> for u8 {
121 #[inline(always)]
122 fn from(variant: Frangeselect) -> Self {
123 variant as _
124 }
125}
126impl crate::FieldSpec for Frangeselect {
127 type Ux = u8;
128}
129impl crate::IsEnum for Frangeselect {}
130#[doc = "Field `FRANGE` reader - Oscillator Frequency Range"]
131pub type FrangeR = crate::FieldReader<Frangeselect>;
132impl FrangeR {
133 #[doc = "Get enumerated values variant"]
134 #[inline(always)]
135 pub const fn variant(&self) -> Frangeselect {
136 match self.bits {
137 0 => Frangeselect::_0,
138 1 => Frangeselect::_1,
139 2 => Frangeselect::_2,
140 3 => Frangeselect::_3,
141 _ => unreachable!(),
142 }
143 }
144 #[doc = "4 to 6MHz"]
145 #[inline(always)]
146 pub fn is_0(&self) -> bool {
147 *self == Frangeselect::_0
148 }
149 #[doc = "6 to 8MHz"]
150 #[inline(always)]
151 pub fn is_1(&self) -> bool {
152 *self == Frangeselect::_1
153 }
154 #[doc = "8 to 11MHz"]
155 #[inline(always)]
156 pub fn is_2(&self) -> bool {
157 *self == Frangeselect::_2
158 }
159 #[doc = "11 to 15MHz"]
160 #[inline(always)]
161 pub fn is_3(&self) -> bool {
162 *self == Frangeselect::_3
163 }
164}
165#[doc = "Field `FRANGE` writer - Oscillator Frequency Range"]
166pub type FrangeW<'a, REG> = crate::FieldWriter<'a, REG, 2, Frangeselect, crate::Safe>;
167impl<'a, REG> FrangeW<'a, REG>
168where
169 REG: crate::Writable + crate::RegisterSpec,
170 REG::Ux: From<u8>,
171{
172 #[doc = "4 to 6MHz"]
173 #[inline(always)]
174 pub fn _0(self) -> &'a mut crate::W<REG> {
175 self.variant(Frangeselect::_0)
176 }
177 #[doc = "6 to 8MHz"]
178 #[inline(always)]
179 pub fn _1(self) -> &'a mut crate::W<REG> {
180 self.variant(Frangeselect::_1)
181 }
182 #[doc = "8 to 11MHz"]
183 #[inline(always)]
184 pub fn _2(self) -> &'a mut crate::W<REG> {
185 self.variant(Frangeselect::_2)
186 }
187 #[doc = "11 to 15MHz"]
188 #[inline(always)]
189 pub fn _3(self) -> &'a mut crate::W<REG> {
190 self.variant(Frangeselect::_3)
191 }
192}
193impl R {
194 #[doc = "Bit 1 - Oscillator Enable"]
195 #[inline(always)]
196 pub fn enable(&self) -> EnableR {
197 EnableR::new(((self.bits >> 1) & 1) != 0)
198 }
199 #[doc = "Bit 6 - Run in Standby"]
200 #[inline(always)]
201 pub fn runstdby(&self) -> RunstdbyR {
202 RunstdbyR::new(((self.bits >> 6) & 1) != 0)
203 }
204 #[doc = "Bit 7 - On Demand Control"]
205 #[inline(always)]
206 pub fn ondemand(&self) -> OndemandR {
207 OndemandR::new(((self.bits >> 7) & 1) != 0)
208 }
209 #[doc = "Bits 8:9 - Oscillator Prescaler"]
210 #[inline(always)]
211 pub fn presc(&self) -> PrescR {
212 PrescR::new(((self.bits >> 8) & 3) as u8)
213 }
214 #[doc = "Bits 16:27 - Oscillator Calibration"]
215 #[inline(always)]
216 pub fn calib(&self) -> CalibR {
217 CalibR::new(((self.bits >> 16) & 0x0fff) as u16)
218 }
219 #[doc = "Bits 30:31 - Oscillator Frequency Range"]
220 #[inline(always)]
221 pub fn frange(&self) -> FrangeR {
222 FrangeR::new(((self.bits >> 30) & 3) as u8)
223 }
224}
225impl W {
226 #[doc = "Bit 1 - Oscillator Enable"]
227 #[inline(always)]
228 #[must_use]
229 pub fn enable(&mut self) -> EnableW<Osc8mSpec> {
230 EnableW::new(self, 1)
231 }
232 #[doc = "Bit 6 - Run in Standby"]
233 #[inline(always)]
234 #[must_use]
235 pub fn runstdby(&mut self) -> RunstdbyW<Osc8mSpec> {
236 RunstdbyW::new(self, 6)
237 }
238 #[doc = "Bit 7 - On Demand Control"]
239 #[inline(always)]
240 #[must_use]
241 pub fn ondemand(&mut self) -> OndemandW<Osc8mSpec> {
242 OndemandW::new(self, 7)
243 }
244 #[doc = "Bits 8:9 - Oscillator Prescaler"]
245 #[inline(always)]
246 #[must_use]
247 pub fn presc(&mut self) -> PrescW<Osc8mSpec> {
248 PrescW::new(self, 8)
249 }
250 #[doc = "Bits 16:27 - Oscillator Calibration"]
251 #[inline(always)]
252 #[must_use]
253 pub fn calib(&mut self) -> CalibW<Osc8mSpec> {
254 CalibW::new(self, 16)
255 }
256 #[doc = "Bits 30:31 - Oscillator Frequency Range"]
257 #[inline(always)]
258 #[must_use]
259 pub fn frange(&mut self) -> FrangeW<Osc8mSpec> {
260 FrangeW::new(self, 30)
261 }
262}
263#[doc = "8MHz Internal Oscillator (OSC8M) Control\n\nYou can [`read`](crate::Reg::read) this register and get [`osc8m::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`osc8m::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
264pub struct Osc8mSpec;
265impl crate::RegisterSpec for Osc8mSpec {
266 type Ux = u32;
267}
268#[doc = "`read()` method returns [`osc8m::R`](R) reader structure"]
269impl crate::Readable for Osc8mSpec {}
270#[doc = "`write(|w| ..)` method takes [`osc8m::W`](W) writer structure"]
271impl crate::Writable for Osc8mSpec {
272 type Safety = crate::Unsafe;
273 const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
274 const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
275}
276#[doc = "`reset()` method sets OSC8M to value 0x8707_0382"]
277impl crate::Resettable for Osc8mSpec {
278 const RESET_VALUE: u32 = 0x8707_0382;
279}