k64/sys_tick/
csr.rs

1#[doc = r" Value read from the register"]
2pub struct R {
3    bits: u32,
4}
5#[doc = r" Value to write to the register"]
6pub struct W {
7    bits: u32,
8}
9impl super::CSR {
10    #[doc = r" Modifies the contents of the register"]
11    #[inline]
12    pub fn modify<F>(&self, f: F)
13    where
14        for<'w> F: FnOnce(&R, &'w mut W) -> &'w mut W,
15    {
16        let bits = self.register.get();
17        let r = R { bits: bits };
18        let mut w = W { bits: bits };
19        f(&r, &mut w);
20        self.register.set(w.bits);
21    }
22    #[doc = r" Reads the contents of the register"]
23    #[inline]
24    pub fn read(&self) -> R {
25        R {
26            bits: self.register.get(),
27        }
28    }
29    #[doc = r" Writes to the register"]
30    #[inline]
31    pub fn write<F>(&self, f: F)
32    where
33        F: FnOnce(&mut W) -> &mut W,
34    {
35        let mut w = W::reset_value();
36        f(&mut w);
37        self.register.set(w.bits);
38    }
39    #[doc = r" Writes the reset value to the register"]
40    #[inline]
41    pub fn reset(&self) {
42        self.write(|w| w)
43    }
44}
45#[doc = "Possible values of the field `ENABLE`"]
46#[derive(Clone, Copy, Debug, PartialEq)]
47pub enum ENABLER {
48    #[doc = "counter disabled"]
49    _0,
50    #[doc = "counter enabled"]
51    _1,
52}
53impl ENABLER {
54    #[doc = r" Returns `true` if the bit is clear (0)"]
55    #[inline]
56    pub fn bit_is_clear(&self) -> bool {
57        !self.bit()
58    }
59    #[doc = r" Returns `true` if the bit is set (1)"]
60    #[inline]
61    pub fn bit_is_set(&self) -> bool {
62        self.bit()
63    }
64    #[doc = r" Value of the field as raw bits"]
65    #[inline]
66    pub fn bit(&self) -> bool {
67        match *self {
68            ENABLER::_0 => false,
69            ENABLER::_1 => true,
70        }
71    }
72    #[allow(missing_docs)]
73    #[doc(hidden)]
74    #[inline]
75    pub fn _from(value: bool) -> ENABLER {
76        match value {
77            false => ENABLER::_0,
78            true => ENABLER::_1,
79        }
80    }
81    #[doc = "Checks if the value of the field is `_0`"]
82    #[inline]
83    pub fn is_0(&self) -> bool {
84        *self == ENABLER::_0
85    }
86    #[doc = "Checks if the value of the field is `_1`"]
87    #[inline]
88    pub fn is_1(&self) -> bool {
89        *self == ENABLER::_1
90    }
91}
92#[doc = "Possible values of the field `TICKINT`"]
93#[derive(Clone, Copy, Debug, PartialEq)]
94pub enum TICKINTR {
95    #[doc = "counting down to 0 does not assert the SysTick exception request"]
96    _0,
97    #[doc = "counting down to 0 asserts the SysTick exception request"]
98    _1,
99}
100impl TICKINTR {
101    #[doc = r" Returns `true` if the bit is clear (0)"]
102    #[inline]
103    pub fn bit_is_clear(&self) -> bool {
104        !self.bit()
105    }
106    #[doc = r" Returns `true` if the bit is set (1)"]
107    #[inline]
108    pub fn bit_is_set(&self) -> bool {
109        self.bit()
110    }
111    #[doc = r" Value of the field as raw bits"]
112    #[inline]
113    pub fn bit(&self) -> bool {
114        match *self {
115            TICKINTR::_0 => false,
116            TICKINTR::_1 => true,
117        }
118    }
119    #[allow(missing_docs)]
120    #[doc(hidden)]
121    #[inline]
122    pub fn _from(value: bool) -> TICKINTR {
123        match value {
124            false => TICKINTR::_0,
125            true => TICKINTR::_1,
126        }
127    }
128    #[doc = "Checks if the value of the field is `_0`"]
129    #[inline]
130    pub fn is_0(&self) -> bool {
131        *self == TICKINTR::_0
132    }
133    #[doc = "Checks if the value of the field is `_1`"]
134    #[inline]
135    pub fn is_1(&self) -> bool {
136        *self == TICKINTR::_1
137    }
138}
139#[doc = "Possible values of the field `CLKSOURCE`"]
140#[derive(Clone, Copy, Debug, PartialEq)]
141pub enum CLKSOURCER {
142    #[doc = "external clock"]
143    _0,
144    #[doc = "processor clock"]
145    _1,
146}
147impl CLKSOURCER {
148    #[doc = r" Returns `true` if the bit is clear (0)"]
149    #[inline]
150    pub fn bit_is_clear(&self) -> bool {
151        !self.bit()
152    }
153    #[doc = r" Returns `true` if the bit is set (1)"]
154    #[inline]
155    pub fn bit_is_set(&self) -> bool {
156        self.bit()
157    }
158    #[doc = r" Value of the field as raw bits"]
159    #[inline]
160    pub fn bit(&self) -> bool {
161        match *self {
162            CLKSOURCER::_0 => false,
163            CLKSOURCER::_1 => true,
164        }
165    }
166    #[allow(missing_docs)]
167    #[doc(hidden)]
168    #[inline]
169    pub fn _from(value: bool) -> CLKSOURCER {
170        match value {
171            false => CLKSOURCER::_0,
172            true => CLKSOURCER::_1,
173        }
174    }
175    #[doc = "Checks if the value of the field is `_0`"]
176    #[inline]
177    pub fn is_0(&self) -> bool {
178        *self == CLKSOURCER::_0
179    }
180    #[doc = "Checks if the value of the field is `_1`"]
181    #[inline]
182    pub fn is_1(&self) -> bool {
183        *self == CLKSOURCER::_1
184    }
185}
186#[doc = r" Value of the field"]
187pub struct COUNTFLAGR {
188    bits: bool,
189}
190impl COUNTFLAGR {
191    #[doc = r" Value of the field as raw bits"]
192    #[inline]
193    pub fn bit(&self) -> bool {
194        self.bits
195    }
196    #[doc = r" Returns `true` if the bit is clear (0)"]
197    #[inline]
198    pub fn bit_is_clear(&self) -> bool {
199        !self.bit()
200    }
201    #[doc = r" Returns `true` if the bit is set (1)"]
202    #[inline]
203    pub fn bit_is_set(&self) -> bool {
204        self.bit()
205    }
206}
207#[doc = "Values that can be written to the field `ENABLE`"]
208pub enum ENABLEW {
209    #[doc = "counter disabled"]
210    _0,
211    #[doc = "counter enabled"]
212    _1,
213}
214impl ENABLEW {
215    #[allow(missing_docs)]
216    #[doc(hidden)]
217    #[inline]
218    pub fn _bits(&self) -> bool {
219        match *self {
220            ENABLEW::_0 => false,
221            ENABLEW::_1 => true,
222        }
223    }
224}
225#[doc = r" Proxy"]
226pub struct _ENABLEW<'a> {
227    w: &'a mut W,
228}
229impl<'a> _ENABLEW<'a> {
230    #[doc = r" Writes `variant` to the field"]
231    #[inline]
232    pub fn variant(self, variant: ENABLEW) -> &'a mut W {
233        {
234            self.bit(variant._bits())
235        }
236    }
237    #[doc = "counter disabled"]
238    #[inline]
239    pub fn _0(self) -> &'a mut W {
240        self.variant(ENABLEW::_0)
241    }
242    #[doc = "counter enabled"]
243    #[inline]
244    pub fn _1(self) -> &'a mut W {
245        self.variant(ENABLEW::_1)
246    }
247    #[doc = r" Sets the field bit"]
248    pub fn set_bit(self) -> &'a mut W {
249        self.bit(true)
250    }
251    #[doc = r" Clears the field bit"]
252    pub fn clear_bit(self) -> &'a mut W {
253        self.bit(false)
254    }
255    #[doc = r" Writes raw bits to the field"]
256    #[inline]
257    pub fn bit(self, value: bool) -> &'a mut W {
258        const MASK: bool = true;
259        const OFFSET: u8 = 0;
260        self.w.bits &= !((MASK as u32) << OFFSET);
261        self.w.bits |= ((value & MASK) as u32) << OFFSET;
262        self.w
263    }
264}
265#[doc = "Values that can be written to the field `TICKINT`"]
266pub enum TICKINTW {
267    #[doc = "counting down to 0 does not assert the SysTick exception request"]
268    _0,
269    #[doc = "counting down to 0 asserts the SysTick exception request"]
270    _1,
271}
272impl TICKINTW {
273    #[allow(missing_docs)]
274    #[doc(hidden)]
275    #[inline]
276    pub fn _bits(&self) -> bool {
277        match *self {
278            TICKINTW::_0 => false,
279            TICKINTW::_1 => true,
280        }
281    }
282}
283#[doc = r" Proxy"]
284pub struct _TICKINTW<'a> {
285    w: &'a mut W,
286}
287impl<'a> _TICKINTW<'a> {
288    #[doc = r" Writes `variant` to the field"]
289    #[inline]
290    pub fn variant(self, variant: TICKINTW) -> &'a mut W {
291        {
292            self.bit(variant._bits())
293        }
294    }
295    #[doc = "counting down to 0 does not assert the SysTick exception request"]
296    #[inline]
297    pub fn _0(self) -> &'a mut W {
298        self.variant(TICKINTW::_0)
299    }
300    #[doc = "counting down to 0 asserts the SysTick exception request"]
301    #[inline]
302    pub fn _1(self) -> &'a mut W {
303        self.variant(TICKINTW::_1)
304    }
305    #[doc = r" Sets the field bit"]
306    pub fn set_bit(self) -> &'a mut W {
307        self.bit(true)
308    }
309    #[doc = r" Clears the field bit"]
310    pub fn clear_bit(self) -> &'a mut W {
311        self.bit(false)
312    }
313    #[doc = r" Writes raw bits to the field"]
314    #[inline]
315    pub fn bit(self, value: bool) -> &'a mut W {
316        const MASK: bool = true;
317        const OFFSET: u8 = 1;
318        self.w.bits &= !((MASK as u32) << OFFSET);
319        self.w.bits |= ((value & MASK) as u32) << OFFSET;
320        self.w
321    }
322}
323#[doc = "Values that can be written to the field `CLKSOURCE`"]
324pub enum CLKSOURCEW {
325    #[doc = "external clock"]
326    _0,
327    #[doc = "processor clock"]
328    _1,
329}
330impl CLKSOURCEW {
331    #[allow(missing_docs)]
332    #[doc(hidden)]
333    #[inline]
334    pub fn _bits(&self) -> bool {
335        match *self {
336            CLKSOURCEW::_0 => false,
337            CLKSOURCEW::_1 => true,
338        }
339    }
340}
341#[doc = r" Proxy"]
342pub struct _CLKSOURCEW<'a> {
343    w: &'a mut W,
344}
345impl<'a> _CLKSOURCEW<'a> {
346    #[doc = r" Writes `variant` to the field"]
347    #[inline]
348    pub fn variant(self, variant: CLKSOURCEW) -> &'a mut W {
349        {
350            self.bit(variant._bits())
351        }
352    }
353    #[doc = "external clock"]
354    #[inline]
355    pub fn _0(self) -> &'a mut W {
356        self.variant(CLKSOURCEW::_0)
357    }
358    #[doc = "processor clock"]
359    #[inline]
360    pub fn _1(self) -> &'a mut W {
361        self.variant(CLKSOURCEW::_1)
362    }
363    #[doc = r" Sets the field bit"]
364    pub fn set_bit(self) -> &'a mut W {
365        self.bit(true)
366    }
367    #[doc = r" Clears the field bit"]
368    pub fn clear_bit(self) -> &'a mut W {
369        self.bit(false)
370    }
371    #[doc = r" Writes raw bits to the field"]
372    #[inline]
373    pub fn bit(self, value: bool) -> &'a mut W {
374        const MASK: bool = true;
375        const OFFSET: u8 = 2;
376        self.w.bits &= !((MASK as u32) << OFFSET);
377        self.w.bits |= ((value & MASK) as u32) << OFFSET;
378        self.w
379    }
380}
381#[doc = r" Proxy"]
382pub struct _COUNTFLAGW<'a> {
383    w: &'a mut W,
384}
385impl<'a> _COUNTFLAGW<'a> {
386    #[doc = r" Sets the field bit"]
387    pub fn set_bit(self) -> &'a mut W {
388        self.bit(true)
389    }
390    #[doc = r" Clears the field bit"]
391    pub fn clear_bit(self) -> &'a mut W {
392        self.bit(false)
393    }
394    #[doc = r" Writes raw bits to the field"]
395    #[inline]
396    pub fn bit(self, value: bool) -> &'a mut W {
397        const MASK: bool = true;
398        const OFFSET: u8 = 16;
399        self.w.bits &= !((MASK as u32) << OFFSET);
400        self.w.bits |= ((value & MASK) as u32) << OFFSET;
401        self.w
402    }
403}
404impl R {
405    #[doc = r" Value of the register as raw bits"]
406    #[inline]
407    pub fn bits(&self) -> u32 {
408        self.bits
409    }
410    #[doc = "Bit 0 - no description available"]
411    #[inline]
412    pub fn enable(&self) -> ENABLER {
413        ENABLER::_from({
414            const MASK: bool = true;
415            const OFFSET: u8 = 0;
416            ((self.bits >> OFFSET) & MASK as u32) != 0
417        })
418    }
419    #[doc = "Bit 1 - no description available"]
420    #[inline]
421    pub fn tickint(&self) -> TICKINTR {
422        TICKINTR::_from({
423            const MASK: bool = true;
424            const OFFSET: u8 = 1;
425            ((self.bits >> OFFSET) & MASK as u32) != 0
426        })
427    }
428    #[doc = "Bit 2 - no description available"]
429    #[inline]
430    pub fn clksource(&self) -> CLKSOURCER {
431        CLKSOURCER::_from({
432            const MASK: bool = true;
433            const OFFSET: u8 = 2;
434            ((self.bits >> OFFSET) & MASK as u32) != 0
435        })
436    }
437    #[doc = "Bit 16 - no description available"]
438    #[inline]
439    pub fn countflag(&self) -> COUNTFLAGR {
440        let bits = {
441            const MASK: bool = true;
442            const OFFSET: u8 = 16;
443            ((self.bits >> OFFSET) & MASK as u32) != 0
444        };
445        COUNTFLAGR { bits }
446    }
447}
448impl W {
449    #[doc = r" Reset value of the register"]
450    #[inline]
451    pub fn reset_value() -> W {
452        W { bits: 4 }
453    }
454    #[doc = r" Writes raw bits to the register"]
455    #[inline]
456    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
457        self.bits = bits;
458        self
459    }
460    #[doc = "Bit 0 - no description available"]
461    #[inline]
462    pub fn enable(&mut self) -> _ENABLEW {
463        _ENABLEW { w: self }
464    }
465    #[doc = "Bit 1 - no description available"]
466    #[inline]
467    pub fn tickint(&mut self) -> _TICKINTW {
468        _TICKINTW { w: self }
469    }
470    #[doc = "Bit 2 - no description available"]
471    #[inline]
472    pub fn clksource(&mut self) -> _CLKSOURCEW {
473        _CLKSOURCEW { w: self }
474    }
475    #[doc = "Bit 16 - no description available"]
476    #[inline]
477    pub fn countflag(&mut self) -> _COUNTFLAGW {
478        _COUNTFLAGW { w: self }
479    }
480}