1#[doc = "Register `CTRL` reader"]
2pub type R = crate::R<CTRL_SPEC>;
3#[doc = "Register `CTRL` writer"]
4pub type W = crate::W<CTRL_SPEC>;
5#[doc = "Field `FREQ_RANGE` reader - Frequency range. This resets to 0xAA0 and cannot be changed."]
6pub type FREQ_RANGE_R = crate::FieldReader<FREQ_RANGE_A>;
7#[doc = "Frequency range. This resets to 0xAA0 and cannot be changed.
89Value on reset: 0"]
10#[derive(Clone, Copy, Debug, PartialEq, Eq)]
11#[repr(u16)]
12pub enum FREQ_RANGE_A {
13#[doc = "2720: `101010100000`"]
14_1_15MHZ = 2720,
15#[doc = "2721: `101010100001`"]
16RESERVED_1 = 2721,
17#[doc = "2722: `101010100010`"]
18RESERVED_2 = 2722,
19#[doc = "2723: `101010100011`"]
20RESERVED_3 = 2723,
21}
22impl From<FREQ_RANGE_A> for u16 {
23#[inline(always)]
24fn from(variant: FREQ_RANGE_A) -> Self {
25 variant as _
26}
27}
28impl crate::FieldSpec for FREQ_RANGE_A {
29type Ux = u16;
30}
31impl FREQ_RANGE_R {
32#[doc = "Get enumerated values variant"]
33 #[inline(always)]
34pub const fn variant(&self) -> Option<FREQ_RANGE_A> {
35match self.bits {
362720 => Some(FREQ_RANGE_A::_1_15MHZ),
372721 => Some(FREQ_RANGE_A::RESERVED_1),
382722 => Some(FREQ_RANGE_A::RESERVED_2),
392723 => Some(FREQ_RANGE_A::RESERVED_3),
40_ => None,
41 }
42 }
43#[doc = "`101010100000`"]
44 #[inline(always)]
45pub fn is_1_15mhz(&self) -> bool {
46*self == FREQ_RANGE_A::_1_15MHZ
47 }
48#[doc = "`101010100001`"]
49 #[inline(always)]
50pub fn is_reserved_1(&self) -> bool {
51*self == FREQ_RANGE_A::RESERVED_1
52 }
53#[doc = "`101010100010`"]
54 #[inline(always)]
55pub fn is_reserved_2(&self) -> bool {
56*self == FREQ_RANGE_A::RESERVED_2
57 }
58#[doc = "`101010100011`"]
59 #[inline(always)]
60pub fn is_reserved_3(&self) -> bool {
61*self == FREQ_RANGE_A::RESERVED_3
62 }
63}
64#[doc = "Field `FREQ_RANGE` writer - Frequency range. This resets to 0xAA0 and cannot be changed."]
65pub type FREQ_RANGE_W<'a, REG> = crate::FieldWriter<'a, REG, 12, FREQ_RANGE_A>;
66impl<'a, REG> FREQ_RANGE_W<'a, REG>
67where
68REG: crate::Writable + crate::RegisterSpec,
69 REG::Ux: From<u16>,
70{
71#[doc = "`101010100000`"]
72 #[inline(always)]
73pub fn _1_15mhz(self) -> &'a mut crate::W<REG> {
74self.variant(FREQ_RANGE_A::_1_15MHZ)
75 }
76#[doc = "`101010100001`"]
77 #[inline(always)]
78pub fn reserved_1(self) -> &'a mut crate::W<REG> {
79self.variant(FREQ_RANGE_A::RESERVED_1)
80 }
81#[doc = "`101010100010`"]
82 #[inline(always)]
83pub fn reserved_2(self) -> &'a mut crate::W<REG> {
84self.variant(FREQ_RANGE_A::RESERVED_2)
85 }
86#[doc = "`101010100011`"]
87 #[inline(always)]
88pub fn reserved_3(self) -> &'a mut crate::W<REG> {
89self.variant(FREQ_RANGE_A::RESERVED_3)
90 }
91}
92#[doc = "Field `ENABLE` reader - On power-up this field is initialised to DISABLE and the chip runs from the ROSC.
93 If the chip has subsequently been programmed to run from the XOSC then setting this field to DISABLE may lock-up the chip. If this is a concern then run the clk_ref from the ROSC and enable the clk_sys RESUS feature.
94 The 12-bit code is intended to give some protection against accidental writes. An invalid setting will enable the oscillator."]
95pub type ENABLE_R = crate::FieldReader<ENABLE_A>;
96#[doc = "On power-up this field is initialised to DISABLE and the chip runs from the ROSC.
97 If the chip has subsequently been programmed to run from the XOSC then setting this field to DISABLE may lock-up the chip. If this is a concern then run the clk_ref from the ROSC and enable the clk_sys RESUS feature.
98 The 12-bit code is intended to give some protection against accidental writes. An invalid setting will enable the oscillator.
99100Value on reset: 0"]
101#[derive(Clone, Copy, Debug, PartialEq, Eq)]
102#[repr(u16)]
103pub enum ENABLE_A {
104#[doc = "3358: `110100011110`"]
105DISABLE = 3358,
106#[doc = "4011: `111110101011`"]
107ENABLE = 4011,
108}
109impl From<ENABLE_A> for u16 {
110#[inline(always)]
111fn from(variant: ENABLE_A) -> Self {
112 variant as _
113}
114}
115impl crate::FieldSpec for ENABLE_A {
116type Ux = u16;
117}
118impl ENABLE_R {
119#[doc = "Get enumerated values variant"]
120 #[inline(always)]
121pub const fn variant(&self) -> Option<ENABLE_A> {
122match self.bits {
1233358 => Some(ENABLE_A::DISABLE),
1244011 => Some(ENABLE_A::ENABLE),
125_ => None,
126 }
127 }
128#[doc = "`110100011110`"]
129 #[inline(always)]
130pub fn is_disable(&self) -> bool {
131*self == ENABLE_A::DISABLE
132 }
133#[doc = "`111110101011`"]
134 #[inline(always)]
135pub fn is_enable(&self) -> bool {
136*self == ENABLE_A::ENABLE
137 }
138}
139#[doc = "Field `ENABLE` writer - On power-up this field is initialised to DISABLE and the chip runs from the ROSC.
140 If the chip has subsequently been programmed to run from the XOSC then setting this field to DISABLE may lock-up the chip. If this is a concern then run the clk_ref from the ROSC and enable the clk_sys RESUS feature.
141 The 12-bit code is intended to give some protection against accidental writes. An invalid setting will enable the oscillator."]
142pub type ENABLE_W<'a, REG> = crate::FieldWriter<'a, REG, 12, ENABLE_A>;
143impl<'a, REG> ENABLE_W<'a, REG>
144where
145REG: crate::Writable + crate::RegisterSpec,
146 REG::Ux: From<u16>,
147{
148#[doc = "`110100011110`"]
149 #[inline(always)]
150pub fn disable(self) -> &'a mut crate::W<REG> {
151self.variant(ENABLE_A::DISABLE)
152 }
153#[doc = "`111110101011`"]
154 #[inline(always)]
155pub fn enable(self) -> &'a mut crate::W<REG> {
156self.variant(ENABLE_A::ENABLE)
157 }
158}
159impl R {
160#[doc = "Bits 0:11 - Frequency range. This resets to 0xAA0 and cannot be changed."]
161 #[inline(always)]
162pub fn freq_range(&self) -> FREQ_RANGE_R {
163 FREQ_RANGE_R::new((self.bits & 0x0fff) as u16)
164 }
165#[doc = "Bits 12:23 - On power-up this field is initialised to DISABLE and the chip runs from the ROSC.
166 If the chip has subsequently been programmed to run from the XOSC then setting this field to DISABLE may lock-up the chip. If this is a concern then run the clk_ref from the ROSC and enable the clk_sys RESUS feature.
167 The 12-bit code is intended to give some protection against accidental writes. An invalid setting will enable the oscillator."]
168 #[inline(always)]
169pub fn enable(&self) -> ENABLE_R {
170 ENABLE_R::new(((self.bits >> 12) & 0x0fff) as u16)
171 }
172}
173impl W {
174#[doc = "Bits 0:11 - Frequency range. This resets to 0xAA0 and cannot be changed."]
175 #[inline(always)]
176 #[must_use]
177pub fn freq_range(&mut self) -> FREQ_RANGE_W<CTRL_SPEC> {
178 FREQ_RANGE_W::new(self, 0)
179 }
180#[doc = "Bits 12:23 - On power-up this field is initialised to DISABLE and the chip runs from the ROSC.
181 If the chip has subsequently been programmed to run from the XOSC then setting this field to DISABLE may lock-up the chip. If this is a concern then run the clk_ref from the ROSC and enable the clk_sys RESUS feature.
182 The 12-bit code is intended to give some protection against accidental writes. An invalid setting will enable the oscillator."]
183 #[inline(always)]
184 #[must_use]
185pub fn enable(&mut self) -> ENABLE_W<CTRL_SPEC> {
186 ENABLE_W::new(self, 12)
187 }
188#[doc = r" Writes raw bits to the register."]
189 #[doc = r""]
190 #[doc = r" # Safety"]
191 #[doc = r""]
192 #[doc = r" Passing incorrect value can cause undefined behaviour. See reference manual"]
193 #[inline(always)]
194pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
195self.bits = bits;
196self
197}
198}
199#[doc = "Crystal Oscillator Control
200201You can [`read`](crate::generic::Reg::read) this register and get [`ctrl::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 [`ctrl::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
202pub struct CTRL_SPEC;
203impl crate::RegisterSpec for CTRL_SPEC {
204type Ux = u32;
205}
206#[doc = "`read()` method returns [`ctrl::R`](R) reader structure"]
207impl crate::Readable for CTRL_SPEC {}
208#[doc = "`write(|w| ..)` method takes [`ctrl::W`](W) writer structure"]
209impl crate::Writable for CTRL_SPEC {
210const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
211const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
212}
213#[doc = "`reset()` method sets CTRL to value 0"]
214impl crate::Resettable for CTRL_SPEC {
215const RESET_VALUE: u32 = 0;
216}