atsam4s2c_pac/supc/
mr.rs

1#[doc = "Register `MR` reader"]
2pub struct R(crate::R<MR_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<MR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<MR_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<MR_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `MR` writer"]
17pub struct W(crate::W<MR_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<MR_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<MR_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<MR_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `BODRSTEN` reader - Brownout Detector Reset Enable"]
38pub type BODRSTEN_R = crate::BitReader<BODRSTEN_A>;
39#[doc = "Brownout Detector Reset Enable\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41pub enum BODRSTEN_A {
42    #[doc = "0: The core reset signal \"vddcore_nreset\" is not affected when a brownout detection occurs."]
43    NOT_ENABLE = 0,
44    #[doc = "1: The core reset signal, vddcore_nreset is asserted when a brownout detection occurs."]
45    ENABLE = 1,
46}
47impl From<BODRSTEN_A> for bool {
48    #[inline(always)]
49    fn from(variant: BODRSTEN_A) -> Self {
50        variant as u8 != 0
51    }
52}
53impl BODRSTEN_R {
54    #[doc = "Get enumerated values variant"]
55    #[inline(always)]
56    pub fn variant(&self) -> BODRSTEN_A {
57        match self.bits {
58            false => BODRSTEN_A::NOT_ENABLE,
59            true => BODRSTEN_A::ENABLE,
60        }
61    }
62    #[doc = "Checks if the value of the field is `NOT_ENABLE`"]
63    #[inline(always)]
64    pub fn is_not_enable(&self) -> bool {
65        *self == BODRSTEN_A::NOT_ENABLE
66    }
67    #[doc = "Checks if the value of the field is `ENABLE`"]
68    #[inline(always)]
69    pub fn is_enable(&self) -> bool {
70        *self == BODRSTEN_A::ENABLE
71    }
72}
73#[doc = "Field `BODRSTEN` writer - Brownout Detector Reset Enable"]
74pub type BODRSTEN_W<'a, const O: u8> = crate::BitWriter<'a, u32, MR_SPEC, BODRSTEN_A, O>;
75impl<'a, const O: u8> BODRSTEN_W<'a, O> {
76    #[doc = "The core reset signal \"vddcore_nreset\" is not affected when a brownout detection occurs."]
77    #[inline(always)]
78    pub fn not_enable(self) -> &'a mut W {
79        self.variant(BODRSTEN_A::NOT_ENABLE)
80    }
81    #[doc = "The core reset signal, vddcore_nreset is asserted when a brownout detection occurs."]
82    #[inline(always)]
83    pub fn enable(self) -> &'a mut W {
84        self.variant(BODRSTEN_A::ENABLE)
85    }
86}
87#[doc = "Field `BODDIS` reader - Brownout Detector Disable"]
88pub type BODDIS_R = crate::BitReader<BODDIS_A>;
89#[doc = "Brownout Detector Disable\n\nValue on reset: 0"]
90#[derive(Clone, Copy, Debug, PartialEq, Eq)]
91pub enum BODDIS_A {
92    #[doc = "0: The core brownout detector is enabled."]
93    ENABLE = 0,
94    #[doc = "1: The core brownout detector is disabled."]
95    DISABLE = 1,
96}
97impl From<BODDIS_A> for bool {
98    #[inline(always)]
99    fn from(variant: BODDIS_A) -> Self {
100        variant as u8 != 0
101    }
102}
103impl BODDIS_R {
104    #[doc = "Get enumerated values variant"]
105    #[inline(always)]
106    pub fn variant(&self) -> BODDIS_A {
107        match self.bits {
108            false => BODDIS_A::ENABLE,
109            true => BODDIS_A::DISABLE,
110        }
111    }
112    #[doc = "Checks if the value of the field is `ENABLE`"]
113    #[inline(always)]
114    pub fn is_enable(&self) -> bool {
115        *self == BODDIS_A::ENABLE
116    }
117    #[doc = "Checks if the value of the field is `DISABLE`"]
118    #[inline(always)]
119    pub fn is_disable(&self) -> bool {
120        *self == BODDIS_A::DISABLE
121    }
122}
123#[doc = "Field `BODDIS` writer - Brownout Detector Disable"]
124pub type BODDIS_W<'a, const O: u8> = crate::BitWriter<'a, u32, MR_SPEC, BODDIS_A, O>;
125impl<'a, const O: u8> BODDIS_W<'a, O> {
126    #[doc = "The core brownout detector is enabled."]
127    #[inline(always)]
128    pub fn enable(self) -> &'a mut W {
129        self.variant(BODDIS_A::ENABLE)
130    }
131    #[doc = "The core brownout detector is disabled."]
132    #[inline(always)]
133    pub fn disable(self) -> &'a mut W {
134        self.variant(BODDIS_A::DISABLE)
135    }
136}
137#[doc = "Field `ONREG` reader - Voltage Regulator Enable"]
138pub type ONREG_R = crate::BitReader<ONREG_A>;
139#[doc = "Voltage Regulator Enable\n\nValue on reset: 0"]
140#[derive(Clone, Copy, Debug, PartialEq, Eq)]
141pub enum ONREG_A {
142    #[doc = "0: Internal voltage regulator is not used (external power supply is used)."]
143    ONREG_UNUSED = 0,
144    #[doc = "1: Internal voltage regulator is used."]
145    ONREG_USED = 1,
146}
147impl From<ONREG_A> for bool {
148    #[inline(always)]
149    fn from(variant: ONREG_A) -> Self {
150        variant as u8 != 0
151    }
152}
153impl ONREG_R {
154    #[doc = "Get enumerated values variant"]
155    #[inline(always)]
156    pub fn variant(&self) -> ONREG_A {
157        match self.bits {
158            false => ONREG_A::ONREG_UNUSED,
159            true => ONREG_A::ONREG_USED,
160        }
161    }
162    #[doc = "Checks if the value of the field is `ONREG_UNUSED`"]
163    #[inline(always)]
164    pub fn is_onreg_unused(&self) -> bool {
165        *self == ONREG_A::ONREG_UNUSED
166    }
167    #[doc = "Checks if the value of the field is `ONREG_USED`"]
168    #[inline(always)]
169    pub fn is_onreg_used(&self) -> bool {
170        *self == ONREG_A::ONREG_USED
171    }
172}
173#[doc = "Field `ONREG` writer - Voltage Regulator Enable"]
174pub type ONREG_W<'a, const O: u8> = crate::BitWriter<'a, u32, MR_SPEC, ONREG_A, O>;
175impl<'a, const O: u8> ONREG_W<'a, O> {
176    #[doc = "Internal voltage regulator is not used (external power supply is used)."]
177    #[inline(always)]
178    pub fn onreg_unused(self) -> &'a mut W {
179        self.variant(ONREG_A::ONREG_UNUSED)
180    }
181    #[doc = "Internal voltage regulator is used."]
182    #[inline(always)]
183    pub fn onreg_used(self) -> &'a mut W {
184        self.variant(ONREG_A::ONREG_USED)
185    }
186}
187#[doc = "Field `OSCBYPASS` reader - Oscillator Bypass"]
188pub type OSCBYPASS_R = crate::BitReader<OSCBYPASS_A>;
189#[doc = "Oscillator Bypass\n\nValue on reset: 0"]
190#[derive(Clone, Copy, Debug, PartialEq, Eq)]
191pub enum OSCBYPASS_A {
192    #[doc = "0: No effect. Clock selection depends on XTALSEL value."]
193    NO_EFFECT = 0,
194    #[doc = "1: The 32 kHz crystal oscillator is selected and put in bypass mode."]
195    BYPASS = 1,
196}
197impl From<OSCBYPASS_A> for bool {
198    #[inline(always)]
199    fn from(variant: OSCBYPASS_A) -> Self {
200        variant as u8 != 0
201    }
202}
203impl OSCBYPASS_R {
204    #[doc = "Get enumerated values variant"]
205    #[inline(always)]
206    pub fn variant(&self) -> OSCBYPASS_A {
207        match self.bits {
208            false => OSCBYPASS_A::NO_EFFECT,
209            true => OSCBYPASS_A::BYPASS,
210        }
211    }
212    #[doc = "Checks if the value of the field is `NO_EFFECT`"]
213    #[inline(always)]
214    pub fn is_no_effect(&self) -> bool {
215        *self == OSCBYPASS_A::NO_EFFECT
216    }
217    #[doc = "Checks if the value of the field is `BYPASS`"]
218    #[inline(always)]
219    pub fn is_bypass(&self) -> bool {
220        *self == OSCBYPASS_A::BYPASS
221    }
222}
223#[doc = "Field `OSCBYPASS` writer - Oscillator Bypass"]
224pub type OSCBYPASS_W<'a, const O: u8> = crate::BitWriter<'a, u32, MR_SPEC, OSCBYPASS_A, O>;
225impl<'a, const O: u8> OSCBYPASS_W<'a, O> {
226    #[doc = "No effect. Clock selection depends on XTALSEL value."]
227    #[inline(always)]
228    pub fn no_effect(self) -> &'a mut W {
229        self.variant(OSCBYPASS_A::NO_EFFECT)
230    }
231    #[doc = "The 32 kHz crystal oscillator is selected and put in bypass mode."]
232    #[inline(always)]
233    pub fn bypass(self) -> &'a mut W {
234        self.variant(OSCBYPASS_A::BYPASS)
235    }
236}
237#[doc = "Field `KEY` reader - Password Key"]
238pub type KEY_R = crate::FieldReader<u8, KEY_A>;
239#[doc = "Password Key\n\nValue on reset: 0"]
240#[derive(Clone, Copy, Debug, PartialEq, Eq)]
241#[repr(u8)]
242pub enum KEY_A {
243    #[doc = "165: Writing any other value in this field aborts the write operation."]
244    PASSWD = 165,
245}
246impl From<KEY_A> for u8 {
247    #[inline(always)]
248    fn from(variant: KEY_A) -> Self {
249        variant as _
250    }
251}
252impl KEY_R {
253    #[doc = "Get enumerated values variant"]
254    #[inline(always)]
255    pub fn variant(&self) -> Option<KEY_A> {
256        match self.bits {
257            165 => Some(KEY_A::PASSWD),
258            _ => None,
259        }
260    }
261    #[doc = "Checks if the value of the field is `PASSWD`"]
262    #[inline(always)]
263    pub fn is_passwd(&self) -> bool {
264        *self == KEY_A::PASSWD
265    }
266}
267#[doc = "Field `KEY` writer - Password Key"]
268pub type KEY_W<'a, const O: u8> = crate::FieldWriter<'a, u32, MR_SPEC, u8, KEY_A, 8, O>;
269impl<'a, const O: u8> KEY_W<'a, O> {
270    #[doc = "Writing any other value in this field aborts the write operation."]
271    #[inline(always)]
272    pub fn passwd(self) -> &'a mut W {
273        self.variant(KEY_A::PASSWD)
274    }
275}
276impl R {
277    #[doc = "Bit 12 - Brownout Detector Reset Enable"]
278    #[inline(always)]
279    pub fn bodrsten(&self) -> BODRSTEN_R {
280        BODRSTEN_R::new(((self.bits >> 12) & 1) != 0)
281    }
282    #[doc = "Bit 13 - Brownout Detector Disable"]
283    #[inline(always)]
284    pub fn boddis(&self) -> BODDIS_R {
285        BODDIS_R::new(((self.bits >> 13) & 1) != 0)
286    }
287    #[doc = "Bit 14 - Voltage Regulator Enable"]
288    #[inline(always)]
289    pub fn onreg(&self) -> ONREG_R {
290        ONREG_R::new(((self.bits >> 14) & 1) != 0)
291    }
292    #[doc = "Bit 20 - Oscillator Bypass"]
293    #[inline(always)]
294    pub fn oscbypass(&self) -> OSCBYPASS_R {
295        OSCBYPASS_R::new(((self.bits >> 20) & 1) != 0)
296    }
297    #[doc = "Bits 24:31 - Password Key"]
298    #[inline(always)]
299    pub fn key(&self) -> KEY_R {
300        KEY_R::new(((self.bits >> 24) & 0xff) as u8)
301    }
302}
303impl W {
304    #[doc = "Bit 12 - Brownout Detector Reset Enable"]
305    #[inline(always)]
306    #[must_use]
307    pub fn bodrsten(&mut self) -> BODRSTEN_W<12> {
308        BODRSTEN_W::new(self)
309    }
310    #[doc = "Bit 13 - Brownout Detector Disable"]
311    #[inline(always)]
312    #[must_use]
313    pub fn boddis(&mut self) -> BODDIS_W<13> {
314        BODDIS_W::new(self)
315    }
316    #[doc = "Bit 14 - Voltage Regulator Enable"]
317    #[inline(always)]
318    #[must_use]
319    pub fn onreg(&mut self) -> ONREG_W<14> {
320        ONREG_W::new(self)
321    }
322    #[doc = "Bit 20 - Oscillator Bypass"]
323    #[inline(always)]
324    #[must_use]
325    pub fn oscbypass(&mut self) -> OSCBYPASS_W<20> {
326        OSCBYPASS_W::new(self)
327    }
328    #[doc = "Bits 24:31 - Password Key"]
329    #[inline(always)]
330    #[must_use]
331    pub fn key(&mut self) -> KEY_W<24> {
332        KEY_W::new(self)
333    }
334    #[doc = "Writes raw bits to the register."]
335    #[inline(always)]
336    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
337        self.0.bits(bits);
338        self
339    }
340}
341#[doc = "Supply Controller Mode 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 [mr](index.html) module"]
342pub struct MR_SPEC;
343impl crate::RegisterSpec for MR_SPEC {
344    type Ux = u32;
345}
346#[doc = "`read()` method returns [mr::R](R) reader structure"]
347impl crate::Readable for MR_SPEC {
348    type Reader = R;
349}
350#[doc = "`write(|w| ..)` method takes [mr::W](W) writer structure"]
351impl crate::Writable for MR_SPEC {
352    type Writer = W;
353    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
354    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
355}
356#[doc = "`reset()` method sets MR to value 0x0a00"]
357impl crate::Resettable for MR_SPEC {
358    const RESET_VALUE: Self::Ux = 0x0a00;
359}