atsams70n21/pmc/
pmc_pck.rs

1#[doc = "Register `PMC_PCK[%s]` reader"]
2pub struct R(crate::R<PMC_PCK_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<PMC_PCK_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<PMC_PCK_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<PMC_PCK_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `PMC_PCK[%s]` writer"]
17pub struct W(crate::W<PMC_PCK_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<PMC_PCK_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<PMC_PCK_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<PMC_PCK_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Programmable Clock Source Selection\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39#[repr(u8)]
40pub enum CSS_A {
41    #[doc = "0: SLCK is selected"]
42    SLOW_CLK = 0,
43    #[doc = "1: MAINCK is selected"]
44    MAIN_CLK = 1,
45    #[doc = "2: PLLACK is selected"]
46    PLLA_CLK = 2,
47    #[doc = "3: UPLLCKDIV is selected"]
48    UPLL_CLK = 3,
49    #[doc = "4: MCK is selected"]
50    MCK = 4,
51}
52impl From<CSS_A> for u8 {
53    #[inline(always)]
54    fn from(variant: CSS_A) -> Self {
55        variant as _
56    }
57}
58#[doc = "Field `CSS` reader - Programmable Clock Source Selection"]
59pub struct CSS_R(crate::FieldReader<u8, CSS_A>);
60impl CSS_R {
61    #[inline(always)]
62    pub(crate) fn new(bits: u8) -> Self {
63        CSS_R(crate::FieldReader::new(bits))
64    }
65    #[doc = r"Get enumerated values variant"]
66    #[inline(always)]
67    pub fn variant(&self) -> Option<CSS_A> {
68        match self.bits {
69            0 => Some(CSS_A::SLOW_CLK),
70            1 => Some(CSS_A::MAIN_CLK),
71            2 => Some(CSS_A::PLLA_CLK),
72            3 => Some(CSS_A::UPLL_CLK),
73            4 => Some(CSS_A::MCK),
74            _ => None,
75        }
76    }
77    #[doc = "Checks if the value of the field is `SLOW_CLK`"]
78    #[inline(always)]
79    pub fn is_slow_clk(&self) -> bool {
80        **self == CSS_A::SLOW_CLK
81    }
82    #[doc = "Checks if the value of the field is `MAIN_CLK`"]
83    #[inline(always)]
84    pub fn is_main_clk(&self) -> bool {
85        **self == CSS_A::MAIN_CLK
86    }
87    #[doc = "Checks if the value of the field is `PLLA_CLK`"]
88    #[inline(always)]
89    pub fn is_plla_clk(&self) -> bool {
90        **self == CSS_A::PLLA_CLK
91    }
92    #[doc = "Checks if the value of the field is `UPLL_CLK`"]
93    #[inline(always)]
94    pub fn is_upll_clk(&self) -> bool {
95        **self == CSS_A::UPLL_CLK
96    }
97    #[doc = "Checks if the value of the field is `MCK`"]
98    #[inline(always)]
99    pub fn is_mck(&self) -> bool {
100        **self == CSS_A::MCK
101    }
102}
103impl core::ops::Deref for CSS_R {
104    type Target = crate::FieldReader<u8, CSS_A>;
105    #[inline(always)]
106    fn deref(&self) -> &Self::Target {
107        &self.0
108    }
109}
110#[doc = "Field `CSS` writer - Programmable Clock Source Selection"]
111pub struct CSS_W<'a> {
112    w: &'a mut W,
113}
114impl<'a> CSS_W<'a> {
115    #[doc = r"Writes `variant` to the field"]
116    #[inline(always)]
117    pub fn variant(self, variant: CSS_A) -> &'a mut W {
118        unsafe { self.bits(variant.into()) }
119    }
120    #[doc = "SLCK is selected"]
121    #[inline(always)]
122    pub fn slow_clk(self) -> &'a mut W {
123        self.variant(CSS_A::SLOW_CLK)
124    }
125    #[doc = "MAINCK is selected"]
126    #[inline(always)]
127    pub fn main_clk(self) -> &'a mut W {
128        self.variant(CSS_A::MAIN_CLK)
129    }
130    #[doc = "PLLACK is selected"]
131    #[inline(always)]
132    pub fn plla_clk(self) -> &'a mut W {
133        self.variant(CSS_A::PLLA_CLK)
134    }
135    #[doc = "UPLLCKDIV is selected"]
136    #[inline(always)]
137    pub fn upll_clk(self) -> &'a mut W {
138        self.variant(CSS_A::UPLL_CLK)
139    }
140    #[doc = "MCK is selected"]
141    #[inline(always)]
142    pub fn mck(self) -> &'a mut W {
143        self.variant(CSS_A::MCK)
144    }
145    #[doc = r"Writes raw bits to the field"]
146    #[inline(always)]
147    pub unsafe fn bits(self, value: u8) -> &'a mut W {
148        self.w.bits = (self.w.bits & !0x07) | (value as u32 & 0x07);
149        self.w
150    }
151}
152#[doc = "Field `PRES` reader - Programmable Clock Prescaler"]
153pub struct PRES_R(crate::FieldReader<u8, u8>);
154impl PRES_R {
155    #[inline(always)]
156    pub(crate) fn new(bits: u8) -> Self {
157        PRES_R(crate::FieldReader::new(bits))
158    }
159}
160impl core::ops::Deref for PRES_R {
161    type Target = crate::FieldReader<u8, u8>;
162    #[inline(always)]
163    fn deref(&self) -> &Self::Target {
164        &self.0
165    }
166}
167#[doc = "Field `PRES` writer - Programmable Clock Prescaler"]
168pub struct PRES_W<'a> {
169    w: &'a mut W,
170}
171impl<'a> PRES_W<'a> {
172    #[doc = r"Writes raw bits to the field"]
173    #[inline(always)]
174    pub unsafe fn bits(self, value: u8) -> &'a mut W {
175        self.w.bits = (self.w.bits & !(0xff << 4)) | ((value as u32 & 0xff) << 4);
176        self.w
177    }
178}
179impl R {
180    #[doc = "Bits 0:2 - Programmable Clock Source Selection"]
181    #[inline(always)]
182    pub fn css(&self) -> CSS_R {
183        CSS_R::new((self.bits & 0x07) as u8)
184    }
185    #[doc = "Bits 4:11 - Programmable Clock Prescaler"]
186    #[inline(always)]
187    pub fn pres(&self) -> PRES_R {
188        PRES_R::new(((self.bits >> 4) & 0xff) as u8)
189    }
190}
191impl W {
192    #[doc = "Bits 0:2 - Programmable Clock Source Selection"]
193    #[inline(always)]
194    pub fn css(&mut self) -> CSS_W {
195        CSS_W { w: self }
196    }
197    #[doc = "Bits 4:11 - Programmable Clock Prescaler"]
198    #[inline(always)]
199    pub fn pres(&mut self) -> PRES_W {
200        PRES_W { w: self }
201    }
202    #[doc = "Writes raw bits to the register."]
203    #[inline(always)]
204    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
205        self.0.bits(bits);
206        self
207    }
208}
209#[doc = "Programmable Clock 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 [pmc_pck](index.html) module"]
210pub struct PMC_PCK_SPEC;
211impl crate::RegisterSpec for PMC_PCK_SPEC {
212    type Ux = u32;
213}
214#[doc = "`read()` method returns [pmc_pck::R](R) reader structure"]
215impl crate::Readable for PMC_PCK_SPEC {
216    type Reader = R;
217}
218#[doc = "`write(|w| ..)` method takes [pmc_pck::W](W) writer structure"]
219impl crate::Writable for PMC_PCK_SPEC {
220    type Writer = W;
221}
222#[doc = "`reset()` method sets PMC_PCK[%s]
223to value 0"]
224impl crate::Resettable for PMC_PCK_SPEC {
225    #[inline(always)]
226    fn reset_value() -> Self::Ux {
227        0
228    }
229}