lpc845_pac/syscon/frg/
frgclksel.rs

1#[doc = "Register `FRGCLKSEL` reader"]
2pub struct R(crate::R<FRGCLKSEL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<FRGCLKSEL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<FRGCLKSEL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<FRGCLKSEL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `FRGCLKSEL` writer"]
17pub struct W(crate::W<FRGCLKSEL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<FRGCLKSEL_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<FRGCLKSEL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<FRGCLKSEL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Clock source for frgN_src clock\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39#[repr(u8)]
40pub enum SEL_A {
41    #[doc = "0: FRO"]
42    FRO = 0,
43    #[doc = "1: main clock"]
44    MAIN_CLK = 1,
45    #[doc = "2: sys pll"]
46    SYS_PLL = 2,
47    #[doc = "3: None"]
48    NONE = 3,
49}
50impl From<SEL_A> for u8 {
51    #[inline(always)]
52    fn from(variant: SEL_A) -> Self {
53        variant as _
54    }
55}
56#[doc = "Field `SEL` reader - Clock source for frgN_src clock"]
57pub struct SEL_R(crate::FieldReader<u8, SEL_A>);
58impl SEL_R {
59    pub(crate) fn new(bits: u8) -> Self {
60        SEL_R(crate::FieldReader::new(bits))
61    }
62    #[doc = r"Get enumerated values variant"]
63    #[inline(always)]
64    pub fn variant(&self) -> SEL_A {
65        match self.bits {
66            0 => SEL_A::FRO,
67            1 => SEL_A::MAIN_CLK,
68            2 => SEL_A::SYS_PLL,
69            3 => SEL_A::NONE,
70            _ => unreachable!(),
71        }
72    }
73    #[doc = "Checks if the value of the field is `FRO`"]
74    #[inline(always)]
75    pub fn is_fro(&self) -> bool {
76        **self == SEL_A::FRO
77    }
78    #[doc = "Checks if the value of the field is `MAIN_CLK`"]
79    #[inline(always)]
80    pub fn is_main_clk(&self) -> bool {
81        **self == SEL_A::MAIN_CLK
82    }
83    #[doc = "Checks if the value of the field is `SYS_PLL`"]
84    #[inline(always)]
85    pub fn is_sys_pll(&self) -> bool {
86        **self == SEL_A::SYS_PLL
87    }
88    #[doc = "Checks if the value of the field is `NONE`"]
89    #[inline(always)]
90    pub fn is_none(&self) -> bool {
91        **self == SEL_A::NONE
92    }
93}
94impl core::ops::Deref for SEL_R {
95    type Target = crate::FieldReader<u8, SEL_A>;
96    #[inline(always)]
97    fn deref(&self) -> &Self::Target {
98        &self.0
99    }
100}
101#[doc = "Field `SEL` writer - Clock source for frgN_src clock"]
102pub struct SEL_W<'a> {
103    w: &'a mut W,
104}
105impl<'a> SEL_W<'a> {
106    #[doc = r"Writes `variant` to the field"]
107    #[inline(always)]
108    pub fn variant(self, variant: SEL_A) -> &'a mut W {
109        self.bits(variant.into())
110    }
111    #[doc = "FRO"]
112    #[inline(always)]
113    pub fn fro(self) -> &'a mut W {
114        self.variant(SEL_A::FRO)
115    }
116    #[doc = "main clock"]
117    #[inline(always)]
118    pub fn main_clk(self) -> &'a mut W {
119        self.variant(SEL_A::MAIN_CLK)
120    }
121    #[doc = "sys pll"]
122    #[inline(always)]
123    pub fn sys_pll(self) -> &'a mut W {
124        self.variant(SEL_A::SYS_PLL)
125    }
126    #[doc = "None"]
127    #[inline(always)]
128    pub fn none(self) -> &'a mut W {
129        self.variant(SEL_A::NONE)
130    }
131    #[doc = r"Writes raw bits to the field"]
132    #[inline(always)]
133    pub fn bits(self, value: u8) -> &'a mut W {
134        self.w.bits = (self.w.bits & !0x03) | (value as u32 & 0x03);
135        self.w
136    }
137}
138impl R {
139    #[doc = "Bits 0:1 - Clock source for frgN_src clock"]
140    #[inline(always)]
141    pub fn sel(&self) -> SEL_R {
142        SEL_R::new((self.bits & 0x03) as u8)
143    }
144}
145impl W {
146    #[doc = "Bits 0:1 - Clock source for frgN_src clock"]
147    #[inline(always)]
148    pub fn sel(&mut self) -> SEL_W {
149        SEL_W { w: self }
150    }
151    #[doc = "Writes raw bits to the register."]
152    #[inline(always)]
153    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
154        self.0.bits(bits);
155        self
156    }
157}
158#[doc = "FRG N clock source select 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 [frgclksel](index.html) module"]
159pub struct FRGCLKSEL_SPEC;
160impl crate::RegisterSpec for FRGCLKSEL_SPEC {
161    type Ux = u32;
162}
163#[doc = "`read()` method returns [frgclksel::R](R) reader structure"]
164impl crate::Readable for FRGCLKSEL_SPEC {
165    type Reader = R;
166}
167#[doc = "`write(|w| ..)` method takes [frgclksel::W](W) writer structure"]
168impl crate::Writable for FRGCLKSEL_SPEC {
169    type Writer = W;
170}
171#[doc = "`reset()` method sets FRGCLKSEL to value 0"]
172impl crate::Resettable for FRGCLKSEL_SPEC {
173    #[inline(always)]
174    fn reset_value() -> Self::Ux {
175        0
176    }
177}