atsamd11c/sysctrl/
xosc.rs
1#[doc = "Register `XOSC` reader"]
2pub type R = crate::R<XoscSpec>;
3#[doc = "Register `XOSC` writer"]
4pub type W = crate::W<XoscSpec>;
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 `XTALEN` reader - Crystal Oscillator Enable"]
10pub type XtalenR = crate::BitReader;
11#[doc = "Field `XTALEN` writer - Crystal Oscillator Enable"]
12pub type XtalenW<'a, REG> = crate::BitWriter<'a, REG>;
13#[doc = "Field `RUNSTDBY` reader - Run in Standby"]
14pub type RunstdbyR = crate::BitReader;
15#[doc = "Field `RUNSTDBY` writer - Run in Standby"]
16pub type RunstdbyW<'a, REG> = crate::BitWriter<'a, REG>;
17#[doc = "Field `ONDEMAND` reader - On Demand Control"]
18pub type OndemandR = crate::BitReader;
19#[doc = "Field `ONDEMAND` writer - On Demand Control"]
20pub type OndemandW<'a, REG> = crate::BitWriter<'a, REG>;
21#[doc = "Oscillator Gain\n\nValue on reset: 0"]
22#[derive(Clone, Copy, Debug, PartialEq, Eq)]
23#[repr(u8)]
24pub enum Gainselect {
25 #[doc = "0: 2MHz"]
26 _0 = 0,
27 #[doc = "1: 4MHz"]
28 _1 = 1,
29 #[doc = "2: 8MHz"]
30 _2 = 2,
31 #[doc = "3: 16MHz"]
32 _3 = 3,
33 #[doc = "4: 30MHz"]
34 _4 = 4,
35}
36impl From<Gainselect> for u8 {
37 #[inline(always)]
38 fn from(variant: Gainselect) -> Self {
39 variant as _
40 }
41}
42impl crate::FieldSpec for Gainselect {
43 type Ux = u8;
44}
45impl crate::IsEnum for Gainselect {}
46#[doc = "Field `GAIN` reader - Oscillator Gain"]
47pub type GainR = crate::FieldReader<Gainselect>;
48impl GainR {
49 #[doc = "Get enumerated values variant"]
50 #[inline(always)]
51 pub const fn variant(&self) -> Option<Gainselect> {
52 match self.bits {
53 0 => Some(Gainselect::_0),
54 1 => Some(Gainselect::_1),
55 2 => Some(Gainselect::_2),
56 3 => Some(Gainselect::_3),
57 4 => Some(Gainselect::_4),
58 _ => None,
59 }
60 }
61 #[doc = "2MHz"]
62 #[inline(always)]
63 pub fn is_0(&self) -> bool {
64 *self == Gainselect::_0
65 }
66 #[doc = "4MHz"]
67 #[inline(always)]
68 pub fn is_1(&self) -> bool {
69 *self == Gainselect::_1
70 }
71 #[doc = "8MHz"]
72 #[inline(always)]
73 pub fn is_2(&self) -> bool {
74 *self == Gainselect::_2
75 }
76 #[doc = "16MHz"]
77 #[inline(always)]
78 pub fn is_3(&self) -> bool {
79 *self == Gainselect::_3
80 }
81 #[doc = "30MHz"]
82 #[inline(always)]
83 pub fn is_4(&self) -> bool {
84 *self == Gainselect::_4
85 }
86}
87#[doc = "Field `GAIN` writer - Oscillator Gain"]
88pub type GainW<'a, REG> = crate::FieldWriter<'a, REG, 3, Gainselect>;
89impl<'a, REG> GainW<'a, REG>
90where
91 REG: crate::Writable + crate::RegisterSpec,
92 REG::Ux: From<u8>,
93{
94 #[doc = "2MHz"]
95 #[inline(always)]
96 pub fn _0(self) -> &'a mut crate::W<REG> {
97 self.variant(Gainselect::_0)
98 }
99 #[doc = "4MHz"]
100 #[inline(always)]
101 pub fn _1(self) -> &'a mut crate::W<REG> {
102 self.variant(Gainselect::_1)
103 }
104 #[doc = "8MHz"]
105 #[inline(always)]
106 pub fn _2(self) -> &'a mut crate::W<REG> {
107 self.variant(Gainselect::_2)
108 }
109 #[doc = "16MHz"]
110 #[inline(always)]
111 pub fn _3(self) -> &'a mut crate::W<REG> {
112 self.variant(Gainselect::_3)
113 }
114 #[doc = "30MHz"]
115 #[inline(always)]
116 pub fn _4(self) -> &'a mut crate::W<REG> {
117 self.variant(Gainselect::_4)
118 }
119}
120#[doc = "Field `AMPGC` reader - Automatic Amplitude Gain Control"]
121pub type AmpgcR = crate::BitReader;
122#[doc = "Field `AMPGC` writer - Automatic Amplitude Gain Control"]
123pub type AmpgcW<'a, REG> = crate::BitWriter<'a, REG>;
124#[doc = "Field `STARTUP` reader - Start-Up Time"]
125pub type StartupR = crate::FieldReader;
126#[doc = "Field `STARTUP` writer - Start-Up Time"]
127pub type StartupW<'a, REG> = crate::FieldWriter<'a, REG, 4>;
128impl R {
129 #[doc = "Bit 1 - Oscillator Enable"]
130 #[inline(always)]
131 pub fn enable(&self) -> EnableR {
132 EnableR::new(((self.bits >> 1) & 1) != 0)
133 }
134 #[doc = "Bit 2 - Crystal Oscillator Enable"]
135 #[inline(always)]
136 pub fn xtalen(&self) -> XtalenR {
137 XtalenR::new(((self.bits >> 2) & 1) != 0)
138 }
139 #[doc = "Bit 6 - Run in Standby"]
140 #[inline(always)]
141 pub fn runstdby(&self) -> RunstdbyR {
142 RunstdbyR::new(((self.bits >> 6) & 1) != 0)
143 }
144 #[doc = "Bit 7 - On Demand Control"]
145 #[inline(always)]
146 pub fn ondemand(&self) -> OndemandR {
147 OndemandR::new(((self.bits >> 7) & 1) != 0)
148 }
149 #[doc = "Bits 8:10 - Oscillator Gain"]
150 #[inline(always)]
151 pub fn gain(&self) -> GainR {
152 GainR::new(((self.bits >> 8) & 7) as u8)
153 }
154 #[doc = "Bit 11 - Automatic Amplitude Gain Control"]
155 #[inline(always)]
156 pub fn ampgc(&self) -> AmpgcR {
157 AmpgcR::new(((self.bits >> 11) & 1) != 0)
158 }
159 #[doc = "Bits 12:15 - Start-Up Time"]
160 #[inline(always)]
161 pub fn startup(&self) -> StartupR {
162 StartupR::new(((self.bits >> 12) & 0x0f) as u8)
163 }
164}
165impl W {
166 #[doc = "Bit 1 - Oscillator Enable"]
167 #[inline(always)]
168 #[must_use]
169 pub fn enable(&mut self) -> EnableW<XoscSpec> {
170 EnableW::new(self, 1)
171 }
172 #[doc = "Bit 2 - Crystal Oscillator Enable"]
173 #[inline(always)]
174 #[must_use]
175 pub fn xtalen(&mut self) -> XtalenW<XoscSpec> {
176 XtalenW::new(self, 2)
177 }
178 #[doc = "Bit 6 - Run in Standby"]
179 #[inline(always)]
180 #[must_use]
181 pub fn runstdby(&mut self) -> RunstdbyW<XoscSpec> {
182 RunstdbyW::new(self, 6)
183 }
184 #[doc = "Bit 7 - On Demand Control"]
185 #[inline(always)]
186 #[must_use]
187 pub fn ondemand(&mut self) -> OndemandW<XoscSpec> {
188 OndemandW::new(self, 7)
189 }
190 #[doc = "Bits 8:10 - Oscillator Gain"]
191 #[inline(always)]
192 #[must_use]
193 pub fn gain(&mut self) -> GainW<XoscSpec> {
194 GainW::new(self, 8)
195 }
196 #[doc = "Bit 11 - Automatic Amplitude Gain Control"]
197 #[inline(always)]
198 #[must_use]
199 pub fn ampgc(&mut self) -> AmpgcW<XoscSpec> {
200 AmpgcW::new(self, 11)
201 }
202 #[doc = "Bits 12:15 - Start-Up Time"]
203 #[inline(always)]
204 #[must_use]
205 pub fn startup(&mut self) -> StartupW<XoscSpec> {
206 StartupW::new(self, 12)
207 }
208}
209#[doc = "External Multipurpose Crystal Oscillator (XOSC) Control\n\nYou can [`read`](crate::Reg::read) this register and get [`xosc::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`xosc::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
210pub struct XoscSpec;
211impl crate::RegisterSpec for XoscSpec {
212 type Ux = u16;
213}
214#[doc = "`read()` method returns [`xosc::R`](R) reader structure"]
215impl crate::Readable for XoscSpec {}
216#[doc = "`write(|w| ..)` method takes [`xosc::W`](W) writer structure"]
217impl crate::Writable for XoscSpec {
218 type Safety = crate::Unsafe;
219 const ZERO_TO_MODIFY_FIELDS_BITMAP: u16 = 0;
220 const ONE_TO_MODIFY_FIELDS_BITMAP: u16 = 0;
221}
222#[doc = "`reset()` method sets XOSC to value 0x80"]
223impl crate::Resettable for XoscSpec {
224 const RESET_VALUE: u16 = 0x80;
225}