efm32jg1b_pac/efm32jg1b200/cmu/
lfrcoctrl.rs

1#[doc = "Register `LFRCOCTRL` reader"]
2pub struct R(crate::R<LFRCOCTRL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<LFRCOCTRL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<LFRCOCTRL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<LFRCOCTRL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `LFRCOCTRL` writer"]
17pub struct W(crate::W<LFRCOCTRL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<LFRCOCTRL_SPEC>;
20    #[inline(always)]
21    fn deref(&self) -> &Self::Target {
22        &self.0
23    }
24}
25impl core::ops::DerefMut for W {
26    #[inline(always)]
27    fn deref_mut(&mut self) -> &mut Self::Target {
28        &mut self.0
29    }
30}
31impl From<crate::W<LFRCOCTRL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<LFRCOCTRL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `TUNING` reader - LFRCO Tuning Value"]
38pub type TUNING_R = crate::FieldReader<u16, u16>;
39#[doc = "Field `TUNING` writer - LFRCO Tuning Value"]
40pub type TUNING_W<'a, const O: u8> = crate::FieldWriter<'a, u32, LFRCOCTRL_SPEC, u16, u16, 9, O>;
41#[doc = "Field `ENVREF` reader - Enable Duty Cycling of Vref"]
42pub type ENVREF_R = crate::BitReader<bool>;
43#[doc = "Field `ENVREF` writer - Enable Duty Cycling of Vref"]
44pub type ENVREF_W<'a, const O: u8> = crate::BitWriter<'a, u32, LFRCOCTRL_SPEC, bool, O>;
45#[doc = "Field `ENCHOP` reader - Enable Comparator Chopping"]
46pub type ENCHOP_R = crate::BitReader<bool>;
47#[doc = "Field `ENCHOP` writer - Enable Comparator Chopping"]
48pub type ENCHOP_W<'a, const O: u8> = crate::BitWriter<'a, u32, LFRCOCTRL_SPEC, bool, O>;
49#[doc = "Field `ENDEM` reader - Enable Dynamic Element Matching"]
50pub type ENDEM_R = crate::BitReader<bool>;
51#[doc = "Field `ENDEM` writer - Enable Dynamic Element Matching"]
52pub type ENDEM_W<'a, const O: u8> = crate::BitWriter<'a, u32, LFRCOCTRL_SPEC, bool, O>;
53#[doc = "Field `TIMEOUT` reader - LFRCO Timeout"]
54pub type TIMEOUT_R = crate::FieldReader<u8, TIMEOUT_A>;
55#[doc = "LFRCO Timeout\n\nValue on reset: 1"]
56#[derive(Clone, Copy, Debug, PartialEq, Eq)]
57#[repr(u8)]
58pub enum TIMEOUT_A {
59    #[doc = "0: Timeout period of 2 cycles"]
60    _2CYCLES = 0,
61    #[doc = "1: Timeout period of 16 cycles"]
62    _16CYCLES = 1,
63    #[doc = "2: Timeout period of 32 cycles"]
64    _32CYCLES = 2,
65}
66impl From<TIMEOUT_A> for u8 {
67    #[inline(always)]
68    fn from(variant: TIMEOUT_A) -> Self {
69        variant as _
70    }
71}
72impl TIMEOUT_R {
73    #[doc = "Get enumerated values variant"]
74    #[inline(always)]
75    pub fn variant(&self) -> Option<TIMEOUT_A> {
76        match self.bits {
77            0 => Some(TIMEOUT_A::_2CYCLES),
78            1 => Some(TIMEOUT_A::_16CYCLES),
79            2 => Some(TIMEOUT_A::_32CYCLES),
80            _ => None,
81        }
82    }
83    #[doc = "Checks if the value of the field is `_2CYCLES`"]
84    #[inline(always)]
85    pub fn is_2cycles(&self) -> bool {
86        *self == TIMEOUT_A::_2CYCLES
87    }
88    #[doc = "Checks if the value of the field is `_16CYCLES`"]
89    #[inline(always)]
90    pub fn is_16cycles(&self) -> bool {
91        *self == TIMEOUT_A::_16CYCLES
92    }
93    #[doc = "Checks if the value of the field is `_32CYCLES`"]
94    #[inline(always)]
95    pub fn is_32cycles(&self) -> bool {
96        *self == TIMEOUT_A::_32CYCLES
97    }
98}
99#[doc = "Field `TIMEOUT` writer - LFRCO Timeout"]
100pub type TIMEOUT_W<'a, const O: u8> =
101    crate::FieldWriter<'a, u32, LFRCOCTRL_SPEC, u8, TIMEOUT_A, 2, O>;
102impl<'a, const O: u8> TIMEOUT_W<'a, O> {
103    #[doc = "Timeout period of 2 cycles"]
104    #[inline(always)]
105    pub fn _2cycles(self) -> &'a mut W {
106        self.variant(TIMEOUT_A::_2CYCLES)
107    }
108    #[doc = "Timeout period of 16 cycles"]
109    #[inline(always)]
110    pub fn _16cycles(self) -> &'a mut W {
111        self.variant(TIMEOUT_A::_16CYCLES)
112    }
113    #[doc = "Timeout period of 32 cycles"]
114    #[inline(always)]
115    pub fn _32cycles(self) -> &'a mut W {
116        self.variant(TIMEOUT_A::_32CYCLES)
117    }
118}
119#[doc = "Field `GMCCURTUNE` reader - Tuning of Gmc Current"]
120pub type GMCCURTUNE_R = crate::FieldReader<u8, u8>;
121#[doc = "Field `GMCCURTUNE` writer - Tuning of Gmc Current"]
122pub type GMCCURTUNE_W<'a, const O: u8> = crate::FieldWriter<'a, u32, LFRCOCTRL_SPEC, u8, u8, 4, O>;
123impl R {
124    #[doc = "Bits 0:8 - LFRCO Tuning Value"]
125    #[inline(always)]
126    pub fn tuning(&self) -> TUNING_R {
127        TUNING_R::new((self.bits & 0x01ff) as u16)
128    }
129    #[doc = "Bit 16 - Enable Duty Cycling of Vref"]
130    #[inline(always)]
131    pub fn envref(&self) -> ENVREF_R {
132        ENVREF_R::new(((self.bits >> 16) & 1) != 0)
133    }
134    #[doc = "Bit 17 - Enable Comparator Chopping"]
135    #[inline(always)]
136    pub fn enchop(&self) -> ENCHOP_R {
137        ENCHOP_R::new(((self.bits >> 17) & 1) != 0)
138    }
139    #[doc = "Bit 18 - Enable Dynamic Element Matching"]
140    #[inline(always)]
141    pub fn endem(&self) -> ENDEM_R {
142        ENDEM_R::new(((self.bits >> 18) & 1) != 0)
143    }
144    #[doc = "Bits 24:25 - LFRCO Timeout"]
145    #[inline(always)]
146    pub fn timeout(&self) -> TIMEOUT_R {
147        TIMEOUT_R::new(((self.bits >> 24) & 3) as u8)
148    }
149    #[doc = "Bits 28:31 - Tuning of Gmc Current"]
150    #[inline(always)]
151    pub fn gmccurtune(&self) -> GMCCURTUNE_R {
152        GMCCURTUNE_R::new(((self.bits >> 28) & 0x0f) as u8)
153    }
154}
155impl W {
156    #[doc = "Bits 0:8 - LFRCO Tuning Value"]
157    #[inline(always)]
158    #[must_use]
159    pub fn tuning(&mut self) -> TUNING_W<0> {
160        TUNING_W::new(self)
161    }
162    #[doc = "Bit 16 - Enable Duty Cycling of Vref"]
163    #[inline(always)]
164    #[must_use]
165    pub fn envref(&mut self) -> ENVREF_W<16> {
166        ENVREF_W::new(self)
167    }
168    #[doc = "Bit 17 - Enable Comparator Chopping"]
169    #[inline(always)]
170    #[must_use]
171    pub fn enchop(&mut self) -> ENCHOP_W<17> {
172        ENCHOP_W::new(self)
173    }
174    #[doc = "Bit 18 - Enable Dynamic Element Matching"]
175    #[inline(always)]
176    #[must_use]
177    pub fn endem(&mut self) -> ENDEM_W<18> {
178        ENDEM_W::new(self)
179    }
180    #[doc = "Bits 24:25 - LFRCO Timeout"]
181    #[inline(always)]
182    #[must_use]
183    pub fn timeout(&mut self) -> TIMEOUT_W<24> {
184        TIMEOUT_W::new(self)
185    }
186    #[doc = "Bits 28:31 - Tuning of Gmc Current"]
187    #[inline(always)]
188    #[must_use]
189    pub fn gmccurtune(&mut self) -> GMCCURTUNE_W<28> {
190        GMCCURTUNE_W::new(self)
191    }
192    #[doc = "Writes raw bits to the register."]
193    #[inline(always)]
194    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
195        self.0.bits(bits);
196        self
197    }
198}
199#[doc = "LFRCO Control Register\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [lfrcoctrl](index.html) module"]
200pub struct LFRCOCTRL_SPEC;
201impl crate::RegisterSpec for LFRCOCTRL_SPEC {
202    type Ux = u32;
203}
204#[doc = "`read()` method returns [lfrcoctrl::R](R) reader structure"]
205impl crate::Readable for LFRCOCTRL_SPEC {
206    type Reader = R;
207}
208#[doc = "`write(|w| ..)` method takes [lfrcoctrl::W](W) writer structure"]
209impl crate::Writable for LFRCOCTRL_SPEC {
210    type Writer = W;
211    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
212    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
213}
214#[doc = "`reset()` method sets LFRCOCTRL to value 0x8106_0100"]
215impl crate::Resettable for LFRCOCTRL_SPEC {
216    const RESET_VALUE: Self::Ux = 0x8106_0100;
217}