xmc4100/can_node0/
nsr.rs

1#[doc = "Register `NSR` reader"]
2pub type R = crate::R<NSR_SPEC>;
3#[doc = "Register `NSR` writer"]
4pub type W = crate::W<NSR_SPEC>;
5#[doc = "Field `LEC` reader - Last Error Code"]
6pub type LEC_R = crate::FieldReader;
7#[doc = "Field `LEC` writer - Last Error Code"]
8pub type LEC_W<'a, REG> = crate::FieldWriter<'a, REG, 3>;
9#[doc = "Message Transmitted Successfully\n\nValue on reset: 0"]
10#[derive(Clone, Copy, Debug, PartialEq, Eq)]
11pub enum TXOK_A {
12    #[doc = "0: No successful transmission since last (most recent) flag reset."]
13    VALUE1 = 0,
14    #[doc = "1: A message has been transmitted successfully (error-free and acknowledged by at least another node)."]
15    VALUE2 = 1,
16}
17impl From<TXOK_A> for bool {
18    #[inline(always)]
19    fn from(variant: TXOK_A) -> Self {
20        variant as u8 != 0
21    }
22}
23#[doc = "Field `TXOK` reader - Message Transmitted Successfully"]
24pub type TXOK_R = crate::BitReader<TXOK_A>;
25impl TXOK_R {
26    #[doc = "Get enumerated values variant"]
27    #[inline(always)]
28    pub const fn variant(&self) -> TXOK_A {
29        match self.bits {
30            false => TXOK_A::VALUE1,
31            true => TXOK_A::VALUE2,
32        }
33    }
34    #[doc = "No successful transmission since last (most recent) flag reset."]
35    #[inline(always)]
36    pub fn is_value1(&self) -> bool {
37        *self == TXOK_A::VALUE1
38    }
39    #[doc = "A message has been transmitted successfully (error-free and acknowledged by at least another node)."]
40    #[inline(always)]
41    pub fn is_value2(&self) -> bool {
42        *self == TXOK_A::VALUE2
43    }
44}
45#[doc = "Field `TXOK` writer - Message Transmitted Successfully"]
46pub type TXOK_W<'a, REG> = crate::BitWriter<'a, REG, TXOK_A>;
47impl<'a, REG> TXOK_W<'a, REG>
48where
49    REG: crate::Writable + crate::RegisterSpec,
50{
51    #[doc = "No successful transmission since last (most recent) flag reset."]
52    #[inline(always)]
53    pub fn value1(self) -> &'a mut crate::W<REG> {
54        self.variant(TXOK_A::VALUE1)
55    }
56    #[doc = "A message has been transmitted successfully (error-free and acknowledged by at least another node)."]
57    #[inline(always)]
58    pub fn value2(self) -> &'a mut crate::W<REG> {
59        self.variant(TXOK_A::VALUE2)
60    }
61}
62#[doc = "Message Received Successfully\n\nValue on reset: 0"]
63#[derive(Clone, Copy, Debug, PartialEq, Eq)]
64pub enum RXOK_A {
65    #[doc = "0: No successful reception since last (most recent) flag reset."]
66    VALUE1 = 0,
67    #[doc = "1: A message has been received successfully."]
68    VALUE2 = 1,
69}
70impl From<RXOK_A> for bool {
71    #[inline(always)]
72    fn from(variant: RXOK_A) -> Self {
73        variant as u8 != 0
74    }
75}
76#[doc = "Field `RXOK` reader - Message Received Successfully"]
77pub type RXOK_R = crate::BitReader<RXOK_A>;
78impl RXOK_R {
79    #[doc = "Get enumerated values variant"]
80    #[inline(always)]
81    pub const fn variant(&self) -> RXOK_A {
82        match self.bits {
83            false => RXOK_A::VALUE1,
84            true => RXOK_A::VALUE2,
85        }
86    }
87    #[doc = "No successful reception since last (most recent) flag reset."]
88    #[inline(always)]
89    pub fn is_value1(&self) -> bool {
90        *self == RXOK_A::VALUE1
91    }
92    #[doc = "A message has been received successfully."]
93    #[inline(always)]
94    pub fn is_value2(&self) -> bool {
95        *self == RXOK_A::VALUE2
96    }
97}
98#[doc = "Field `RXOK` writer - Message Received Successfully"]
99pub type RXOK_W<'a, REG> = crate::BitWriter<'a, REG, RXOK_A>;
100impl<'a, REG> RXOK_W<'a, REG>
101where
102    REG: crate::Writable + crate::RegisterSpec,
103{
104    #[doc = "No successful reception since last (most recent) flag reset."]
105    #[inline(always)]
106    pub fn value1(self) -> &'a mut crate::W<REG> {
107        self.variant(RXOK_A::VALUE1)
108    }
109    #[doc = "A message has been received successfully."]
110    #[inline(always)]
111    pub fn value2(self) -> &'a mut crate::W<REG> {
112        self.variant(RXOK_A::VALUE2)
113    }
114}
115#[doc = "Field `ALERT` reader - Alert Warning"]
116pub type ALERT_R = crate::BitReader;
117#[doc = "Field `ALERT` writer - Alert Warning"]
118pub type ALERT_W<'a, REG> = crate::BitWriter<'a, REG>;
119#[doc = "Error Warning Status\n\nValue on reset: 0"]
120#[derive(Clone, Copy, Debug, PartialEq, Eq)]
121pub enum EWRN_A {
122    #[doc = "0: No warning limit exceeded."]
123    VALUE1 = 0,
124    #[doc = "1: One of the error counters REC or TEC reached the warning limit EWRNLVL."]
125    VALUE2 = 1,
126}
127impl From<EWRN_A> for bool {
128    #[inline(always)]
129    fn from(variant: EWRN_A) -> Self {
130        variant as u8 != 0
131    }
132}
133#[doc = "Field `EWRN` reader - Error Warning Status"]
134pub type EWRN_R = crate::BitReader<EWRN_A>;
135impl EWRN_R {
136    #[doc = "Get enumerated values variant"]
137    #[inline(always)]
138    pub const fn variant(&self) -> EWRN_A {
139        match self.bits {
140            false => EWRN_A::VALUE1,
141            true => EWRN_A::VALUE2,
142        }
143    }
144    #[doc = "No warning limit exceeded."]
145    #[inline(always)]
146    pub fn is_value1(&self) -> bool {
147        *self == EWRN_A::VALUE1
148    }
149    #[doc = "One of the error counters REC or TEC reached the warning limit EWRNLVL."]
150    #[inline(always)]
151    pub fn is_value2(&self) -> bool {
152        *self == EWRN_A::VALUE2
153    }
154}
155#[doc = "Bus-off Status\n\nValue on reset: 0"]
156#[derive(Clone, Copy, Debug, PartialEq, Eq)]
157pub enum BOFF_A {
158    #[doc = "0: CAN controller is not in the bus-off state."]
159    VALUE1 = 0,
160    #[doc = "1: CAN controller is in the bus-off state."]
161    VALUE2 = 1,
162}
163impl From<BOFF_A> for bool {
164    #[inline(always)]
165    fn from(variant: BOFF_A) -> Self {
166        variant as u8 != 0
167    }
168}
169#[doc = "Field `BOFF` reader - Bus-off Status"]
170pub type BOFF_R = crate::BitReader<BOFF_A>;
171impl BOFF_R {
172    #[doc = "Get enumerated values variant"]
173    #[inline(always)]
174    pub const fn variant(&self) -> BOFF_A {
175        match self.bits {
176            false => BOFF_A::VALUE1,
177            true => BOFF_A::VALUE2,
178        }
179    }
180    #[doc = "CAN controller is not in the bus-off state."]
181    #[inline(always)]
182    pub fn is_value1(&self) -> bool {
183        *self == BOFF_A::VALUE1
184    }
185    #[doc = "CAN controller is in the bus-off state."]
186    #[inline(always)]
187    pub fn is_value2(&self) -> bool {
188        *self == BOFF_A::VALUE2
189    }
190}
191#[doc = "List Length Error\n\nValue on reset: 0"]
192#[derive(Clone, Copy, Debug, PartialEq, Eq)]
193pub enum LLE_A {
194    #[doc = "0: No List Length Error since last (most recent) flag reset."]
195    VALUE1 = 0,
196    #[doc = "1: A List Length Error has been detected during message acceptance filtering. The number of elements in the list that belongs to this CAN node differs from the list SIZE given in the list termination pointer."]
197    VALUE2 = 1,
198}
199impl From<LLE_A> for bool {
200    #[inline(always)]
201    fn from(variant: LLE_A) -> Self {
202        variant as u8 != 0
203    }
204}
205#[doc = "Field `LLE` reader - List Length Error"]
206pub type LLE_R = crate::BitReader<LLE_A>;
207impl LLE_R {
208    #[doc = "Get enumerated values variant"]
209    #[inline(always)]
210    pub const fn variant(&self) -> LLE_A {
211        match self.bits {
212            false => LLE_A::VALUE1,
213            true => LLE_A::VALUE2,
214        }
215    }
216    #[doc = "No List Length Error since last (most recent) flag reset."]
217    #[inline(always)]
218    pub fn is_value1(&self) -> bool {
219        *self == LLE_A::VALUE1
220    }
221    #[doc = "A List Length Error has been detected during message acceptance filtering. The number of elements in the list that belongs to this CAN node differs from the list SIZE given in the list termination pointer."]
222    #[inline(always)]
223    pub fn is_value2(&self) -> bool {
224        *self == LLE_A::VALUE2
225    }
226}
227#[doc = "Field `LLE` writer - List Length Error"]
228pub type LLE_W<'a, REG> = crate::BitWriter<'a, REG, LLE_A>;
229impl<'a, REG> LLE_W<'a, REG>
230where
231    REG: crate::Writable + crate::RegisterSpec,
232{
233    #[doc = "No List Length Error since last (most recent) flag reset."]
234    #[inline(always)]
235    pub fn value1(self) -> &'a mut crate::W<REG> {
236        self.variant(LLE_A::VALUE1)
237    }
238    #[doc = "A List Length Error has been detected during message acceptance filtering. The number of elements in the list that belongs to this CAN node differs from the list SIZE given in the list termination pointer."]
239    #[inline(always)]
240    pub fn value2(self) -> &'a mut crate::W<REG> {
241        self.variant(LLE_A::VALUE2)
242    }
243}
244#[doc = "List Object Error\n\nValue on reset: 0"]
245#[derive(Clone, Copy, Debug, PartialEq, Eq)]
246pub enum LOE_A {
247    #[doc = "0: No List Object Error since last (most recent) flag reset."]
248    VALUE1 = 0,
249    #[doc = "1: A List Object Error has been detected during message acceptance filtering. A message object with wrong LIST index entry in the Message Object Control Register has been detected."]
250    VALUE2 = 1,
251}
252impl From<LOE_A> for bool {
253    #[inline(always)]
254    fn from(variant: LOE_A) -> Self {
255        variant as u8 != 0
256    }
257}
258#[doc = "Field `LOE` reader - List Object Error"]
259pub type LOE_R = crate::BitReader<LOE_A>;
260impl LOE_R {
261    #[doc = "Get enumerated values variant"]
262    #[inline(always)]
263    pub const fn variant(&self) -> LOE_A {
264        match self.bits {
265            false => LOE_A::VALUE1,
266            true => LOE_A::VALUE2,
267        }
268    }
269    #[doc = "No List Object Error since last (most recent) flag reset."]
270    #[inline(always)]
271    pub fn is_value1(&self) -> bool {
272        *self == LOE_A::VALUE1
273    }
274    #[doc = "A List Object Error has been detected during message acceptance filtering. A message object with wrong LIST index entry in the Message Object Control Register has been detected."]
275    #[inline(always)]
276    pub fn is_value2(&self) -> bool {
277        *self == LOE_A::VALUE2
278    }
279}
280#[doc = "Field `LOE` writer - List Object Error"]
281pub type LOE_W<'a, REG> = crate::BitWriter<'a, REG, LOE_A>;
282impl<'a, REG> LOE_W<'a, REG>
283where
284    REG: crate::Writable + crate::RegisterSpec,
285{
286    #[doc = "No List Object Error since last (most recent) flag reset."]
287    #[inline(always)]
288    pub fn value1(self) -> &'a mut crate::W<REG> {
289        self.variant(LOE_A::VALUE1)
290    }
291    #[doc = "A List Object Error has been detected during message acceptance filtering. A message object with wrong LIST index entry in the Message Object Control Register has been detected."]
292    #[inline(always)]
293    pub fn value2(self) -> &'a mut crate::W<REG> {
294        self.variant(LOE_A::VALUE2)
295    }
296}
297#[doc = "Suspend Acknowledge\n\nValue on reset: 0"]
298#[derive(Clone, Copy, Debug, PartialEq, Eq)]
299pub enum SUSACK_A {
300    #[doc = "0: The CAN node is not in Suspend Mode or a suspend request is pending, but the CAN node has not yet reached bus-idle or bus-off."]
301    VALUE1 = 0,
302    #[doc = "1: The CAN node is in Suspend Mode: The CAN node is inactive (bit NCR.INIT internally forced to 1) due to an OCDS suspend request."]
303    VALUE2 = 1,
304}
305impl From<SUSACK_A> for bool {
306    #[inline(always)]
307    fn from(variant: SUSACK_A) -> Self {
308        variant as u8 != 0
309    }
310}
311#[doc = "Field `SUSACK` reader - Suspend Acknowledge"]
312pub type SUSACK_R = crate::BitReader<SUSACK_A>;
313impl SUSACK_R {
314    #[doc = "Get enumerated values variant"]
315    #[inline(always)]
316    pub const fn variant(&self) -> SUSACK_A {
317        match self.bits {
318            false => SUSACK_A::VALUE1,
319            true => SUSACK_A::VALUE2,
320        }
321    }
322    #[doc = "The CAN node is not in Suspend Mode or a suspend request is pending, but the CAN node has not yet reached bus-idle or bus-off."]
323    #[inline(always)]
324    pub fn is_value1(&self) -> bool {
325        *self == SUSACK_A::VALUE1
326    }
327    #[doc = "The CAN node is in Suspend Mode: The CAN node is inactive (bit NCR.INIT internally forced to 1) due to an OCDS suspend request."]
328    #[inline(always)]
329    pub fn is_value2(&self) -> bool {
330        *self == SUSACK_A::VALUE2
331    }
332}
333impl R {
334    #[doc = "Bits 0:2 - Last Error Code"]
335    #[inline(always)]
336    pub fn lec(&self) -> LEC_R {
337        LEC_R::new((self.bits & 7) as u8)
338    }
339    #[doc = "Bit 3 - Message Transmitted Successfully"]
340    #[inline(always)]
341    pub fn txok(&self) -> TXOK_R {
342        TXOK_R::new(((self.bits >> 3) & 1) != 0)
343    }
344    #[doc = "Bit 4 - Message Received Successfully"]
345    #[inline(always)]
346    pub fn rxok(&self) -> RXOK_R {
347        RXOK_R::new(((self.bits >> 4) & 1) != 0)
348    }
349    #[doc = "Bit 5 - Alert Warning"]
350    #[inline(always)]
351    pub fn alert(&self) -> ALERT_R {
352        ALERT_R::new(((self.bits >> 5) & 1) != 0)
353    }
354    #[doc = "Bit 6 - Error Warning Status"]
355    #[inline(always)]
356    pub fn ewrn(&self) -> EWRN_R {
357        EWRN_R::new(((self.bits >> 6) & 1) != 0)
358    }
359    #[doc = "Bit 7 - Bus-off Status"]
360    #[inline(always)]
361    pub fn boff(&self) -> BOFF_R {
362        BOFF_R::new(((self.bits >> 7) & 1) != 0)
363    }
364    #[doc = "Bit 8 - List Length Error"]
365    #[inline(always)]
366    pub fn lle(&self) -> LLE_R {
367        LLE_R::new(((self.bits >> 8) & 1) != 0)
368    }
369    #[doc = "Bit 9 - List Object Error"]
370    #[inline(always)]
371    pub fn loe(&self) -> LOE_R {
372        LOE_R::new(((self.bits >> 9) & 1) != 0)
373    }
374    #[doc = "Bit 10 - Suspend Acknowledge"]
375    #[inline(always)]
376    pub fn susack(&self) -> SUSACK_R {
377        SUSACK_R::new(((self.bits >> 10) & 1) != 0)
378    }
379}
380impl W {
381    #[doc = "Bits 0:2 - Last Error Code"]
382    #[inline(always)]
383    pub fn lec(&mut self) -> LEC_W<NSR_SPEC> {
384        LEC_W::new(self, 0)
385    }
386    #[doc = "Bit 3 - Message Transmitted Successfully"]
387    #[inline(always)]
388    pub fn txok(&mut self) -> TXOK_W<NSR_SPEC> {
389        TXOK_W::new(self, 3)
390    }
391    #[doc = "Bit 4 - Message Received Successfully"]
392    #[inline(always)]
393    pub fn rxok(&mut self) -> RXOK_W<NSR_SPEC> {
394        RXOK_W::new(self, 4)
395    }
396    #[doc = "Bit 5 - Alert Warning"]
397    #[inline(always)]
398    pub fn alert(&mut self) -> ALERT_W<NSR_SPEC> {
399        ALERT_W::new(self, 5)
400    }
401    #[doc = "Bit 8 - List Length Error"]
402    #[inline(always)]
403    pub fn lle(&mut self) -> LLE_W<NSR_SPEC> {
404        LLE_W::new(self, 8)
405    }
406    #[doc = "Bit 9 - List Object Error"]
407    #[inline(always)]
408    pub fn loe(&mut self) -> LOE_W<NSR_SPEC> {
409        LOE_W::new(self, 9)
410    }
411}
412#[doc = "Node Status Register\n\nYou can [`read`](crate::Reg::read) this register and get [`nsr::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`nsr::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
413pub struct NSR_SPEC;
414impl crate::RegisterSpec for NSR_SPEC {
415    type Ux = u32;
416}
417#[doc = "`read()` method returns [`nsr::R`](R) reader structure"]
418impl crate::Readable for NSR_SPEC {}
419#[doc = "`write(|w| ..)` method takes [`nsr::W`](W) writer structure"]
420impl crate::Writable for NSR_SPEC {
421    type Safety = crate::Unsafe;
422    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
423    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
424}
425#[doc = "`reset()` method sets NSR to value 0"]
426impl crate::Resettable for NSR_SPEC {
427    const RESET_VALUE: u32 = 0;
428}