xmc4200/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 = "Enable\n\nValue on reset: 0"]
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7pub enum ENABLE_A {
8    #[doc = "0: counter disabled"]
9    VALUE1 = 0,
10    #[doc = "1: counter enabled."]
11    VALUE2 = 1,
12}
13impl From<ENABLE_A> for bool {
14    #[inline(always)]
15    fn from(variant: ENABLE_A) -> Self {
16        variant as u8 != 0
17    }
18}
19#[doc = "Field `ENABLE` reader - Enable"]
20pub type ENABLE_R = crate::BitReader<ENABLE_A>;
21impl ENABLE_R {
22    #[doc = "Get enumerated values variant"]
23    #[inline(always)]
24    pub const fn variant(&self) -> ENABLE_A {
25        match self.bits {
26            false => ENABLE_A::VALUE1,
27            true => ENABLE_A::VALUE2,
28        }
29    }
30    #[doc = "counter disabled"]
31    #[inline(always)]
32    pub fn is_value1(&self) -> bool {
33        *self == ENABLE_A::VALUE1
34    }
35    #[doc = "counter enabled."]
36    #[inline(always)]
37    pub fn is_value2(&self) -> bool {
38        *self == ENABLE_A::VALUE2
39    }
40}
41#[doc = "Field `ENABLE` writer - Enable"]
42pub type ENABLE_W<'a, REG> = crate::BitWriter<'a, REG, ENABLE_A>;
43impl<'a, REG> ENABLE_W<'a, REG>
44where
45    REG: crate::Writable + crate::RegisterSpec,
46{
47    #[doc = "counter disabled"]
48    #[inline(always)]
49    pub fn value1(self) -> &'a mut crate::W<REG> {
50        self.variant(ENABLE_A::VALUE1)
51    }
52    #[doc = "counter enabled."]
53    #[inline(always)]
54    pub fn value2(self) -> &'a mut crate::W<REG> {
55        self.variant(ENABLE_A::VALUE2)
56    }
57}
58#[doc = "Tick Interrupt Enable\n\nValue on reset: 0"]
59#[derive(Clone, Copy, Debug, PartialEq, Eq)]
60pub enum TICKINT_A {
61    #[doc = "0: counting down to zero does not assert the SysTick exception request"]
62    VALUE1 = 0,
63    #[doc = "1: counting down to zero to asserts the SysTick exception request."]
64    VALUE2 = 1,
65}
66impl From<TICKINT_A> for bool {
67    #[inline(always)]
68    fn from(variant: TICKINT_A) -> Self {
69        variant as u8 != 0
70    }
71}
72#[doc = "Field `TICKINT` reader - Tick Interrupt Enable"]
73pub type TICKINT_R = crate::BitReader<TICKINT_A>;
74impl TICKINT_R {
75    #[doc = "Get enumerated values variant"]
76    #[inline(always)]
77    pub const fn variant(&self) -> TICKINT_A {
78        match self.bits {
79            false => TICKINT_A::VALUE1,
80            true => TICKINT_A::VALUE2,
81        }
82    }
83    #[doc = "counting down to zero does not assert the SysTick exception request"]
84    #[inline(always)]
85    pub fn is_value1(&self) -> bool {
86        *self == TICKINT_A::VALUE1
87    }
88    #[doc = "counting down to zero to asserts the SysTick exception request."]
89    #[inline(always)]
90    pub fn is_value2(&self) -> bool {
91        *self == TICKINT_A::VALUE2
92    }
93}
94#[doc = "Field `TICKINT` writer - Tick Interrupt Enable"]
95pub type TICKINT_W<'a, REG> = crate::BitWriter<'a, REG, TICKINT_A>;
96impl<'a, REG> TICKINT_W<'a, REG>
97where
98    REG: crate::Writable + crate::RegisterSpec,
99{
100    #[doc = "counting down to zero does not assert the SysTick exception request"]
101    #[inline(always)]
102    pub fn value1(self) -> &'a mut crate::W<REG> {
103        self.variant(TICKINT_A::VALUE1)
104    }
105    #[doc = "counting down to zero to asserts the SysTick exception request."]
106    #[inline(always)]
107    pub fn value2(self) -> &'a mut crate::W<REG> {
108        self.variant(TICKINT_A::VALUE2)
109    }
110}
111#[doc = "Indicates the clock source:\n\nValue on reset: 1"]
112#[derive(Clone, Copy, Debug, PartialEq, Eq)]
113pub enum CLKSOURCE_A {
114    #[doc = "0: external clock"]
115    VALUE1 = 0,
116    #[doc = "1: processor clock."]
117    VALUE2 = 1,
118}
119impl From<CLKSOURCE_A> for bool {
120    #[inline(always)]
121    fn from(variant: CLKSOURCE_A) -> Self {
122        variant as u8 != 0
123    }
124}
125#[doc = "Field `CLKSOURCE` reader - Indicates the clock source:"]
126pub type CLKSOURCE_R = crate::BitReader<CLKSOURCE_A>;
127impl CLKSOURCE_R {
128    #[doc = "Get enumerated values variant"]
129    #[inline(always)]
130    pub const fn variant(&self) -> CLKSOURCE_A {
131        match self.bits {
132            false => CLKSOURCE_A::VALUE1,
133            true => CLKSOURCE_A::VALUE2,
134        }
135    }
136    #[doc = "external clock"]
137    #[inline(always)]
138    pub fn is_value1(&self) -> bool {
139        *self == CLKSOURCE_A::VALUE1
140    }
141    #[doc = "processor clock."]
142    #[inline(always)]
143    pub fn is_value2(&self) -> bool {
144        *self == CLKSOURCE_A::VALUE2
145    }
146}
147#[doc = "Field `CLKSOURCE` writer - Indicates the clock source:"]
148pub type CLKSOURCE_W<'a, REG> = crate::BitWriter<'a, REG, CLKSOURCE_A>;
149impl<'a, REG> CLKSOURCE_W<'a, REG>
150where
151    REG: crate::Writable + crate::RegisterSpec,
152{
153    #[doc = "external clock"]
154    #[inline(always)]
155    pub fn value1(self) -> &'a mut crate::W<REG> {
156        self.variant(CLKSOURCE_A::VALUE1)
157    }
158    #[doc = "processor clock."]
159    #[inline(always)]
160    pub fn value2(self) -> &'a mut crate::W<REG> {
161        self.variant(CLKSOURCE_A::VALUE2)
162    }
163}
164#[doc = "Field `COUNTFLAG` reader - Counter Flag"]
165pub type COUNTFLAG_R = crate::BitReader;
166#[doc = "Field `COUNTFLAG` writer - Counter Flag"]
167pub type COUNTFLAG_W<'a, REG> = crate::BitWriter<'a, REG>;
168impl R {
169    #[doc = "Bit 0 - Enable"]
170    #[inline(always)]
171    pub fn enable(&self) -> ENABLE_R {
172        ENABLE_R::new((self.bits & 1) != 0)
173    }
174    #[doc = "Bit 1 - Tick Interrupt Enable"]
175    #[inline(always)]
176    pub fn tickint(&self) -> TICKINT_R {
177        TICKINT_R::new(((self.bits >> 1) & 1) != 0)
178    }
179    #[doc = "Bit 2 - Indicates the clock source:"]
180    #[inline(always)]
181    pub fn clksource(&self) -> CLKSOURCE_R {
182        CLKSOURCE_R::new(((self.bits >> 2) & 1) != 0)
183    }
184    #[doc = "Bit 16 - Counter Flag"]
185    #[inline(always)]
186    pub fn countflag(&self) -> COUNTFLAG_R {
187        COUNTFLAG_R::new(((self.bits >> 16) & 1) != 0)
188    }
189}
190impl W {
191    #[doc = "Bit 0 - Enable"]
192    #[inline(always)]
193    pub fn enable(&mut self) -> ENABLE_W<SYST_CSR_SPEC> {
194        ENABLE_W::new(self, 0)
195    }
196    #[doc = "Bit 1 - Tick Interrupt Enable"]
197    #[inline(always)]
198    pub fn tickint(&mut self) -> TICKINT_W<SYST_CSR_SPEC> {
199        TICKINT_W::new(self, 1)
200    }
201    #[doc = "Bit 2 - Indicates the clock source:"]
202    #[inline(always)]
203    pub fn clksource(&mut self) -> CLKSOURCE_W<SYST_CSR_SPEC> {
204        CLKSOURCE_W::new(self, 2)
205    }
206    #[doc = "Bit 16 - Counter Flag"]
207    #[inline(always)]
208    pub fn countflag(&mut self) -> COUNTFLAG_W<SYST_CSR_SPEC> {
209        COUNTFLAG_W::new(self, 16)
210    }
211}
212#[doc = "SysTick Control and Status Register\n\nYou can [`read`](crate::Reg::read) this register and get [`syst_csr::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`syst_csr::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
213pub struct SYST_CSR_SPEC;
214impl crate::RegisterSpec for SYST_CSR_SPEC {
215    type Ux = u32;
216}
217#[doc = "`read()` method returns [`syst_csr::R`](R) reader structure"]
218impl crate::Readable for SYST_CSR_SPEC {}
219#[doc = "`write(|w| ..)` method takes [`syst_csr::W`](W) writer structure"]
220impl crate::Writable for SYST_CSR_SPEC {
221    type Safety = crate::Unsafe;
222    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
223    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
224}
225#[doc = "`reset()` method sets SYST_CSR to value 0x04"]
226impl crate::Resettable for SYST_CSR_SPEC {
227    const RESET_VALUE: u32 = 0x04;
228}