rp2040_pac/ppb/
syst_csr.rs

1#[doc = "Register `SYST_CSR` reader"]
2pub type R = crate::R<SYST_CSR_SPEC>;
3#[doc = "Register `SYST_CSR` writer"]
4pub type W = crate::W<SYST_CSR_SPEC>;
5#[doc = "Field `ENABLE` reader - Enable SysTick counter:  
6 0 = Counter disabled.  
7 1 = Counter enabled."]
8pub type ENABLE_R = crate::BitReader;
9#[doc = "Field `ENABLE` writer - Enable SysTick counter:  
10 0 = Counter disabled.  
11 1 = Counter enabled."]
12pub type ENABLE_W<'a, REG> = crate::BitWriter<'a, REG>;
13#[doc = "Field `TICKINT` reader - Enables SysTick exception request:  
14 0 = Counting down to zero does not assert the SysTick exception request.  
15 1 = Counting down to zero to asserts the SysTick exception request."]
16pub type TICKINT_R = crate::BitReader;
17#[doc = "Field `TICKINT` writer - Enables SysTick exception request:  
18 0 = Counting down to zero does not assert the SysTick exception request.  
19 1 = Counting down to zero to asserts the SysTick exception request."]
20pub type TICKINT_W<'a, REG> = crate::BitWriter<'a, REG>;
21#[doc = "Field `CLKSOURCE` reader - SysTick clock source. Always reads as one if SYST_CALIB reports NOREF.  
22 Selects the SysTick timer clock source:  
23 0 = External reference clock.  
24 1 = Processor clock."]
25pub type CLKSOURCE_R = crate::BitReader;
26#[doc = "Field `CLKSOURCE` writer - SysTick clock source. Always reads as one if SYST_CALIB reports NOREF.  
27 Selects the SysTick timer clock source:  
28 0 = External reference clock.  
29 1 = Processor clock."]
30pub type CLKSOURCE_W<'a, REG> = crate::BitWriter<'a, REG>;
31#[doc = "Field `COUNTFLAG` reader - Returns 1 if timer counted to 0 since last time this was read. Clears on read by application or debugger."]
32pub type COUNTFLAG_R = crate::BitReader;
33impl R {
34    #[doc = "Bit 0 - Enable SysTick counter:  
35 0 = Counter disabled.  
36 1 = Counter enabled."]
37    #[inline(always)]
38    pub fn enable(&self) -> ENABLE_R {
39        ENABLE_R::new((self.bits & 1) != 0)
40    }
41    #[doc = "Bit 1 - Enables SysTick exception request:  
42 0 = Counting down to zero does not assert the SysTick exception request.  
43 1 = Counting down to zero to asserts the SysTick exception request."]
44    #[inline(always)]
45    pub fn tickint(&self) -> TICKINT_R {
46        TICKINT_R::new(((self.bits >> 1) & 1) != 0)
47    }
48    #[doc = "Bit 2 - SysTick clock source. Always reads as one if SYST_CALIB reports NOREF.  
49 Selects the SysTick timer clock source:  
50 0 = External reference clock.  
51 1 = Processor clock."]
52    #[inline(always)]
53    pub fn clksource(&self) -> CLKSOURCE_R {
54        CLKSOURCE_R::new(((self.bits >> 2) & 1) != 0)
55    }
56    #[doc = "Bit 16 - Returns 1 if timer counted to 0 since last time this was read. Clears on read by application or debugger."]
57    #[inline(always)]
58    pub fn countflag(&self) -> COUNTFLAG_R {
59        COUNTFLAG_R::new(((self.bits >> 16) & 1) != 0)
60    }
61}
62impl W {
63    #[doc = "Bit 0 - Enable SysTick counter:  
64 0 = Counter disabled.  
65 1 = Counter enabled."]
66    #[inline(always)]
67    #[must_use]
68    pub fn enable(&mut self) -> ENABLE_W<SYST_CSR_SPEC> {
69        ENABLE_W::new(self, 0)
70    }
71    #[doc = "Bit 1 - Enables SysTick exception request:  
72 0 = Counting down to zero does not assert the SysTick exception request.  
73 1 = Counting down to zero to asserts the SysTick exception request."]
74    #[inline(always)]
75    #[must_use]
76    pub fn tickint(&mut self) -> TICKINT_W<SYST_CSR_SPEC> {
77        TICKINT_W::new(self, 1)
78    }
79    #[doc = "Bit 2 - SysTick clock source. Always reads as one if SYST_CALIB reports NOREF.  
80 Selects the SysTick timer clock source:  
81 0 = External reference clock.  
82 1 = Processor clock."]
83    #[inline(always)]
84    #[must_use]
85    pub fn clksource(&mut self) -> CLKSOURCE_W<SYST_CSR_SPEC> {
86        CLKSOURCE_W::new(self, 2)
87    }
88    #[doc = r" Writes raw bits to the register."]
89    #[doc = r""]
90    #[doc = r" # Safety"]
91    #[doc = r""]
92    #[doc = r" Passing incorrect value can cause undefined behaviour. See reference manual"]
93    #[inline(always)]
94    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
95        self.bits = bits;
96        self
97    }
98}
99#[doc = "Use the SysTick Control and Status Register to enable the SysTick features.  
100
101You can [`read`](crate::generic::Reg::read) this register and get [`syst_csr::R`](R).  You can [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero) this register using [`syst_csr::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
102pub struct SYST_CSR_SPEC;
103impl crate::RegisterSpec for SYST_CSR_SPEC {
104    type Ux = u32;
105}
106#[doc = "`read()` method returns [`syst_csr::R`](R) reader structure"]
107impl crate::Readable for SYST_CSR_SPEC {}
108#[doc = "`write(|w| ..)` method takes [`syst_csr::W`](W) writer structure"]
109impl crate::Writable for SYST_CSR_SPEC {
110    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
111    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
112}
113#[doc = "`reset()` method sets SYST_CSR to value 0"]
114impl crate::Resettable for SYST_CSR_SPEC {
115    const RESET_VALUE: u32 = 0;
116}