1#[doc = "Register `SOSCCFG` reader"]
2pub type R = crate::R<SosccfgSpec>;
3#[doc = "Register `SOSCCFG` writer"]
4pub type W = crate::W<SosccfgSpec>;
5#[doc = "External Reference Select\n\nValue on reset: 0"]
6#[cfg_attr(feature = "defmt", derive(defmt::Format))]
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8pub enum Erefs {
9 #[doc = "0: External reference clock selected."]
10 External = 0,
11 #[doc = "1: Internal crystal oscillator of OSC selected."]
12 Internal = 1,
13}
14impl From<Erefs> for bool {
15 #[inline(always)]
16 fn from(variant: Erefs) -> Self {
17 variant as u8 != 0
18 }
19}
20#[doc = "Field `EREFS` reader - External Reference Select"]
21pub type ErefsR = crate::BitReader<Erefs>;
22impl ErefsR {
23 #[doc = "Get enumerated values variant"]
24 #[inline(always)]
25 pub const fn variant(&self) -> Erefs {
26 match self.bits {
27 false => Erefs::External,
28 true => Erefs::Internal,
29 }
30 }
31 #[doc = "External reference clock selected."]
32 #[inline(always)]
33 pub fn is_external(&self) -> bool {
34 *self == Erefs::External
35 }
36 #[doc = "Internal crystal oscillator of OSC selected."]
37 #[inline(always)]
38 pub fn is_internal(&self) -> bool {
39 *self == Erefs::Internal
40 }
41}
42#[doc = "Field `EREFS` writer - External Reference Select"]
43pub type ErefsW<'a, REG> = crate::BitWriter<'a, REG, Erefs>;
44impl<'a, REG> ErefsW<'a, REG>
45where
46 REG: crate::Writable + crate::RegisterSpec,
47{
48 #[doc = "External reference clock selected."]
49 #[inline(always)]
50 pub fn external(self) -> &'a mut crate::W<REG> {
51 self.variant(Erefs::External)
52 }
53 #[doc = "Internal crystal oscillator of OSC selected."]
54 #[inline(always)]
55 pub fn internal(self) -> &'a mut crate::W<REG> {
56 self.variant(Erefs::Internal)
57 }
58}
59#[doc = "SOSC Range Select\n\nValue on reset: 0"]
60#[cfg_attr(feature = "defmt", derive(defmt::Format))]
61#[derive(Clone, Copy, Debug, PartialEq, Eq)]
62#[repr(u8)]
63pub enum Range {
64 #[doc = "0: Frequency range select of 8-16 MHz."]
65 Freq16to20mhz = 0,
66 #[doc = "1: Frequency range select of 16-25 MHz."]
67 LowFreq = 1,
68 #[doc = "2: Frequency range select of 25-40 MHz."]
69 MediumFreq = 2,
70 #[doc = "3: Frequency range select of 40-50 MHz."]
71 HighFreq = 3,
72}
73impl From<Range> for u8 {
74 #[inline(always)]
75 fn from(variant: Range) -> Self {
76 variant as _
77 }
78}
79impl crate::FieldSpec for Range {
80 type Ux = u8;
81}
82impl crate::IsEnum for Range {}
83#[doc = "Field `RANGE` reader - SOSC Range Select"]
84pub type RangeR = crate::FieldReader<Range>;
85impl RangeR {
86 #[doc = "Get enumerated values variant"]
87 #[inline(always)]
88 pub const fn variant(&self) -> Range {
89 match self.bits {
90 0 => Range::Freq16to20mhz,
91 1 => Range::LowFreq,
92 2 => Range::MediumFreq,
93 3 => Range::HighFreq,
94 _ => unreachable!(),
95 }
96 }
97 #[doc = "Frequency range select of 8-16 MHz."]
98 #[inline(always)]
99 pub fn is_freq_16to20mhz(&self) -> bool {
100 *self == Range::Freq16to20mhz
101 }
102 #[doc = "Frequency range select of 16-25 MHz."]
103 #[inline(always)]
104 pub fn is_low_freq(&self) -> bool {
105 *self == Range::LowFreq
106 }
107 #[doc = "Frequency range select of 25-40 MHz."]
108 #[inline(always)]
109 pub fn is_medium_freq(&self) -> bool {
110 *self == Range::MediumFreq
111 }
112 #[doc = "Frequency range select of 40-50 MHz."]
113 #[inline(always)]
114 pub fn is_high_freq(&self) -> bool {
115 *self == Range::HighFreq
116 }
117}
118#[doc = "Field `RANGE` writer - SOSC Range Select"]
119pub type RangeW<'a, REG> = crate::FieldWriter<'a, REG, 2, Range, crate::Safe>;
120impl<'a, REG> RangeW<'a, REG>
121where
122 REG: crate::Writable + crate::RegisterSpec,
123 REG::Ux: From<u8>,
124{
125 #[doc = "Frequency range select of 8-16 MHz."]
126 #[inline(always)]
127 pub fn freq_16to20mhz(self) -> &'a mut crate::W<REG> {
128 self.variant(Range::Freq16to20mhz)
129 }
130 #[doc = "Frequency range select of 16-25 MHz."]
131 #[inline(always)]
132 pub fn low_freq(self) -> &'a mut crate::W<REG> {
133 self.variant(Range::LowFreq)
134 }
135 #[doc = "Frequency range select of 25-40 MHz."]
136 #[inline(always)]
137 pub fn medium_freq(self) -> &'a mut crate::W<REG> {
138 self.variant(Range::MediumFreq)
139 }
140 #[doc = "Frequency range select of 40-50 MHz."]
141 #[inline(always)]
142 pub fn high_freq(self) -> &'a mut crate::W<REG> {
143 self.variant(Range::HighFreq)
144 }
145}
146impl R {
147 #[doc = "Bit 2 - External Reference Select"]
148 #[inline(always)]
149 pub fn erefs(&self) -> ErefsR {
150 ErefsR::new(((self.bits >> 2) & 1) != 0)
151 }
152 #[doc = "Bits 4:5 - SOSC Range Select"]
153 #[inline(always)]
154 pub fn range(&self) -> RangeR {
155 RangeR::new(((self.bits >> 4) & 3) as u8)
156 }
157}
158#[cfg(feature = "debug")]
159impl core::fmt::Debug for R {
160 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
161 f.debug_struct("SOSCCFG")
162 .field("erefs", &self.erefs())
163 .field("range", &self.range())
164 .finish()
165 }
166}
167impl W {
168 #[doc = "Bit 2 - External Reference Select"]
169 #[inline(always)]
170 pub fn erefs(&mut self) -> ErefsW<'_, SosccfgSpec> {
171 ErefsW::new(self, 2)
172 }
173 #[doc = "Bits 4:5 - SOSC Range Select"]
174 #[inline(always)]
175 pub fn range(&mut self) -> RangeW<'_, SosccfgSpec> {
176 RangeW::new(self, 4)
177 }
178}
179#[doc = "SOSC Configuration Register\n\nYou can [`read`](crate::Reg::read) this register and get [`sosccfg::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`sosccfg::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
180pub struct SosccfgSpec;
181impl crate::RegisterSpec for SosccfgSpec {
182 type Ux = u32;
183}
184#[doc = "`read()` method returns [`sosccfg::R`](R) reader structure"]
185impl crate::Readable for SosccfgSpec {}
186#[doc = "`write(|w| ..)` method takes [`sosccfg::W`](W) writer structure"]
187impl crate::Writable for SosccfgSpec {
188 type Safety = crate::Unsafe;
189}
190#[doc = "`reset()` method sets SOSCCFG to value 0"]
191impl crate::Resettable for SosccfgSpec {}