xmc4100/scu_osc/
oschpctrl.rs

1#[doc = "Register `OSCHPCTRL` reader"]
2pub type R = crate::R<OSCHPCTRL_SPEC>;
3#[doc = "Register `OSCHPCTRL` writer"]
4pub type W = crate::W<OSCHPCTRL_SPEC>;
5#[doc = "XTAL1 Data Enable\n\nValue on reset: 1"]
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7pub enum X1DEN_A {
8    #[doc = "0: Bit X1D is not updated"]
9    VALUE1 = 0,
10    #[doc = "1: Bit X1D can be updated"]
11    VALUE2 = 1,
12}
13impl From<X1DEN_A> for bool {
14    #[inline(always)]
15    fn from(variant: X1DEN_A) -> Self {
16        variant as u8 != 0
17    }
18}
19#[doc = "Field `X1DEN` reader - XTAL1 Data Enable"]
20pub type X1DEN_R = crate::BitReader<X1DEN_A>;
21impl X1DEN_R {
22    #[doc = "Get enumerated values variant"]
23    #[inline(always)]
24    pub const fn variant(&self) -> X1DEN_A {
25        match self.bits {
26            false => X1DEN_A::VALUE1,
27            true => X1DEN_A::VALUE2,
28        }
29    }
30    #[doc = "Bit X1D is not updated"]
31    #[inline(always)]
32    pub fn is_value1(&self) -> bool {
33        *self == X1DEN_A::VALUE1
34    }
35    #[doc = "Bit X1D can be updated"]
36    #[inline(always)]
37    pub fn is_value2(&self) -> bool {
38        *self == X1DEN_A::VALUE2
39    }
40}
41#[doc = "Field `X1DEN` writer - XTAL1 Data Enable"]
42pub type X1DEN_W<'a, REG> = crate::BitWriter<'a, REG, X1DEN_A>;
43impl<'a, REG> X1DEN_W<'a, REG>
44where
45    REG: crate::Writable + crate::RegisterSpec,
46{
47    #[doc = "Bit X1D is not updated"]
48    #[inline(always)]
49    pub fn value1(self) -> &'a mut crate::W<REG> {
50        self.variant(X1DEN_A::VALUE1)
51    }
52    #[doc = "Bit X1D can be updated"]
53    #[inline(always)]
54    pub fn value2(self) -> &'a mut crate::W<REG> {
55        self.variant(X1DEN_A::VALUE2)
56    }
57}
58#[doc = "Shaper Bypass\n\nValue on reset: 1"]
59#[derive(Clone, Copy, Debug, PartialEq, Eq)]
60pub enum SHBY_A {
61    #[doc = "0: The shaper is not bypassed"]
62    VALUE1 = 0,
63    #[doc = "1: The shaper is bypassed"]
64    VALUE2 = 1,
65}
66impl From<SHBY_A> for bool {
67    #[inline(always)]
68    fn from(variant: SHBY_A) -> Self {
69        variant as u8 != 0
70    }
71}
72#[doc = "Field `SHBY` reader - Shaper Bypass"]
73pub type SHBY_R = crate::BitReader<SHBY_A>;
74impl SHBY_R {
75    #[doc = "Get enumerated values variant"]
76    #[inline(always)]
77    pub const fn variant(&self) -> SHBY_A {
78        match self.bits {
79            false => SHBY_A::VALUE1,
80            true => SHBY_A::VALUE2,
81        }
82    }
83    #[doc = "The shaper is not bypassed"]
84    #[inline(always)]
85    pub fn is_value1(&self) -> bool {
86        *self == SHBY_A::VALUE1
87    }
88    #[doc = "The shaper is bypassed"]
89    #[inline(always)]
90    pub fn is_value2(&self) -> bool {
91        *self == SHBY_A::VALUE2
92    }
93}
94#[doc = "Field `SHBY` writer - Shaper Bypass"]
95pub type SHBY_W<'a, REG> = crate::BitWriter<'a, REG, SHBY_A>;
96impl<'a, REG> SHBY_W<'a, REG>
97where
98    REG: crate::Writable + crate::RegisterSpec,
99{
100    #[doc = "The shaper is not bypassed"]
101    #[inline(always)]
102    pub fn value1(self) -> &'a mut crate::W<REG> {
103        self.variant(SHBY_A::VALUE1)
104    }
105    #[doc = "The shaper is bypassed"]
106    #[inline(always)]
107    pub fn value2(self) -> &'a mut crate::W<REG> {
108        self.variant(SHBY_A::VALUE2)
109    }
110}
111#[doc = "Oscillator Mode\n\nValue on reset: 3"]
112#[derive(Clone, Copy, Debug, PartialEq, Eq)]
113#[repr(u8)]
114pub enum MODE_A {
115    #[doc = "0: External Crystal Mode and External Input Clock Mode. The oscillator Power-Saving Mode is not entered."]
116    VALUE1 = 0,
117    #[doc = "1: OSC is disabled. The oscillator Power-Saving Mode is not entered."]
118    VALUE2 = 1,
119    #[doc = "2: External Input Clock Mode and the oscillator Power-Saving Mode is entered"]
120    VALUE3 = 2,
121    #[doc = "3: OSC is disabled. The oscillator Power-Saving Mode is entered."]
122    VALUE4 = 3,
123}
124impl From<MODE_A> for u8 {
125    #[inline(always)]
126    fn from(variant: MODE_A) -> Self {
127        variant as _
128    }
129}
130impl crate::FieldSpec for MODE_A {
131    type Ux = u8;
132}
133impl crate::IsEnum for MODE_A {}
134#[doc = "Field `MODE` reader - Oscillator Mode"]
135pub type MODE_R = crate::FieldReader<MODE_A>;
136impl MODE_R {
137    #[doc = "Get enumerated values variant"]
138    #[inline(always)]
139    pub const fn variant(&self) -> MODE_A {
140        match self.bits {
141            0 => MODE_A::VALUE1,
142            1 => MODE_A::VALUE2,
143            2 => MODE_A::VALUE3,
144            3 => MODE_A::VALUE4,
145            _ => unreachable!(),
146        }
147    }
148    #[doc = "External Crystal Mode and External Input Clock Mode. The oscillator Power-Saving Mode is not entered."]
149    #[inline(always)]
150    pub fn is_value1(&self) -> bool {
151        *self == MODE_A::VALUE1
152    }
153    #[doc = "OSC is disabled. The oscillator Power-Saving Mode is not entered."]
154    #[inline(always)]
155    pub fn is_value2(&self) -> bool {
156        *self == MODE_A::VALUE2
157    }
158    #[doc = "External Input Clock Mode and the oscillator Power-Saving Mode is entered"]
159    #[inline(always)]
160    pub fn is_value3(&self) -> bool {
161        *self == MODE_A::VALUE3
162    }
163    #[doc = "OSC is disabled. The oscillator Power-Saving Mode is entered."]
164    #[inline(always)]
165    pub fn is_value4(&self) -> bool {
166        *self == MODE_A::VALUE4
167    }
168}
169#[doc = "Field `MODE` writer - Oscillator Mode"]
170pub type MODE_W<'a, REG> = crate::FieldWriter<'a, REG, 2, MODE_A, crate::Safe>;
171impl<'a, REG> MODE_W<'a, REG>
172where
173    REG: crate::Writable + crate::RegisterSpec,
174    REG::Ux: From<u8>,
175{
176    #[doc = "External Crystal Mode and External Input Clock Mode. The oscillator Power-Saving Mode is not entered."]
177    #[inline(always)]
178    pub fn value1(self) -> &'a mut crate::W<REG> {
179        self.variant(MODE_A::VALUE1)
180    }
181    #[doc = "OSC is disabled. The oscillator Power-Saving Mode is not entered."]
182    #[inline(always)]
183    pub fn value2(self) -> &'a mut crate::W<REG> {
184        self.variant(MODE_A::VALUE2)
185    }
186    #[doc = "External Input Clock Mode and the oscillator Power-Saving Mode is entered"]
187    #[inline(always)]
188    pub fn value3(self) -> &'a mut crate::W<REG> {
189        self.variant(MODE_A::VALUE3)
190    }
191    #[doc = "OSC is disabled. The oscillator Power-Saving Mode is entered."]
192    #[inline(always)]
193    pub fn value4(self) -> &'a mut crate::W<REG> {
194        self.variant(MODE_A::VALUE4)
195    }
196}
197#[doc = "Field `OSCVAL` reader - OSC Frequency Value"]
198pub type OSCVAL_R = crate::FieldReader;
199#[doc = "Field `OSCVAL` writer - OSC Frequency Value"]
200pub type OSCVAL_W<'a, REG> = crate::FieldWriter<'a, REG, 4>;
201impl R {
202    #[doc = "Bit 0 - XTAL1 Data Enable"]
203    #[inline(always)]
204    pub fn x1den(&self) -> X1DEN_R {
205        X1DEN_R::new((self.bits & 1) != 0)
206    }
207    #[doc = "Bit 1 - Shaper Bypass"]
208    #[inline(always)]
209    pub fn shby(&self) -> SHBY_R {
210        SHBY_R::new(((self.bits >> 1) & 1) != 0)
211    }
212    #[doc = "Bits 4:5 - Oscillator Mode"]
213    #[inline(always)]
214    pub fn mode(&self) -> MODE_R {
215        MODE_R::new(((self.bits >> 4) & 3) as u8)
216    }
217    #[doc = "Bits 16:19 - OSC Frequency Value"]
218    #[inline(always)]
219    pub fn oscval(&self) -> OSCVAL_R {
220        OSCVAL_R::new(((self.bits >> 16) & 0x0f) as u8)
221    }
222}
223impl W {
224    #[doc = "Bit 0 - XTAL1 Data Enable"]
225    #[inline(always)]
226    pub fn x1den(&mut self) -> X1DEN_W<OSCHPCTRL_SPEC> {
227        X1DEN_W::new(self, 0)
228    }
229    #[doc = "Bit 1 - Shaper Bypass"]
230    #[inline(always)]
231    pub fn shby(&mut self) -> SHBY_W<OSCHPCTRL_SPEC> {
232        SHBY_W::new(self, 1)
233    }
234    #[doc = "Bits 4:5 - Oscillator Mode"]
235    #[inline(always)]
236    pub fn mode(&mut self) -> MODE_W<OSCHPCTRL_SPEC> {
237        MODE_W::new(self, 4)
238    }
239    #[doc = "Bits 16:19 - OSC Frequency Value"]
240    #[inline(always)]
241    pub fn oscval(&mut self) -> OSCVAL_W<OSCHPCTRL_SPEC> {
242        OSCVAL_W::new(self, 16)
243    }
244}
245#[doc = "OSC_HP Control Register\n\nYou can [`read`](crate::Reg::read) this register and get [`oschpctrl::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`oschpctrl::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
246pub struct OSCHPCTRL_SPEC;
247impl crate::RegisterSpec for OSCHPCTRL_SPEC {
248    type Ux = u32;
249}
250#[doc = "`read()` method returns [`oschpctrl::R`](R) reader structure"]
251impl crate::Readable for OSCHPCTRL_SPEC {}
252#[doc = "`write(|w| ..)` method takes [`oschpctrl::W`](W) writer structure"]
253impl crate::Writable for OSCHPCTRL_SPEC {
254    type Safety = crate::Unsafe;
255    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
256    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
257}
258#[doc = "`reset()` method sets OSCHPCTRL to value 0x33"]
259impl crate::Resettable for OSCHPCTRL_SPEC {
260    const RESET_VALUE: u32 = 0x33;
261}