atsamv71j21/pmc/
ckgr_mcfr.rs

1#[doc = "Register `CKGR_MCFR` reader"]
2pub struct R(crate::R<CKGR_MCFR_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CKGR_MCFR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CKGR_MCFR_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CKGR_MCFR_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `CKGR_MCFR` writer"]
17pub struct W(crate::W<CKGR_MCFR_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CKGR_MCFR_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<CKGR_MCFR_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CKGR_MCFR_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `MAINF` reader - Main Clock Frequency"]
38pub struct MAINF_R(crate::FieldReader<u16, u16>);
39impl MAINF_R {
40    #[inline(always)]
41    pub(crate) fn new(bits: u16) -> Self {
42        MAINF_R(crate::FieldReader::new(bits))
43    }
44}
45impl core::ops::Deref for MAINF_R {
46    type Target = crate::FieldReader<u16, u16>;
47    #[inline(always)]
48    fn deref(&self) -> &Self::Target {
49        &self.0
50    }
51}
52#[doc = "Field `MAINF` writer - Main Clock Frequency"]
53pub struct MAINF_W<'a> {
54    w: &'a mut W,
55}
56impl<'a> MAINF_W<'a> {
57    #[doc = r"Writes raw bits to the field"]
58    #[inline(always)]
59    pub unsafe fn bits(self, value: u16) -> &'a mut W {
60        self.w.bits = (self.w.bits & !0xffff) | (value as u32 & 0xffff);
61        self.w
62    }
63}
64#[doc = "Field `MAINFRDY` reader - Main Clock Frequency Measure Ready"]
65pub struct MAINFRDY_R(crate::FieldReader<bool, bool>);
66impl MAINFRDY_R {
67    #[inline(always)]
68    pub(crate) fn new(bits: bool) -> Self {
69        MAINFRDY_R(crate::FieldReader::new(bits))
70    }
71}
72impl core::ops::Deref for MAINFRDY_R {
73    type Target = crate::FieldReader<bool, bool>;
74    #[inline(always)]
75    fn deref(&self) -> &Self::Target {
76        &self.0
77    }
78}
79#[doc = "Field `MAINFRDY` writer - Main Clock Frequency Measure Ready"]
80pub struct MAINFRDY_W<'a> {
81    w: &'a mut W,
82}
83impl<'a> MAINFRDY_W<'a> {
84    #[doc = r"Sets the field bit"]
85    #[inline(always)]
86    pub fn set_bit(self) -> &'a mut W {
87        self.bit(true)
88    }
89    #[doc = r"Clears the field bit"]
90    #[inline(always)]
91    pub fn clear_bit(self) -> &'a mut W {
92        self.bit(false)
93    }
94    #[doc = r"Writes raw bits to the field"]
95    #[inline(always)]
96    pub fn bit(self, value: bool) -> &'a mut W {
97        self.w.bits = (self.w.bits & !(0x01 << 16)) | ((value as u32 & 0x01) << 16);
98        self.w
99    }
100}
101#[doc = "Field `RCMEAS` reader - RC Oscillator Frequency Measure (write-only)"]
102pub struct RCMEAS_R(crate::FieldReader<bool, bool>);
103impl RCMEAS_R {
104    #[inline(always)]
105    pub(crate) fn new(bits: bool) -> Self {
106        RCMEAS_R(crate::FieldReader::new(bits))
107    }
108}
109impl core::ops::Deref for RCMEAS_R {
110    type Target = crate::FieldReader<bool, bool>;
111    #[inline(always)]
112    fn deref(&self) -> &Self::Target {
113        &self.0
114    }
115}
116#[doc = "Field `RCMEAS` writer - RC Oscillator Frequency Measure (write-only)"]
117pub struct RCMEAS_W<'a> {
118    w: &'a mut W,
119}
120impl<'a> RCMEAS_W<'a> {
121    #[doc = r"Sets the field bit"]
122    #[inline(always)]
123    pub fn set_bit(self) -> &'a mut W {
124        self.bit(true)
125    }
126    #[doc = r"Clears the field bit"]
127    #[inline(always)]
128    pub fn clear_bit(self) -> &'a mut W {
129        self.bit(false)
130    }
131    #[doc = r"Writes raw bits to the field"]
132    #[inline(always)]
133    pub fn bit(self, value: bool) -> &'a mut W {
134        self.w.bits = (self.w.bits & !(0x01 << 20)) | ((value as u32 & 0x01) << 20);
135        self.w
136    }
137}
138#[doc = "Field `CCSS` reader - Counter Clock Source Selection"]
139pub struct CCSS_R(crate::FieldReader<bool, bool>);
140impl CCSS_R {
141    #[inline(always)]
142    pub(crate) fn new(bits: bool) -> Self {
143        CCSS_R(crate::FieldReader::new(bits))
144    }
145}
146impl core::ops::Deref for CCSS_R {
147    type Target = crate::FieldReader<bool, bool>;
148    #[inline(always)]
149    fn deref(&self) -> &Self::Target {
150        &self.0
151    }
152}
153#[doc = "Field `CCSS` writer - Counter Clock Source Selection"]
154pub struct CCSS_W<'a> {
155    w: &'a mut W,
156}
157impl<'a> CCSS_W<'a> {
158    #[doc = r"Sets the field bit"]
159    #[inline(always)]
160    pub fn set_bit(self) -> &'a mut W {
161        self.bit(true)
162    }
163    #[doc = r"Clears the field bit"]
164    #[inline(always)]
165    pub fn clear_bit(self) -> &'a mut W {
166        self.bit(false)
167    }
168    #[doc = r"Writes raw bits to the field"]
169    #[inline(always)]
170    pub fn bit(self, value: bool) -> &'a mut W {
171        self.w.bits = (self.w.bits & !(0x01 << 24)) | ((value as u32 & 0x01) << 24);
172        self.w
173    }
174}
175impl R {
176    #[doc = "Bits 0:15 - Main Clock Frequency"]
177    #[inline(always)]
178    pub fn mainf(&self) -> MAINF_R {
179        MAINF_R::new((self.bits & 0xffff) as u16)
180    }
181    #[doc = "Bit 16 - Main Clock Frequency Measure Ready"]
182    #[inline(always)]
183    pub fn mainfrdy(&self) -> MAINFRDY_R {
184        MAINFRDY_R::new(((self.bits >> 16) & 0x01) != 0)
185    }
186    #[doc = "Bit 20 - RC Oscillator Frequency Measure (write-only)"]
187    #[inline(always)]
188    pub fn rcmeas(&self) -> RCMEAS_R {
189        RCMEAS_R::new(((self.bits >> 20) & 0x01) != 0)
190    }
191    #[doc = "Bit 24 - Counter Clock Source Selection"]
192    #[inline(always)]
193    pub fn ccss(&self) -> CCSS_R {
194        CCSS_R::new(((self.bits >> 24) & 0x01) != 0)
195    }
196}
197impl W {
198    #[doc = "Bits 0:15 - Main Clock Frequency"]
199    #[inline(always)]
200    pub fn mainf(&mut self) -> MAINF_W {
201        MAINF_W { w: self }
202    }
203    #[doc = "Bit 16 - Main Clock Frequency Measure Ready"]
204    #[inline(always)]
205    pub fn mainfrdy(&mut self) -> MAINFRDY_W {
206        MAINFRDY_W { w: self }
207    }
208    #[doc = "Bit 20 - RC Oscillator Frequency Measure (write-only)"]
209    #[inline(always)]
210    pub fn rcmeas(&mut self) -> RCMEAS_W {
211        RCMEAS_W { w: self }
212    }
213    #[doc = "Bit 24 - Counter Clock Source Selection"]
214    #[inline(always)]
215    pub fn ccss(&mut self) -> CCSS_W {
216        CCSS_W { w: self }
217    }
218    #[doc = "Writes raw bits to the register."]
219    #[inline(always)]
220    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
221        self.0.bits(bits);
222        self
223    }
224}
225#[doc = "Main Clock Frequency 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 [ckgr_mcfr](index.html) module"]
226pub struct CKGR_MCFR_SPEC;
227impl crate::RegisterSpec for CKGR_MCFR_SPEC {
228    type Ux = u32;
229}
230#[doc = "`read()` method returns [ckgr_mcfr::R](R) reader structure"]
231impl crate::Readable for CKGR_MCFR_SPEC {
232    type Reader = R;
233}
234#[doc = "`write(|w| ..)` method takes [ckgr_mcfr::W](W) writer structure"]
235impl crate::Writable for CKGR_MCFR_SPEC {
236    type Writer = W;
237}
238#[doc = "`reset()` method sets CKGR_MCFR to value 0"]
239impl crate::Resettable for CKGR_MCFR_SPEC {
240    #[inline(always)]
241    fn reset_value() -> Self::Ux {
242        0
243    }
244}