efm32g230_pac/cmu/
hfrcoctrl.rs

1#[doc = "Register `HFRCOCTRL` reader"]
2pub struct R(crate::R<HFRCOCTRL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<HFRCOCTRL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<HFRCOCTRL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<HFRCOCTRL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `HFRCOCTRL` writer"]
17pub struct W(crate::W<HFRCOCTRL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<HFRCOCTRL_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<HFRCOCTRL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<HFRCOCTRL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `TUNING` reader - HFRCO Tuning Value"]
38pub type TUNING_R = crate::FieldReader<u8, u8>;
39#[doc = "Field `TUNING` writer - HFRCO Tuning Value"]
40pub type TUNING_W<'a> = crate::FieldWriter<'a, u32, HFRCOCTRL_SPEC, u8, u8, 8, 0>;
41#[doc = "HFRCO Band Select\n\nValue on reset: 3"]
42#[derive(Clone, Copy, Debug, PartialEq)]
43#[repr(u8)]
44pub enum BAND_A {
45    #[doc = "0: 1 MHz band. NOTE: Also set the TUNING value (bits 7:0) when changing band."]
46    _1MHZ = 0,
47    #[doc = "1: 7 MHz band. NOTE: Also set the TUNING value (bits 7:0) when changing band."]
48    _7MHZ = 1,
49    #[doc = "2: 11 MHz band. NOTE: Also set the TUNING value (bits 7:0) when changing band."]
50    _11MHZ = 2,
51    #[doc = "3: 14 MHz band. NOTE: Also set the TUNING value (bits 7:0) when changing band."]
52    _14MHZ = 3,
53    #[doc = "4: 21 MHz band. NOTE: Also set the TUNING value (bits 7:0) when changing band."]
54    _21MHZ = 4,
55    #[doc = "5: 28 MHz band. NOTE: Also set the TUNING value (bits 7:0) when changing band."]
56    _28MHZ = 5,
57}
58impl From<BAND_A> for u8 {
59    #[inline(always)]
60    fn from(variant: BAND_A) -> Self {
61        variant as _
62    }
63}
64#[doc = "Field `BAND` reader - HFRCO Band Select"]
65pub type BAND_R = crate::FieldReader<u8, BAND_A>;
66impl BAND_R {
67    #[doc = "Get enumerated values variant"]
68    #[inline(always)]
69    pub fn variant(&self) -> Option<BAND_A> {
70        match self.bits {
71            0 => Some(BAND_A::_1MHZ),
72            1 => Some(BAND_A::_7MHZ),
73            2 => Some(BAND_A::_11MHZ),
74            3 => Some(BAND_A::_14MHZ),
75            4 => Some(BAND_A::_21MHZ),
76            5 => Some(BAND_A::_28MHZ),
77            _ => None,
78        }
79    }
80    #[doc = "Checks if the value of the field is `_1MHZ`"]
81    #[inline(always)]
82    pub fn is_1mhz(&self) -> bool {
83        *self == BAND_A::_1MHZ
84    }
85    #[doc = "Checks if the value of the field is `_7MHZ`"]
86    #[inline(always)]
87    pub fn is_7mhz(&self) -> bool {
88        *self == BAND_A::_7MHZ
89    }
90    #[doc = "Checks if the value of the field is `_11MHZ`"]
91    #[inline(always)]
92    pub fn is_11mhz(&self) -> bool {
93        *self == BAND_A::_11MHZ
94    }
95    #[doc = "Checks if the value of the field is `_14MHZ`"]
96    #[inline(always)]
97    pub fn is_14mhz(&self) -> bool {
98        *self == BAND_A::_14MHZ
99    }
100    #[doc = "Checks if the value of the field is `_21MHZ`"]
101    #[inline(always)]
102    pub fn is_21mhz(&self) -> bool {
103        *self == BAND_A::_21MHZ
104    }
105    #[doc = "Checks if the value of the field is `_28MHZ`"]
106    #[inline(always)]
107    pub fn is_28mhz(&self) -> bool {
108        *self == BAND_A::_28MHZ
109    }
110}
111#[doc = "Field `BAND` writer - HFRCO Band Select"]
112pub type BAND_W<'a> = crate::FieldWriter<'a, u32, HFRCOCTRL_SPEC, u8, BAND_A, 3, 8>;
113impl<'a> BAND_W<'a> {
114    #[doc = "1 MHz band. NOTE: Also set the TUNING value (bits 7:0) when changing band."]
115    #[inline(always)]
116    pub fn _1mhz(self) -> &'a mut W {
117        self.variant(BAND_A::_1MHZ)
118    }
119    #[doc = "7 MHz band. NOTE: Also set the TUNING value (bits 7:0) when changing band."]
120    #[inline(always)]
121    pub fn _7mhz(self) -> &'a mut W {
122        self.variant(BAND_A::_7MHZ)
123    }
124    #[doc = "11 MHz band. NOTE: Also set the TUNING value (bits 7:0) when changing band."]
125    #[inline(always)]
126    pub fn _11mhz(self) -> &'a mut W {
127        self.variant(BAND_A::_11MHZ)
128    }
129    #[doc = "14 MHz band. NOTE: Also set the TUNING value (bits 7:0) when changing band."]
130    #[inline(always)]
131    pub fn _14mhz(self) -> &'a mut W {
132        self.variant(BAND_A::_14MHZ)
133    }
134    #[doc = "21 MHz band. NOTE: Also set the TUNING value (bits 7:0) when changing band."]
135    #[inline(always)]
136    pub fn _21mhz(self) -> &'a mut W {
137        self.variant(BAND_A::_21MHZ)
138    }
139    #[doc = "28 MHz band. NOTE: Also set the TUNING value (bits 7:0) when changing band."]
140    #[inline(always)]
141    pub fn _28mhz(self) -> &'a mut W {
142        self.variant(BAND_A::_28MHZ)
143    }
144}
145#[doc = "Field `SUDELAY` reader - HFRCO Start-up Delay"]
146pub type SUDELAY_R = crate::FieldReader<u8, u8>;
147#[doc = "Field `SUDELAY` writer - HFRCO Start-up Delay"]
148pub type SUDELAY_W<'a> = crate::FieldWriter<'a, u32, HFRCOCTRL_SPEC, u8, u8, 5, 12>;
149impl R {
150    #[doc = "Bits 0:7 - HFRCO Tuning Value"]
151    #[inline(always)]
152    pub fn tuning(&self) -> TUNING_R {
153        TUNING_R::new((self.bits & 0xff) as u8)
154    }
155    #[doc = "Bits 8:10 - HFRCO Band Select"]
156    #[inline(always)]
157    pub fn band(&self) -> BAND_R {
158        BAND_R::new(((self.bits >> 8) & 7) as u8)
159    }
160    #[doc = "Bits 12:16 - HFRCO Start-up Delay"]
161    #[inline(always)]
162    pub fn sudelay(&self) -> SUDELAY_R {
163        SUDELAY_R::new(((self.bits >> 12) & 0x1f) as u8)
164    }
165}
166impl W {
167    #[doc = "Bits 0:7 - HFRCO Tuning Value"]
168    #[inline(always)]
169    pub fn tuning(&mut self) -> TUNING_W {
170        TUNING_W::new(self)
171    }
172    #[doc = "Bits 8:10 - HFRCO Band Select"]
173    #[inline(always)]
174    pub fn band(&mut self) -> BAND_W {
175        BAND_W::new(self)
176    }
177    #[doc = "Bits 12:16 - HFRCO Start-up Delay"]
178    #[inline(always)]
179    pub fn sudelay(&mut self) -> SUDELAY_W {
180        SUDELAY_W::new(self)
181    }
182    #[doc = "Writes raw bits to the register."]
183    #[inline(always)]
184    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
185        self.0.bits(bits);
186        self
187    }
188}
189#[doc = "HFRCO 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 [hfrcoctrl](index.html) module"]
190pub struct HFRCOCTRL_SPEC;
191impl crate::RegisterSpec for HFRCOCTRL_SPEC {
192    type Ux = u32;
193}
194#[doc = "`read()` method returns [hfrcoctrl::R](R) reader structure"]
195impl crate::Readable for HFRCOCTRL_SPEC {
196    type Reader = R;
197}
198#[doc = "`write(|w| ..)` method takes [hfrcoctrl::W](W) writer structure"]
199impl crate::Writable for HFRCOCTRL_SPEC {
200    type Writer = W;
201}
202#[doc = "`reset()` method sets HFRCOCTRL to value 0x0380"]
203impl crate::Resettable for HFRCOCTRL_SPEC {
204    #[inline(always)]
205    fn reset_value() -> Self::Ux {
206        0x0380
207    }
208}