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