1#[doc = "Register `MOMCR` reader"]
2pub struct R(crate::R<MOMCR_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<MOMCR_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<MOMCR_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<MOMCR_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `MOMCR` writer"]
17pub struct W(crate::W<MOMCR_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<MOMCR_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<MOMCR_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<MOMCR_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `MODRV` reader - Main Clock Oscillator Drive Capability 0 Switching"]
38pub type MODRV_R = crate::FieldReader<u8, MODRV_A>;
39#[doc = "Main Clock Oscillator Drive Capability 0 Switching\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum MODRV_A {
43 #[doc = "0: 20 MHz to 24 MHz"]
44 _00 = 0,
45 #[doc = "1: 16 MHz to 20 MHz"]
46 _01 = 1,
47 #[doc = "2: 8 MHz to 16 MHz"]
48 _10 = 2,
49 #[doc = "3: 8 MHz"]
50 _11 = 3,
51}
52impl From<MODRV_A> for u8 {
53 #[inline(always)]
54 fn from(variant: MODRV_A) -> Self {
55 variant as _
56 }
57}
58impl MODRV_R {
59 #[doc = "Get enumerated values variant"]
60 #[inline(always)]
61 pub fn variant(&self) -> MODRV_A {
62 match self.bits {
63 0 => MODRV_A::_00,
64 1 => MODRV_A::_01,
65 2 => MODRV_A::_10,
66 3 => MODRV_A::_11,
67 _ => unreachable!(),
68 }
69 }
70 #[doc = "Checks if the value of the field is `_00`"]
71 #[inline(always)]
72 pub fn is_00(&self) -> bool {
73 *self == MODRV_A::_00
74 }
75 #[doc = "Checks if the value of the field is `_01`"]
76 #[inline(always)]
77 pub fn is_01(&self) -> bool {
78 *self == MODRV_A::_01
79 }
80 #[doc = "Checks if the value of the field is `_10`"]
81 #[inline(always)]
82 pub fn is_10(&self) -> bool {
83 *self == MODRV_A::_10
84 }
85 #[doc = "Checks if the value of the field is `_11`"]
86 #[inline(always)]
87 pub fn is_11(&self) -> bool {
88 *self == MODRV_A::_11
89 }
90}
91#[doc = "Field `MODRV` writer - Main Clock Oscillator Drive Capability 0 Switching"]
92pub type MODRV_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u8, MOMCR_SPEC, u8, MODRV_A, 2, O>;
93impl<'a, const O: u8> MODRV_W<'a, O> {
94 #[doc = "20 MHz to 24 MHz"]
95 #[inline(always)]
96 pub fn _00(self) -> &'a mut W {
97 self.variant(MODRV_A::_00)
98 }
99 #[doc = "16 MHz to 20 MHz"]
100 #[inline(always)]
101 pub fn _01(self) -> &'a mut W {
102 self.variant(MODRV_A::_01)
103 }
104 #[doc = "8 MHz to 16 MHz"]
105 #[inline(always)]
106 pub fn _10(self) -> &'a mut W {
107 self.variant(MODRV_A::_10)
108 }
109 #[doc = "8 MHz"]
110 #[inline(always)]
111 pub fn _11(self) -> &'a mut W {
112 self.variant(MODRV_A::_11)
113 }
114}
115#[doc = "Field `MOSEL` reader - Main Clock Oscillator Switching"]
116pub type MOSEL_R = crate::BitReader<MOSEL_A>;
117#[doc = "Main Clock Oscillator Switching\n\nValue on reset: 0"]
118#[derive(Clone, Copy, Debug, PartialEq, Eq)]
119pub enum MOSEL_A {
120 #[doc = "0: Resonator"]
121 _0 = 0,
122 #[doc = "1: External clock input"]
123 _1 = 1,
124}
125impl From<MOSEL_A> for bool {
126 #[inline(always)]
127 fn from(variant: MOSEL_A) -> Self {
128 variant as u8 != 0
129 }
130}
131impl MOSEL_R {
132 #[doc = "Get enumerated values variant"]
133 #[inline(always)]
134 pub fn variant(&self) -> MOSEL_A {
135 match self.bits {
136 false => MOSEL_A::_0,
137 true => MOSEL_A::_1,
138 }
139 }
140 #[doc = "Checks if the value of the field is `_0`"]
141 #[inline(always)]
142 pub fn is_0(&self) -> bool {
143 *self == MOSEL_A::_0
144 }
145 #[doc = "Checks if the value of the field is `_1`"]
146 #[inline(always)]
147 pub fn is_1(&self) -> bool {
148 *self == MOSEL_A::_1
149 }
150}
151#[doc = "Field `MOSEL` writer - Main Clock Oscillator Switching"]
152pub type MOSEL_W<'a, const O: u8> = crate::BitWriter<'a, u8, MOMCR_SPEC, MOSEL_A, O>;
153impl<'a, const O: u8> MOSEL_W<'a, O> {
154 #[doc = "Resonator"]
155 #[inline(always)]
156 pub fn _0(self) -> &'a mut W {
157 self.variant(MOSEL_A::_0)
158 }
159 #[doc = "External clock input"]
160 #[inline(always)]
161 pub fn _1(self) -> &'a mut W {
162 self.variant(MOSEL_A::_1)
163 }
164}
165impl R {
166 #[doc = "Bits 4:5 - Main Clock Oscillator Drive Capability 0 Switching"]
167 #[inline(always)]
168 pub fn modrv(&self) -> MODRV_R {
169 MODRV_R::new((self.bits >> 4) & 3)
170 }
171 #[doc = "Bit 6 - Main Clock Oscillator Switching"]
172 #[inline(always)]
173 pub fn mosel(&self) -> MOSEL_R {
174 MOSEL_R::new(((self.bits >> 6) & 1) != 0)
175 }
176}
177impl W {
178 #[doc = "Bits 4:5 - Main Clock Oscillator Drive Capability 0 Switching"]
179 #[inline(always)]
180 #[must_use]
181 pub fn modrv(&mut self) -> MODRV_W<4> {
182 MODRV_W::new(self)
183 }
184 #[doc = "Bit 6 - Main Clock Oscillator Switching"]
185 #[inline(always)]
186 #[must_use]
187 pub fn mosel(&mut self) -> MOSEL_W<6> {
188 MOSEL_W::new(self)
189 }
190 #[doc = "Writes raw bits to the register."]
191 #[inline(always)]
192 pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
193 self.0.bits(bits);
194 self
195 }
196}
197#[doc = "Main Clock Oscillator Mode Oscillation 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 [momcr](index.html) module"]
198pub struct MOMCR_SPEC;
199impl crate::RegisterSpec for MOMCR_SPEC {
200 type Ux = u8;
201}
202#[doc = "`read()` method returns [momcr::R](R) reader structure"]
203impl crate::Readable for MOMCR_SPEC {
204 type Reader = R;
205}
206#[doc = "`write(|w| ..)` method takes [momcr::W](W) writer structure"]
207impl crate::Writable for MOMCR_SPEC {
208 type Writer = W;
209 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
210 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
211}
212#[doc = "`reset()` method sets MOMCR to value 0"]
213impl crate::Resettable for MOMCR_SPEC {
214 const RESET_VALUE: Self::Ux = 0;
215}