lpc82x_pac/syscon/
clkoutsel.rs1#[doc = "Register `CLKOUTSEL` reader"]
2pub struct R(crate::R<CLKOUTSEL_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<CLKOUTSEL_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<CLKOUTSEL_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<CLKOUTSEL_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `CLKOUTSEL` writer"]
17pub struct W(crate::W<CLKOUTSEL_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<CLKOUTSEL_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<CLKOUTSEL_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<CLKOUTSEL_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "CLKOUT clock source.\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39#[repr(u8)]
40pub enum SEL_A {
41 #[doc = "0: IRC oscillator"]
42 IRC_OSC = 0,
43 #[doc = "1: Crystal oscillator (SYSOSC)"]
44 SYSOSC = 1,
45 #[doc = "2: Watchdog oscillator"]
46 WDTOSC = 2,
47 #[doc = "3: Main clock"]
48 MAIN_CLK = 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 - CLKOUT clock source."]
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::IRC_OSC,
67 1 => SEL_A::SYSOSC,
68 2 => SEL_A::WDTOSC,
69 3 => SEL_A::MAIN_CLK,
70 _ => unreachable!(),
71 }
72 }
73 #[doc = "Checks if the value of the field is `IRC_OSC`"]
74 #[inline(always)]
75 pub fn is_irc_osc(&self) -> bool {
76 **self == SEL_A::IRC_OSC
77 }
78 #[doc = "Checks if the value of the field is `SYSOSC`"]
79 #[inline(always)]
80 pub fn is_sysosc(&self) -> bool {
81 **self == SEL_A::SYSOSC
82 }
83 #[doc = "Checks if the value of the field is `WDTOSC`"]
84 #[inline(always)]
85 pub fn is_wdtosc(&self) -> bool {
86 **self == SEL_A::WDTOSC
87 }
88 #[doc = "Checks if the value of the field is `MAIN_CLK`"]
89 #[inline(always)]
90 pub fn is_main_clk(&self) -> bool {
91 **self == SEL_A::MAIN_CLK
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 - CLKOUT clock source."]
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 = "IRC oscillator"]
112 #[inline(always)]
113 pub fn irc_osc(self) -> &'a mut W {
114 self.variant(SEL_A::IRC_OSC)
115 }
116 #[doc = "Crystal oscillator (SYSOSC)"]
117 #[inline(always)]
118 pub fn sysosc(self) -> &'a mut W {
119 self.variant(SEL_A::SYSOSC)
120 }
121 #[doc = "Watchdog oscillator"]
122 #[inline(always)]
123 pub fn wdtosc(self) -> &'a mut W {
124 self.variant(SEL_A::WDTOSC)
125 }
126 #[doc = "Main clock"]
127 #[inline(always)]
128 pub fn main_clk(self) -> &'a mut W {
129 self.variant(SEL_A::MAIN_CLK)
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 - CLKOUT clock source."]
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 - CLKOUT clock source."]
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 = "CLKOUT clock source select\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 [clkoutsel](index.html) module"]
159pub struct CLKOUTSEL_SPEC;
160impl crate::RegisterSpec for CLKOUTSEL_SPEC {
161 type Ux = u32;
162}
163#[doc = "`read()` method returns [clkoutsel::R](R) reader structure"]
164impl crate::Readable for CLKOUTSEL_SPEC {
165 type Reader = R;
166}
167#[doc = "`write(|w| ..)` method takes [clkoutsel::W](W) writer structure"]
168impl crate::Writable for CLKOUTSEL_SPEC {
169 type Writer = W;
170}
171#[doc = "`reset()` method sets CLKOUTSEL to value 0"]
172impl crate::Resettable for CLKOUTSEL_SPEC {
173 #[inline(always)]
174 fn reset_value() -> Self::Ux {
175 0
176 }
177}