xmc4400/scu_hibernate/
osculctrl.rs

1#[doc = "Register `OSCULCTRL` reader"]
2pub type R = crate::R<OSCULCTRL_SPEC>;
3#[doc = "Register `OSCULCTRL` writer"]
4pub type W = crate::W<OSCULCTRL_SPEC>;
5#[doc = "XTAL1 Data General Purpose Input Enable\n\nValue on reset: 0"]
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7pub enum X1DEN_A {
8    #[doc = "0: Data input inactivated, power down"]
9    VALUE1 = 0,
10    #[doc = "1: Data input active"]
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 General Purpose Input 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 = "Data input inactivated, power down"]
31    #[inline(always)]
32    pub fn is_value1(&self) -> bool {
33        *self == X1DEN_A::VALUE1
34    }
35    #[doc = "Data input active"]
36    #[inline(always)]
37    pub fn is_value2(&self) -> bool {
38        *self == X1DEN_A::VALUE2
39    }
40}
41#[doc = "Field `X1DEN` writer - XTAL1 Data General Purpose Input 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 = "Data input inactivated, power down"]
48    #[inline(always)]
49    pub fn value1(self) -> &'a mut crate::W<REG> {
50        self.variant(X1DEN_A::VALUE1)
51    }
52    #[doc = "Data input active"]
53    #[inline(always)]
54    pub fn value2(self) -> &'a mut crate::W<REG> {
55        self.variant(X1DEN_A::VALUE2)
56    }
57}
58#[doc = "Oscillator Mode\n\nValue on reset: 2"]
59#[derive(Clone, Copy, Debug, PartialEq, Eq)]
60#[repr(u8)]
61pub enum MODE_A {
62    #[doc = "0: Oscillator is enabled, in operation"]
63    VALUE1 = 0,
64    #[doc = "1: Oscillator is enabled, in bypass mode"]
65    VALUE2 = 1,
66    #[doc = "2: Oscillator in power down"]
67    VALUE3 = 2,
68    #[doc = "3: Oscillator in power down, can be used as GPI"]
69    VALUE4 = 3,
70}
71impl From<MODE_A> for u8 {
72    #[inline(always)]
73    fn from(variant: MODE_A) -> Self {
74        variant as _
75    }
76}
77impl crate::FieldSpec for MODE_A {
78    type Ux = u8;
79}
80impl crate::IsEnum for MODE_A {}
81#[doc = "Field `MODE` reader - Oscillator Mode"]
82pub type MODE_R = crate::FieldReader<MODE_A>;
83impl MODE_R {
84    #[doc = "Get enumerated values variant"]
85    #[inline(always)]
86    pub const fn variant(&self) -> MODE_A {
87        match self.bits {
88            0 => MODE_A::VALUE1,
89            1 => MODE_A::VALUE2,
90            2 => MODE_A::VALUE3,
91            3 => MODE_A::VALUE4,
92            _ => unreachable!(),
93        }
94    }
95    #[doc = "Oscillator is enabled, in operation"]
96    #[inline(always)]
97    pub fn is_value1(&self) -> bool {
98        *self == MODE_A::VALUE1
99    }
100    #[doc = "Oscillator is enabled, in bypass mode"]
101    #[inline(always)]
102    pub fn is_value2(&self) -> bool {
103        *self == MODE_A::VALUE2
104    }
105    #[doc = "Oscillator in power down"]
106    #[inline(always)]
107    pub fn is_value3(&self) -> bool {
108        *self == MODE_A::VALUE3
109    }
110    #[doc = "Oscillator in power down, can be used as GPI"]
111    #[inline(always)]
112    pub fn is_value4(&self) -> bool {
113        *self == MODE_A::VALUE4
114    }
115}
116#[doc = "Field `MODE` writer - Oscillator Mode"]
117pub type MODE_W<'a, REG> = crate::FieldWriter<'a, REG, 2, MODE_A, crate::Safe>;
118impl<'a, REG> MODE_W<'a, REG>
119where
120    REG: crate::Writable + crate::RegisterSpec,
121    REG::Ux: From<u8>,
122{
123    #[doc = "Oscillator is enabled, in operation"]
124    #[inline(always)]
125    pub fn value1(self) -> &'a mut crate::W<REG> {
126        self.variant(MODE_A::VALUE1)
127    }
128    #[doc = "Oscillator is enabled, in bypass mode"]
129    #[inline(always)]
130    pub fn value2(self) -> &'a mut crate::W<REG> {
131        self.variant(MODE_A::VALUE2)
132    }
133    #[doc = "Oscillator in power down"]
134    #[inline(always)]
135    pub fn value3(self) -> &'a mut crate::W<REG> {
136        self.variant(MODE_A::VALUE3)
137    }
138    #[doc = "Oscillator in power down, can be used as GPI"]
139    #[inline(always)]
140    pub fn value4(self) -> &'a mut crate::W<REG> {
141        self.variant(MODE_A::VALUE4)
142    }
143}
144impl R {
145    #[doc = "Bit 0 - XTAL1 Data General Purpose Input Enable"]
146    #[inline(always)]
147    pub fn x1den(&self) -> X1DEN_R {
148        X1DEN_R::new((self.bits & 1) != 0)
149    }
150    #[doc = "Bits 4:5 - Oscillator Mode"]
151    #[inline(always)]
152    pub fn mode(&self) -> MODE_R {
153        MODE_R::new(((self.bits >> 4) & 3) as u8)
154    }
155}
156impl W {
157    #[doc = "Bit 0 - XTAL1 Data General Purpose Input Enable"]
158    #[inline(always)]
159    pub fn x1den(&mut self) -> X1DEN_W<OSCULCTRL_SPEC> {
160        X1DEN_W::new(self, 0)
161    }
162    #[doc = "Bits 4:5 - Oscillator Mode"]
163    #[inline(always)]
164    pub fn mode(&mut self) -> MODE_W<OSCULCTRL_SPEC> {
165        MODE_W::new(self, 4)
166    }
167}
168#[doc = "OSC_ULP Control Register\n\nYou can [`read`](crate::Reg::read) this register and get [`osculctrl::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`osculctrl::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
169pub struct OSCULCTRL_SPEC;
170impl crate::RegisterSpec for OSCULCTRL_SPEC {
171    type Ux = u32;
172}
173#[doc = "`read()` method returns [`osculctrl::R`](R) reader structure"]
174impl crate::Readable for OSCULCTRL_SPEC {}
175#[doc = "`write(|w| ..)` method takes [`osculctrl::W`](W) writer structure"]
176impl crate::Writable for OSCULCTRL_SPEC {
177    type Safety = crate::Unsafe;
178    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
179    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
180}
181#[doc = "`reset()` method sets OSCULCTRL to value 0x20"]
182impl crate::Resettable for OSCULCTRL_SPEC {
183    const RESET_VALUE: u32 = 0x20;
184}