efm32gg12b330_pac/cmu/
hfxoctrl1.rs

1#[doc = "Register `HFXOCTRL1` reader"]
2pub struct R(crate::R<HFXOCTRL1_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<HFXOCTRL1_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<HFXOCTRL1_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<HFXOCTRL1_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `HFXOCTRL1` writer"]
17pub struct W(crate::W<HFXOCTRL1_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<HFXOCTRL1_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<HFXOCTRL1_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<HFXOCTRL1_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Sets the Amplitude Detection Level (mV)\n\nValue on reset: 2"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39#[repr(u8)]
40pub enum PEAKDETTHR_A {
41    #[doc = "0: 50mV amplitude detection level"]
42    THR0 = 0,
43    #[doc = "1: 75mV amplitude detection level"]
44    THR1 = 1,
45    #[doc = "2: 115mV amplitude detection level"]
46    THR2 = 2,
47    #[doc = "3: 160mV amplitude detection level"]
48    THR3 = 3,
49    #[doc = "4: 220mV amplitude detection level"]
50    THR4 = 4,
51    #[doc = "5: 260mV amplitude detection level"]
52    THR5 = 5,
53    #[doc = "6: 320mV amplitude detection level"]
54    THR6 = 6,
55    #[doc = "7: Same as THR6"]
56    THR7 = 7,
57}
58impl From<PEAKDETTHR_A> for u8 {
59    #[inline(always)]
60    fn from(variant: PEAKDETTHR_A) -> Self {
61        variant as _
62    }
63}
64#[doc = "Field `PEAKDETTHR` reader - Sets the Amplitude Detection Level (mV)"]
65pub type PEAKDETTHR_R = crate::FieldReader<u8, PEAKDETTHR_A>;
66impl PEAKDETTHR_R {
67    #[doc = "Get enumerated values variant"]
68    #[inline(always)]
69    pub fn variant(&self) -> PEAKDETTHR_A {
70        match self.bits {
71            0 => PEAKDETTHR_A::THR0,
72            1 => PEAKDETTHR_A::THR1,
73            2 => PEAKDETTHR_A::THR2,
74            3 => PEAKDETTHR_A::THR3,
75            4 => PEAKDETTHR_A::THR4,
76            5 => PEAKDETTHR_A::THR5,
77            6 => PEAKDETTHR_A::THR6,
78            7 => PEAKDETTHR_A::THR7,
79            _ => unreachable!(),
80        }
81    }
82    #[doc = "Checks if the value of the field is `THR0`"]
83    #[inline(always)]
84    pub fn is_thr0(&self) -> bool {
85        *self == PEAKDETTHR_A::THR0
86    }
87    #[doc = "Checks if the value of the field is `THR1`"]
88    #[inline(always)]
89    pub fn is_thr1(&self) -> bool {
90        *self == PEAKDETTHR_A::THR1
91    }
92    #[doc = "Checks if the value of the field is `THR2`"]
93    #[inline(always)]
94    pub fn is_thr2(&self) -> bool {
95        *self == PEAKDETTHR_A::THR2
96    }
97    #[doc = "Checks if the value of the field is `THR3`"]
98    #[inline(always)]
99    pub fn is_thr3(&self) -> bool {
100        *self == PEAKDETTHR_A::THR3
101    }
102    #[doc = "Checks if the value of the field is `THR4`"]
103    #[inline(always)]
104    pub fn is_thr4(&self) -> bool {
105        *self == PEAKDETTHR_A::THR4
106    }
107    #[doc = "Checks if the value of the field is `THR5`"]
108    #[inline(always)]
109    pub fn is_thr5(&self) -> bool {
110        *self == PEAKDETTHR_A::THR5
111    }
112    #[doc = "Checks if the value of the field is `THR6`"]
113    #[inline(always)]
114    pub fn is_thr6(&self) -> bool {
115        *self == PEAKDETTHR_A::THR6
116    }
117    #[doc = "Checks if the value of the field is `THR7`"]
118    #[inline(always)]
119    pub fn is_thr7(&self) -> bool {
120        *self == PEAKDETTHR_A::THR7
121    }
122}
123#[doc = "Field `PEAKDETTHR` writer - Sets the Amplitude Detection Level (mV)"]
124pub type PEAKDETTHR_W<'a> =
125    crate::FieldWriterSafe<'a, u32, HFXOCTRL1_SPEC, u8, PEAKDETTHR_A, 3, 12>;
126impl<'a> PEAKDETTHR_W<'a> {
127    #[doc = "50mV amplitude detection level"]
128    #[inline(always)]
129    pub fn thr0(self) -> &'a mut W {
130        self.variant(PEAKDETTHR_A::THR0)
131    }
132    #[doc = "75mV amplitude detection level"]
133    #[inline(always)]
134    pub fn thr1(self) -> &'a mut W {
135        self.variant(PEAKDETTHR_A::THR1)
136    }
137    #[doc = "115mV amplitude detection level"]
138    #[inline(always)]
139    pub fn thr2(self) -> &'a mut W {
140        self.variant(PEAKDETTHR_A::THR2)
141    }
142    #[doc = "160mV amplitude detection level"]
143    #[inline(always)]
144    pub fn thr3(self) -> &'a mut W {
145        self.variant(PEAKDETTHR_A::THR3)
146    }
147    #[doc = "220mV amplitude detection level"]
148    #[inline(always)]
149    pub fn thr4(self) -> &'a mut W {
150        self.variant(PEAKDETTHR_A::THR4)
151    }
152    #[doc = "260mV amplitude detection level"]
153    #[inline(always)]
154    pub fn thr5(self) -> &'a mut W {
155        self.variant(PEAKDETTHR_A::THR5)
156    }
157    #[doc = "320mV amplitude detection level"]
158    #[inline(always)]
159    pub fn thr6(self) -> &'a mut W {
160        self.variant(PEAKDETTHR_A::THR6)
161    }
162    #[doc = "Same as THR6"]
163    #[inline(always)]
164    pub fn thr7(self) -> &'a mut W {
165        self.variant(PEAKDETTHR_A::THR7)
166    }
167}
168impl R {
169    #[doc = "Bits 12:14 - Sets the Amplitude Detection Level (mV)"]
170    #[inline(always)]
171    pub fn peakdetthr(&self) -> PEAKDETTHR_R {
172        PEAKDETTHR_R::new(((self.bits >> 12) & 7) as u8)
173    }
174}
175impl W {
176    #[doc = "Bits 12:14 - Sets the Amplitude Detection Level (mV)"]
177    #[inline(always)]
178    pub fn peakdetthr(&mut self) -> PEAKDETTHR_W {
179        PEAKDETTHR_W::new(self)
180    }
181    #[doc = "Writes raw bits to the register."]
182    #[inline(always)]
183    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
184        self.0.bits(bits);
185        self
186    }
187}
188#[doc = "HFXO Control 1\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 [hfxoctrl1](index.html) module"]
189pub struct HFXOCTRL1_SPEC;
190impl crate::RegisterSpec for HFXOCTRL1_SPEC {
191    type Ux = u32;
192}
193#[doc = "`read()` method returns [hfxoctrl1::R](R) reader structure"]
194impl crate::Readable for HFXOCTRL1_SPEC {
195    type Reader = R;
196}
197#[doc = "`write(|w| ..)` method takes [hfxoctrl1::W](W) writer structure"]
198impl crate::Writable for HFXOCTRL1_SPEC {
199    type Writer = W;
200}
201#[doc = "`reset()` method sets HFXOCTRL1 to value 0x2000"]
202impl crate::Resettable for HFXOCTRL1_SPEC {
203    #[inline(always)]
204    fn reset_value() -> Self::Ux {
205        0x2000
206    }
207}