atsam4sd16b_pac/pmc/
ckgr_mor.rs1#[doc = "Register `CKGR_MOR` reader"]
2pub struct R(crate::R<CKGR_MOR_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<CKGR_MOR_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<CKGR_MOR_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<CKGR_MOR_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `CKGR_MOR` writer"]
17pub struct W(crate::W<CKGR_MOR_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<CKGR_MOR_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<CKGR_MOR_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<CKGR_MOR_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `MOSCXTEN` reader - Main Crystal Oscillator Enable"]
38pub type MOSCXTEN_R = crate::BitReader<bool>;
39#[doc = "Field `MOSCXTEN` writer - Main Crystal Oscillator Enable"]
40pub type MOSCXTEN_W<'a, const O: u8> = crate::BitWriter<'a, u32, CKGR_MOR_SPEC, bool, O>;
41#[doc = "Field `MOSCXTBY` reader - Main Crystal Oscillator Bypass"]
42pub type MOSCXTBY_R = crate::BitReader<bool>;
43#[doc = "Field `MOSCXTBY` writer - Main Crystal Oscillator Bypass"]
44pub type MOSCXTBY_W<'a, const O: u8> = crate::BitWriter<'a, u32, CKGR_MOR_SPEC, bool, O>;
45#[doc = "Field `WAITMODE` reader - Wait Mode Command"]
46pub type WAITMODE_R = crate::BitReader<bool>;
47#[doc = "Field `WAITMODE` writer - Wait Mode Command"]
48pub type WAITMODE_W<'a, const O: u8> = crate::BitWriter<'a, u32, CKGR_MOR_SPEC, bool, O>;
49#[doc = "Field `MOSCRCEN` reader - Main On-Chip RC Oscillator Enable"]
50pub type MOSCRCEN_R = crate::BitReader<bool>;
51#[doc = "Field `MOSCRCEN` writer - Main On-Chip RC Oscillator Enable"]
52pub type MOSCRCEN_W<'a, const O: u8> = crate::BitWriter<'a, u32, CKGR_MOR_SPEC, bool, O>;
53#[doc = "Field `MOSCRCF` reader - Main On-Chip RC Oscillator Frequency Selection"]
54pub type MOSCRCF_R = crate::FieldReader<u8, MOSCRCF_A>;
55#[doc = "Main On-Chip RC Oscillator Frequency Selection\n\nValue on reset: 0"]
56#[derive(Clone, Copy, Debug, PartialEq, Eq)]
57#[repr(u8)]
58pub enum MOSCRCF_A {
59 #[doc = "0: The Fast RC Oscillator Frequency is at 4 MHz (default)"]
60 _4_MHZ = 0,
61 #[doc = "1: The Fast RC Oscillator Frequency is at 8 MHz"]
62 _8_MHZ = 1,
63 #[doc = "2: The Fast RC Oscillator Frequency is at 12 MHz"]
64 _12_MHZ = 2,
65}
66impl From<MOSCRCF_A> for u8 {
67 #[inline(always)]
68 fn from(variant: MOSCRCF_A) -> Self {
69 variant as _
70 }
71}
72impl MOSCRCF_R {
73 #[doc = "Get enumerated values variant"]
74 #[inline(always)]
75 pub fn variant(&self) -> Option<MOSCRCF_A> {
76 match self.bits {
77 0 => Some(MOSCRCF_A::_4_MHZ),
78 1 => Some(MOSCRCF_A::_8_MHZ),
79 2 => Some(MOSCRCF_A::_12_MHZ),
80 _ => None,
81 }
82 }
83 #[doc = "Checks if the value of the field is `_4_MHZ`"]
84 #[inline(always)]
85 pub fn is_4_mhz(&self) -> bool {
86 *self == MOSCRCF_A::_4_MHZ
87 }
88 #[doc = "Checks if the value of the field is `_8_MHZ`"]
89 #[inline(always)]
90 pub fn is_8_mhz(&self) -> bool {
91 *self == MOSCRCF_A::_8_MHZ
92 }
93 #[doc = "Checks if the value of the field is `_12_MHZ`"]
94 #[inline(always)]
95 pub fn is_12_mhz(&self) -> bool {
96 *self == MOSCRCF_A::_12_MHZ
97 }
98}
99#[doc = "Field `MOSCRCF` writer - Main On-Chip RC Oscillator Frequency Selection"]
100pub type MOSCRCF_W<'a, const O: u8> =
101 crate::FieldWriter<'a, u32, CKGR_MOR_SPEC, u8, MOSCRCF_A, 3, O>;
102impl<'a, const O: u8> MOSCRCF_W<'a, O> {
103 #[doc = "The Fast RC Oscillator Frequency is at 4 MHz (default)"]
104 #[inline(always)]
105 pub fn _4_mhz(self) -> &'a mut W {
106 self.variant(MOSCRCF_A::_4_MHZ)
107 }
108 #[doc = "The Fast RC Oscillator Frequency is at 8 MHz"]
109 #[inline(always)]
110 pub fn _8_mhz(self) -> &'a mut W {
111 self.variant(MOSCRCF_A::_8_MHZ)
112 }
113 #[doc = "The Fast RC Oscillator Frequency is at 12 MHz"]
114 #[inline(always)]
115 pub fn _12_mhz(self) -> &'a mut W {
116 self.variant(MOSCRCF_A::_12_MHZ)
117 }
118}
119#[doc = "Field `MOSCXTST` reader - Main Crystal Oscillator Start-up Time"]
120pub type MOSCXTST_R = crate::FieldReader<u8, u8>;
121#[doc = "Field `MOSCXTST` writer - Main Crystal Oscillator Start-up Time"]
122pub type MOSCXTST_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CKGR_MOR_SPEC, u8, u8, 8, O>;
123#[doc = "Field `KEY` reader - Write Access Password"]
124pub type KEY_R = crate::FieldReader<u8, KEY_A>;
125#[doc = "Write Access Password\n\nValue on reset: 0"]
126#[derive(Clone, Copy, Debug, PartialEq, Eq)]
127#[repr(u8)]
128pub enum KEY_A {
129 #[doc = "55: Writing any other value in this field aborts the write operation.Always reads as 0."]
130 PASSWD = 55,
131}
132impl From<KEY_A> for u8 {
133 #[inline(always)]
134 fn from(variant: KEY_A) -> Self {
135 variant as _
136 }
137}
138impl KEY_R {
139 #[doc = "Get enumerated values variant"]
140 #[inline(always)]
141 pub fn variant(&self) -> Option<KEY_A> {
142 match self.bits {
143 55 => Some(KEY_A::PASSWD),
144 _ => None,
145 }
146 }
147 #[doc = "Checks if the value of the field is `PASSWD`"]
148 #[inline(always)]
149 pub fn is_passwd(&self) -> bool {
150 *self == KEY_A::PASSWD
151 }
152}
153#[doc = "Field `KEY` writer - Write Access Password"]
154pub type KEY_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CKGR_MOR_SPEC, u8, KEY_A, 8, O>;
155impl<'a, const O: u8> KEY_W<'a, O> {
156 #[doc = "Writing any other value in this field aborts the write operation.Always reads as 0."]
157 #[inline(always)]
158 pub fn passwd(self) -> &'a mut W {
159 self.variant(KEY_A::PASSWD)
160 }
161}
162#[doc = "Field `MOSCSEL` reader - Main Oscillator Selection"]
163pub type MOSCSEL_R = crate::BitReader<bool>;
164#[doc = "Field `MOSCSEL` writer - Main Oscillator Selection"]
165pub type MOSCSEL_W<'a, const O: u8> = crate::BitWriter<'a, u32, CKGR_MOR_SPEC, bool, O>;
166#[doc = "Field `CFDEN` reader - Clock Failure Detector Enable"]
167pub type CFDEN_R = crate::BitReader<bool>;
168#[doc = "Field `CFDEN` writer - Clock Failure Detector Enable"]
169pub type CFDEN_W<'a, const O: u8> = crate::BitWriter<'a, u32, CKGR_MOR_SPEC, bool, O>;
170impl R {
171 #[doc = "Bit 0 - Main Crystal Oscillator Enable"]
172 #[inline(always)]
173 pub fn moscxten(&self) -> MOSCXTEN_R {
174 MOSCXTEN_R::new((self.bits & 1) != 0)
175 }
176 #[doc = "Bit 1 - Main Crystal Oscillator Bypass"]
177 #[inline(always)]
178 pub fn moscxtby(&self) -> MOSCXTBY_R {
179 MOSCXTBY_R::new(((self.bits >> 1) & 1) != 0)
180 }
181 #[doc = "Bit 2 - Wait Mode Command"]
182 #[inline(always)]
183 pub fn waitmode(&self) -> WAITMODE_R {
184 WAITMODE_R::new(((self.bits >> 2) & 1) != 0)
185 }
186 #[doc = "Bit 3 - Main On-Chip RC Oscillator Enable"]
187 #[inline(always)]
188 pub fn moscrcen(&self) -> MOSCRCEN_R {
189 MOSCRCEN_R::new(((self.bits >> 3) & 1) != 0)
190 }
191 #[doc = "Bits 4:6 - Main On-Chip RC Oscillator Frequency Selection"]
192 #[inline(always)]
193 pub fn moscrcf(&self) -> MOSCRCF_R {
194 MOSCRCF_R::new(((self.bits >> 4) & 7) as u8)
195 }
196 #[doc = "Bits 8:15 - Main Crystal Oscillator Start-up Time"]
197 #[inline(always)]
198 pub fn moscxtst(&self) -> MOSCXTST_R {
199 MOSCXTST_R::new(((self.bits >> 8) & 0xff) as u8)
200 }
201 #[doc = "Bits 16:23 - Write Access Password"]
202 #[inline(always)]
203 pub fn key(&self) -> KEY_R {
204 KEY_R::new(((self.bits >> 16) & 0xff) as u8)
205 }
206 #[doc = "Bit 24 - Main Oscillator Selection"]
207 #[inline(always)]
208 pub fn moscsel(&self) -> MOSCSEL_R {
209 MOSCSEL_R::new(((self.bits >> 24) & 1) != 0)
210 }
211 #[doc = "Bit 25 - Clock Failure Detector Enable"]
212 #[inline(always)]
213 pub fn cfden(&self) -> CFDEN_R {
214 CFDEN_R::new(((self.bits >> 25) & 1) != 0)
215 }
216}
217impl W {
218 #[doc = "Bit 0 - Main Crystal Oscillator Enable"]
219 #[inline(always)]
220 #[must_use]
221 pub fn moscxten(&mut self) -> MOSCXTEN_W<0> {
222 MOSCXTEN_W::new(self)
223 }
224 #[doc = "Bit 1 - Main Crystal Oscillator Bypass"]
225 #[inline(always)]
226 #[must_use]
227 pub fn moscxtby(&mut self) -> MOSCXTBY_W<1> {
228 MOSCXTBY_W::new(self)
229 }
230 #[doc = "Bit 2 - Wait Mode Command"]
231 #[inline(always)]
232 #[must_use]
233 pub fn waitmode(&mut self) -> WAITMODE_W<2> {
234 WAITMODE_W::new(self)
235 }
236 #[doc = "Bit 3 - Main On-Chip RC Oscillator Enable"]
237 #[inline(always)]
238 #[must_use]
239 pub fn moscrcen(&mut self) -> MOSCRCEN_W<3> {
240 MOSCRCEN_W::new(self)
241 }
242 #[doc = "Bits 4:6 - Main On-Chip RC Oscillator Frequency Selection"]
243 #[inline(always)]
244 #[must_use]
245 pub fn moscrcf(&mut self) -> MOSCRCF_W<4> {
246 MOSCRCF_W::new(self)
247 }
248 #[doc = "Bits 8:15 - Main Crystal Oscillator Start-up Time"]
249 #[inline(always)]
250 #[must_use]
251 pub fn moscxtst(&mut self) -> MOSCXTST_W<8> {
252 MOSCXTST_W::new(self)
253 }
254 #[doc = "Bits 16:23 - Write Access Password"]
255 #[inline(always)]
256 #[must_use]
257 pub fn key(&mut self) -> KEY_W<16> {
258 KEY_W::new(self)
259 }
260 #[doc = "Bit 24 - Main Oscillator Selection"]
261 #[inline(always)]
262 #[must_use]
263 pub fn moscsel(&mut self) -> MOSCSEL_W<24> {
264 MOSCSEL_W::new(self)
265 }
266 #[doc = "Bit 25 - Clock Failure Detector Enable"]
267 #[inline(always)]
268 #[must_use]
269 pub fn cfden(&mut self) -> CFDEN_W<25> {
270 CFDEN_W::new(self)
271 }
272 #[doc = "Writes raw bits to the register."]
273 #[inline(always)]
274 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
275 self.0.bits(bits);
276 self
277 }
278}
279#[doc = "Main Oscillator 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 [ckgr_mor](index.html) module"]
280pub struct CKGR_MOR_SPEC;
281impl crate::RegisterSpec for CKGR_MOR_SPEC {
282 type Ux = u32;
283}
284#[doc = "`read()` method returns [ckgr_mor::R](R) reader structure"]
285impl crate::Readable for CKGR_MOR_SPEC {
286 type Reader = R;
287}
288#[doc = "`write(|w| ..)` method takes [ckgr_mor::W](W) writer structure"]
289impl crate::Writable for CKGR_MOR_SPEC {
290 type Writer = W;
291 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
292 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
293}
294#[doc = "`reset()` method sets CKGR_MOR to value 0x08"]
295impl crate::Resettable for CKGR_MOR_SPEC {
296 const RESET_VALUE: Self::Ux = 0x08;
297}