mk66f18/can1/
cs10.rs

1#[doc = "Reader of register CS10"]
2pub type R = crate::R<u32, super::CS10>;
3#[doc = "Writer for register CS10"]
4pub type W = crate::W<u32, super::CS10>;
5#[doc = "Register CS10 `reset()`'s with value 0"]
6impl crate::ResetValue for super::CS10 {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Reader of field `TIME_STAMP`"]
14pub type TIME_STAMP_R = crate::R<u16, u16>;
15#[doc = "Write proxy for field `TIME_STAMP`"]
16pub struct TIME_STAMP_W<'a> {
17    w: &'a mut W,
18}
19impl<'a> TIME_STAMP_W<'a> {
20    #[doc = r"Writes raw bits to the field"]
21    #[inline(always)]
22    pub unsafe fn bits(self, value: u16) -> &'a mut W {
23        self.w.bits = (self.w.bits & !0xffff) | ((value as u32) & 0xffff);
24        self.w
25    }
26}
27#[doc = "Reader of field `DLC`"]
28pub type DLC_R = crate::R<u8, u8>;
29#[doc = "Write proxy for field `DLC`"]
30pub struct DLC_W<'a> {
31    w: &'a mut W,
32}
33impl<'a> DLC_W<'a> {
34    #[doc = r"Writes raw bits to the field"]
35    #[inline(always)]
36    pub unsafe fn bits(self, value: u8) -> &'a mut W {
37        self.w.bits = (self.w.bits & !(0x0f << 16)) | (((value as u32) & 0x0f) << 16);
38        self.w
39    }
40}
41#[doc = "Reader of field `RTR`"]
42pub type RTR_R = crate::R<bool, bool>;
43#[doc = "Write proxy for field `RTR`"]
44pub struct RTR_W<'a> {
45    w: &'a mut W,
46}
47impl<'a> RTR_W<'a> {
48    #[doc = r"Sets the field bit"]
49    #[inline(always)]
50    pub fn set_bit(self) -> &'a mut W {
51        self.bit(true)
52    }
53    #[doc = r"Clears the field bit"]
54    #[inline(always)]
55    pub fn clear_bit(self) -> &'a mut W {
56        self.bit(false)
57    }
58    #[doc = r"Writes raw bits to the field"]
59    #[inline(always)]
60    pub fn bit(self, value: bool) -> &'a mut W {
61        self.w.bits = (self.w.bits & !(0x01 << 20)) | (((value as u32) & 0x01) << 20);
62        self.w
63    }
64}
65#[doc = "Reader of field `IDE`"]
66pub type IDE_R = crate::R<bool, bool>;
67#[doc = "Write proxy for field `IDE`"]
68pub struct IDE_W<'a> {
69    w: &'a mut W,
70}
71impl<'a> IDE_W<'a> {
72    #[doc = r"Sets the field bit"]
73    #[inline(always)]
74    pub fn set_bit(self) -> &'a mut W {
75        self.bit(true)
76    }
77    #[doc = r"Clears the field bit"]
78    #[inline(always)]
79    pub fn clear_bit(self) -> &'a mut W {
80        self.bit(false)
81    }
82    #[doc = r"Writes raw bits to the field"]
83    #[inline(always)]
84    pub fn bit(self, value: bool) -> &'a mut W {
85        self.w.bits = (self.w.bits & !(0x01 << 21)) | (((value as u32) & 0x01) << 21);
86        self.w
87    }
88}
89#[doc = "Reader of field `SRR`"]
90pub type SRR_R = crate::R<bool, bool>;
91#[doc = "Write proxy for field `SRR`"]
92pub struct SRR_W<'a> {
93    w: &'a mut W,
94}
95impl<'a> SRR_W<'a> {
96    #[doc = r"Sets the field bit"]
97    #[inline(always)]
98    pub fn set_bit(self) -> &'a mut W {
99        self.bit(true)
100    }
101    #[doc = r"Clears the field bit"]
102    #[inline(always)]
103    pub fn clear_bit(self) -> &'a mut W {
104        self.bit(false)
105    }
106    #[doc = r"Writes raw bits to the field"]
107    #[inline(always)]
108    pub fn bit(self, value: bool) -> &'a mut W {
109        self.w.bits = (self.w.bits & !(0x01 << 22)) | (((value as u32) & 0x01) << 22);
110        self.w
111    }
112}
113#[doc = "Reader of field `CODE`"]
114pub type CODE_R = crate::R<u8, u8>;
115#[doc = "Write proxy for field `CODE`"]
116pub struct CODE_W<'a> {
117    w: &'a mut W,
118}
119impl<'a> CODE_W<'a> {
120    #[doc = r"Writes raw bits to the field"]
121    #[inline(always)]
122    pub unsafe fn bits(self, value: u8) -> &'a mut W {
123        self.w.bits = (self.w.bits & !(0x0f << 24)) | (((value as u32) & 0x0f) << 24);
124        self.w
125    }
126}
127impl R {
128    #[doc = "Bits 0:15 - Free-Running Counter Time stamp. This 16-bit field is a copy of the Free-Running Timer, captured for Tx and Rx frames at the time when the beginning of the Identifier field appears on the CAN bus."]
129    #[inline(always)]
130    pub fn time_stamp(&self) -> TIME_STAMP_R {
131        TIME_STAMP_R::new((self.bits & 0xffff) as u16)
132    }
133    #[doc = "Bits 16:19 - Length of the data to be stored/transmitted."]
134    #[inline(always)]
135    pub fn dlc(&self) -> DLC_R {
136        DLC_R::new(((self.bits >> 16) & 0x0f) as u8)
137    }
138    #[doc = "Bit 20 - Remote Transmission Request. One/zero for remote/data frame."]
139    #[inline(always)]
140    pub fn rtr(&self) -> RTR_R {
141        RTR_R::new(((self.bits >> 20) & 0x01) != 0)
142    }
143    #[doc = "Bit 21 - ID Extended. One/zero for extended/standard format frame."]
144    #[inline(always)]
145    pub fn ide(&self) -> IDE_R {
146        IDE_R::new(((self.bits >> 21) & 0x01) != 0)
147    }
148    #[doc = "Bit 22 - Substitute Remote Request. Contains a fixed recessive bit."]
149    #[inline(always)]
150    pub fn srr(&self) -> SRR_R {
151        SRR_R::new(((self.bits >> 22) & 0x01) != 0)
152    }
153    #[doc = "Bits 24:27 - Reserved"]
154    #[inline(always)]
155    pub fn code(&self) -> CODE_R {
156        CODE_R::new(((self.bits >> 24) & 0x0f) as u8)
157    }
158}
159impl W {
160    #[doc = "Bits 0:15 - Free-Running Counter Time stamp. This 16-bit field is a copy of the Free-Running Timer, captured for Tx and Rx frames at the time when the beginning of the Identifier field appears on the CAN bus."]
161    #[inline(always)]
162    pub fn time_stamp(&mut self) -> TIME_STAMP_W {
163        TIME_STAMP_W { w: self }
164    }
165    #[doc = "Bits 16:19 - Length of the data to be stored/transmitted."]
166    #[inline(always)]
167    pub fn dlc(&mut self) -> DLC_W {
168        DLC_W { w: self }
169    }
170    #[doc = "Bit 20 - Remote Transmission Request. One/zero for remote/data frame."]
171    #[inline(always)]
172    pub fn rtr(&mut self) -> RTR_W {
173        RTR_W { w: self }
174    }
175    #[doc = "Bit 21 - ID Extended. One/zero for extended/standard format frame."]
176    #[inline(always)]
177    pub fn ide(&mut self) -> IDE_W {
178        IDE_W { w: self }
179    }
180    #[doc = "Bit 22 - Substitute Remote Request. Contains a fixed recessive bit."]
181    #[inline(always)]
182    pub fn srr(&mut self) -> SRR_W {
183        SRR_W { w: self }
184    }
185    #[doc = "Bits 24:27 - Reserved"]
186    #[inline(always)]
187    pub fn code(&mut self) -> CODE_W {
188        CODE_W { w: self }
189    }
190}