atsamv71q21/sys_tick/
csr.rs1#[doc = "Register `CSR` reader"]
2pub struct R(crate::R<CSR_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<CSR_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<CSR_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<CSR_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `CSR` writer"]
17pub struct W(crate::W<CSR_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<CSR_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<CSR_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<CSR_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Enables the counter\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39pub enum ENABLE_A {
40 #[doc = "0: counter disabled"]
41 VALUE_0 = 0,
42 #[doc = "1: counter enabled"]
43 VALUE_1 = 1,
44}
45impl From<ENABLE_A> for bool {
46 #[inline(always)]
47 fn from(variant: ENABLE_A) -> Self {
48 variant as u8 != 0
49 }
50}
51#[doc = "Field `ENABLE` reader - Enables the counter"]
52pub struct ENABLE_R(crate::FieldReader<bool, ENABLE_A>);
53impl ENABLE_R {
54 #[inline(always)]
55 pub(crate) fn new(bits: bool) -> Self {
56 ENABLE_R(crate::FieldReader::new(bits))
57 }
58 #[doc = r"Get enumerated values variant"]
59 #[inline(always)]
60 pub fn variant(&self) -> ENABLE_A {
61 match self.bits {
62 false => ENABLE_A::VALUE_0,
63 true => ENABLE_A::VALUE_1,
64 }
65 }
66 #[doc = "Checks if the value of the field is `VALUE_0`"]
67 #[inline(always)]
68 pub fn is_value_0(&self) -> bool {
69 **self == ENABLE_A::VALUE_0
70 }
71 #[doc = "Checks if the value of the field is `VALUE_1`"]
72 #[inline(always)]
73 pub fn is_value_1(&self) -> bool {
74 **self == ENABLE_A::VALUE_1
75 }
76}
77impl core::ops::Deref for ENABLE_R {
78 type Target = crate::FieldReader<bool, ENABLE_A>;
79 #[inline(always)]
80 fn deref(&self) -> &Self::Target {
81 &self.0
82 }
83}
84#[doc = "Field `ENABLE` writer - Enables the counter"]
85pub struct ENABLE_W<'a> {
86 w: &'a mut W,
87}
88impl<'a> ENABLE_W<'a> {
89 #[doc = r"Writes `variant` to the field"]
90 #[inline(always)]
91 pub fn variant(self, variant: ENABLE_A) -> &'a mut W {
92 self.bit(variant.into())
93 }
94 #[doc = "counter disabled"]
95 #[inline(always)]
96 pub fn value_0(self) -> &'a mut W {
97 self.variant(ENABLE_A::VALUE_0)
98 }
99 #[doc = "counter enabled"]
100 #[inline(always)]
101 pub fn value_1(self) -> &'a mut W {
102 self.variant(ENABLE_A::VALUE_1)
103 }
104 #[doc = r"Sets the field bit"]
105 #[inline(always)]
106 pub fn set_bit(self) -> &'a mut W {
107 self.bit(true)
108 }
109 #[doc = r"Clears the field bit"]
110 #[inline(always)]
111 pub fn clear_bit(self) -> &'a mut W {
112 self.bit(false)
113 }
114 #[doc = r"Writes raw bits to the field"]
115 #[inline(always)]
116 pub fn bit(self, value: bool) -> &'a mut W {
117 self.w.bits = (self.w.bits & !0x01) | (value as u32 & 0x01);
118 self.w
119 }
120}
121#[doc = "Enables SysTick exception request\n\nValue on reset: 0"]
122#[derive(Clone, Copy, Debug, PartialEq)]
123pub enum TICKINT_A {
124 #[doc = "0: counting down to 0 does not assert the SysTick exception request"]
125 VALUE_0 = 0,
126 #[doc = "1: counting down to 0 asserts the SysTick exception request"]
127 VALUE_1 = 1,
128}
129impl From<TICKINT_A> for bool {
130 #[inline(always)]
131 fn from(variant: TICKINT_A) -> Self {
132 variant as u8 != 0
133 }
134}
135#[doc = "Field `TICKINT` reader - Enables SysTick exception request"]
136pub struct TICKINT_R(crate::FieldReader<bool, TICKINT_A>);
137impl TICKINT_R {
138 #[inline(always)]
139 pub(crate) fn new(bits: bool) -> Self {
140 TICKINT_R(crate::FieldReader::new(bits))
141 }
142 #[doc = r"Get enumerated values variant"]
143 #[inline(always)]
144 pub fn variant(&self) -> TICKINT_A {
145 match self.bits {
146 false => TICKINT_A::VALUE_0,
147 true => TICKINT_A::VALUE_1,
148 }
149 }
150 #[doc = "Checks if the value of the field is `VALUE_0`"]
151 #[inline(always)]
152 pub fn is_value_0(&self) -> bool {
153 **self == TICKINT_A::VALUE_0
154 }
155 #[doc = "Checks if the value of the field is `VALUE_1`"]
156 #[inline(always)]
157 pub fn is_value_1(&self) -> bool {
158 **self == TICKINT_A::VALUE_1
159 }
160}
161impl core::ops::Deref for TICKINT_R {
162 type Target = crate::FieldReader<bool, TICKINT_A>;
163 #[inline(always)]
164 fn deref(&self) -> &Self::Target {
165 &self.0
166 }
167}
168#[doc = "Field `TICKINT` writer - Enables SysTick exception request"]
169pub struct TICKINT_W<'a> {
170 w: &'a mut W,
171}
172impl<'a> TICKINT_W<'a> {
173 #[doc = r"Writes `variant` to the field"]
174 #[inline(always)]
175 pub fn variant(self, variant: TICKINT_A) -> &'a mut W {
176 self.bit(variant.into())
177 }
178 #[doc = "counting down to 0 does not assert the SysTick exception request"]
179 #[inline(always)]
180 pub fn value_0(self) -> &'a mut W {
181 self.variant(TICKINT_A::VALUE_0)
182 }
183 #[doc = "counting down to 0 asserts the SysTick exception request"]
184 #[inline(always)]
185 pub fn value_1(self) -> &'a mut W {
186 self.variant(TICKINT_A::VALUE_1)
187 }
188 #[doc = r"Sets the field bit"]
189 #[inline(always)]
190 pub fn set_bit(self) -> &'a mut W {
191 self.bit(true)
192 }
193 #[doc = r"Clears the field bit"]
194 #[inline(always)]
195 pub fn clear_bit(self) -> &'a mut W {
196 self.bit(false)
197 }
198 #[doc = r"Writes raw bits to the field"]
199 #[inline(always)]
200 pub fn bit(self, value: bool) -> &'a mut W {
201 self.w.bits = (self.w.bits & !(0x01 << 1)) | ((value as u32 & 0x01) << 1);
202 self.w
203 }
204}
205#[doc = "Indicates the clock source\n\nValue on reset: 1"]
206#[derive(Clone, Copy, Debug, PartialEq)]
207pub enum CLKSOURCE_A {
208 #[doc = "0: external clock"]
209 VALUE_0 = 0,
210 #[doc = "1: processor clock"]
211 VALUE_1 = 1,
212}
213impl From<CLKSOURCE_A> for bool {
214 #[inline(always)]
215 fn from(variant: CLKSOURCE_A) -> Self {
216 variant as u8 != 0
217 }
218}
219#[doc = "Field `CLKSOURCE` reader - Indicates the clock source"]
220pub struct CLKSOURCE_R(crate::FieldReader<bool, CLKSOURCE_A>);
221impl CLKSOURCE_R {
222 #[inline(always)]
223 pub(crate) fn new(bits: bool) -> Self {
224 CLKSOURCE_R(crate::FieldReader::new(bits))
225 }
226 #[doc = r"Get enumerated values variant"]
227 #[inline(always)]
228 pub fn variant(&self) -> CLKSOURCE_A {
229 match self.bits {
230 false => CLKSOURCE_A::VALUE_0,
231 true => CLKSOURCE_A::VALUE_1,
232 }
233 }
234 #[doc = "Checks if the value of the field is `VALUE_0`"]
235 #[inline(always)]
236 pub fn is_value_0(&self) -> bool {
237 **self == CLKSOURCE_A::VALUE_0
238 }
239 #[doc = "Checks if the value of the field is `VALUE_1`"]
240 #[inline(always)]
241 pub fn is_value_1(&self) -> bool {
242 **self == CLKSOURCE_A::VALUE_1
243 }
244}
245impl core::ops::Deref for CLKSOURCE_R {
246 type Target = crate::FieldReader<bool, CLKSOURCE_A>;
247 #[inline(always)]
248 fn deref(&self) -> &Self::Target {
249 &self.0
250 }
251}
252#[doc = "Field `CLKSOURCE` writer - Indicates the clock source"]
253pub struct CLKSOURCE_W<'a> {
254 w: &'a mut W,
255}
256impl<'a> CLKSOURCE_W<'a> {
257 #[doc = r"Writes `variant` to the field"]
258 #[inline(always)]
259 pub fn variant(self, variant: CLKSOURCE_A) -> &'a mut W {
260 self.bit(variant.into())
261 }
262 #[doc = "external clock"]
263 #[inline(always)]
264 pub fn value_0(self) -> &'a mut W {
265 self.variant(CLKSOURCE_A::VALUE_0)
266 }
267 #[doc = "processor clock"]
268 #[inline(always)]
269 pub fn value_1(self) -> &'a mut W {
270 self.variant(CLKSOURCE_A::VALUE_1)
271 }
272 #[doc = r"Sets the field bit"]
273 #[inline(always)]
274 pub fn set_bit(self) -> &'a mut W {
275 self.bit(true)
276 }
277 #[doc = r"Clears the field bit"]
278 #[inline(always)]
279 pub fn clear_bit(self) -> &'a mut W {
280 self.bit(false)
281 }
282 #[doc = r"Writes raw bits to the field"]
283 #[inline(always)]
284 pub fn bit(self, value: bool) -> &'a mut W {
285 self.w.bits = (self.w.bits & !(0x01 << 2)) | ((value as u32 & 0x01) << 2);
286 self.w
287 }
288}
289#[doc = "Field `COUNTFLAG` reader - Returns 1 if timer counted to 0 since last time this was read"]
290pub struct COUNTFLAG_R(crate::FieldReader<bool, bool>);
291impl COUNTFLAG_R {
292 #[inline(always)]
293 pub(crate) fn new(bits: bool) -> Self {
294 COUNTFLAG_R(crate::FieldReader::new(bits))
295 }
296}
297impl core::ops::Deref for COUNTFLAG_R {
298 type Target = crate::FieldReader<bool, bool>;
299 #[inline(always)]
300 fn deref(&self) -> &Self::Target {
301 &self.0
302 }
303}
304#[doc = "Field `COUNTFLAG` writer - Returns 1 if timer counted to 0 since last time this was read"]
305pub struct COUNTFLAG_W<'a> {
306 w: &'a mut W,
307}
308impl<'a> COUNTFLAG_W<'a> {
309 #[doc = r"Sets the field bit"]
310 #[inline(always)]
311 pub fn set_bit(self) -> &'a mut W {
312 self.bit(true)
313 }
314 #[doc = r"Clears the field bit"]
315 #[inline(always)]
316 pub fn clear_bit(self) -> &'a mut W {
317 self.bit(false)
318 }
319 #[doc = r"Writes raw bits to the field"]
320 #[inline(always)]
321 pub fn bit(self, value: bool) -> &'a mut W {
322 self.w.bits = (self.w.bits & !(0x01 << 16)) | ((value as u32 & 0x01) << 16);
323 self.w
324 }
325}
326impl R {
327 #[doc = "Bit 0 - Enables the counter"]
328 #[inline(always)]
329 pub fn enable(&self) -> ENABLE_R {
330 ENABLE_R::new((self.bits & 0x01) != 0)
331 }
332 #[doc = "Bit 1 - Enables SysTick exception request"]
333 #[inline(always)]
334 pub fn tickint(&self) -> TICKINT_R {
335 TICKINT_R::new(((self.bits >> 1) & 0x01) != 0)
336 }
337 #[doc = "Bit 2 - Indicates the clock source"]
338 #[inline(always)]
339 pub fn clksource(&self) -> CLKSOURCE_R {
340 CLKSOURCE_R::new(((self.bits >> 2) & 0x01) != 0)
341 }
342 #[doc = "Bit 16 - Returns 1 if timer counted to 0 since last time this was read"]
343 #[inline(always)]
344 pub fn countflag(&self) -> COUNTFLAG_R {
345 COUNTFLAG_R::new(((self.bits >> 16) & 0x01) != 0)
346 }
347}
348impl W {
349 #[doc = "Bit 0 - Enables the counter"]
350 #[inline(always)]
351 pub fn enable(&mut self) -> ENABLE_W {
352 ENABLE_W { w: self }
353 }
354 #[doc = "Bit 1 - Enables SysTick exception request"]
355 #[inline(always)]
356 pub fn tickint(&mut self) -> TICKINT_W {
357 TICKINT_W { w: self }
358 }
359 #[doc = "Bit 2 - Indicates the clock source"]
360 #[inline(always)]
361 pub fn clksource(&mut self) -> CLKSOURCE_W {
362 CLKSOURCE_W { w: self }
363 }
364 #[doc = "Bit 16 - Returns 1 if timer counted to 0 since last time this was read"]
365 #[inline(always)]
366 pub fn countflag(&mut self) -> COUNTFLAG_W {
367 COUNTFLAG_W { w: self }
368 }
369 #[doc = "Writes raw bits to the register."]
370 #[inline(always)]
371 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
372 self.0.bits(bits);
373 self
374 }
375}
376#[doc = "Control and Status 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 [csr](index.html) module"]
377pub struct CSR_SPEC;
378impl crate::RegisterSpec for CSR_SPEC {
379 type Ux = u32;
380}
381#[doc = "`read()` method returns [csr::R](R) reader structure"]
382impl crate::Readable for CSR_SPEC {
383 type Reader = R;
384}
385#[doc = "`write(|w| ..)` method takes [csr::W](W) writer structure"]
386impl crate::Writable for CSR_SPEC {
387 type Writer = W;
388}
389#[doc = "`reset()` method sets CSR to value 0x04"]
390impl crate::Resettable for CSR_SPEC {
391 #[inline(always)]
392 fn reset_value() -> Self::Ux {
393 0x04
394 }
395}