atsamd51j19a/dmac/
crcctrl.rs1#[doc = "Reader of register CRCCTRL"]
2pub type R = crate::R<u16, super::CRCCTRL>;
3#[doc = "Writer for register CRCCTRL"]
4pub type W = crate::W<u16, super::CRCCTRL>;
5#[doc = "Register CRCCTRL `reset()`'s with value 0"]
6impl crate::ResetValue for super::CRCCTRL {
7 type Type = u16;
8 #[inline(always)]
9 fn reset_value() -> Self::Type {
10 0
11 }
12}
13#[doc = "CRC Beat Size\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15#[repr(u8)]
16pub enum CRCBEATSIZE_A {
17 #[doc = "0: 8-bit bus transfer"]
18 BYTE = 0,
19 #[doc = "1: 16-bit bus transfer"]
20 HWORD = 1,
21 #[doc = "2: 32-bit bus transfer"]
22 WORD = 2,
23}
24impl From<CRCBEATSIZE_A> for u8 {
25 #[inline(always)]
26 fn from(variant: CRCBEATSIZE_A) -> Self {
27 variant as _
28 }
29}
30#[doc = "Reader of field `CRCBEATSIZE`"]
31pub type CRCBEATSIZE_R = crate::R<u8, CRCBEATSIZE_A>;
32impl CRCBEATSIZE_R {
33 #[doc = r"Get enumerated values variant"]
34 #[inline(always)]
35 pub fn variant(&self) -> crate::Variant<u8, CRCBEATSIZE_A> {
36 use crate::Variant::*;
37 match self.bits {
38 0 => Val(CRCBEATSIZE_A::BYTE),
39 1 => Val(CRCBEATSIZE_A::HWORD),
40 2 => Val(CRCBEATSIZE_A::WORD),
41 i => Res(i),
42 }
43 }
44 #[doc = "Checks if the value of the field is `BYTE`"]
45 #[inline(always)]
46 pub fn is_byte(&self) -> bool {
47 *self == CRCBEATSIZE_A::BYTE
48 }
49 #[doc = "Checks if the value of the field is `HWORD`"]
50 #[inline(always)]
51 pub fn is_hword(&self) -> bool {
52 *self == CRCBEATSIZE_A::HWORD
53 }
54 #[doc = "Checks if the value of the field is `WORD`"]
55 #[inline(always)]
56 pub fn is_word(&self) -> bool {
57 *self == CRCBEATSIZE_A::WORD
58 }
59}
60#[doc = "Write proxy for field `CRCBEATSIZE`"]
61pub struct CRCBEATSIZE_W<'a> {
62 w: &'a mut W,
63}
64impl<'a> CRCBEATSIZE_W<'a> {
65 #[doc = r"Writes `variant` to the field"]
66 #[inline(always)]
67 pub fn variant(self, variant: CRCBEATSIZE_A) -> &'a mut W {
68 unsafe { self.bits(variant.into()) }
69 }
70 #[doc = "8-bit bus transfer"]
71 #[inline(always)]
72 pub fn byte(self) -> &'a mut W {
73 self.variant(CRCBEATSIZE_A::BYTE)
74 }
75 #[doc = "16-bit bus transfer"]
76 #[inline(always)]
77 pub fn hword(self) -> &'a mut W {
78 self.variant(CRCBEATSIZE_A::HWORD)
79 }
80 #[doc = "32-bit bus transfer"]
81 #[inline(always)]
82 pub fn word(self) -> &'a mut W {
83 self.variant(CRCBEATSIZE_A::WORD)
84 }
85 #[doc = r"Writes raw bits to the field"]
86 #[inline(always)]
87 pub unsafe fn bits(self, value: u8) -> &'a mut W {
88 self.w.bits = (self.w.bits & !0x03) | ((value as u16) & 0x03);
89 self.w
90 }
91}
92#[doc = "CRC Polynomial Type\n\nValue on reset: 0"]
93#[derive(Clone, Copy, Debug, PartialEq)]
94#[repr(u8)]
95pub enum CRCPOLY_A {
96 #[doc = "0: CRC-16 (CRC-CCITT)"]
97 CRC16 = 0,
98 #[doc = "1: CRC32 (IEEE 802.3)"]
99 CRC32 = 1,
100}
101impl From<CRCPOLY_A> for u8 {
102 #[inline(always)]
103 fn from(variant: CRCPOLY_A) -> Self {
104 variant as _
105 }
106}
107#[doc = "Reader of field `CRCPOLY`"]
108pub type CRCPOLY_R = crate::R<u8, CRCPOLY_A>;
109impl CRCPOLY_R {
110 #[doc = r"Get enumerated values variant"]
111 #[inline(always)]
112 pub fn variant(&self) -> crate::Variant<u8, CRCPOLY_A> {
113 use crate::Variant::*;
114 match self.bits {
115 0 => Val(CRCPOLY_A::CRC16),
116 1 => Val(CRCPOLY_A::CRC32),
117 i => Res(i),
118 }
119 }
120 #[doc = "Checks if the value of the field is `CRC16`"]
121 #[inline(always)]
122 pub fn is_crc16(&self) -> bool {
123 *self == CRCPOLY_A::CRC16
124 }
125 #[doc = "Checks if the value of the field is `CRC32`"]
126 #[inline(always)]
127 pub fn is_crc32(&self) -> bool {
128 *self == CRCPOLY_A::CRC32
129 }
130}
131#[doc = "Write proxy for field `CRCPOLY`"]
132pub struct CRCPOLY_W<'a> {
133 w: &'a mut W,
134}
135impl<'a> CRCPOLY_W<'a> {
136 #[doc = r"Writes `variant` to the field"]
137 #[inline(always)]
138 pub fn variant(self, variant: CRCPOLY_A) -> &'a mut W {
139 unsafe { self.bits(variant.into()) }
140 }
141 #[doc = "CRC-16 (CRC-CCITT)"]
142 #[inline(always)]
143 pub fn crc16(self) -> &'a mut W {
144 self.variant(CRCPOLY_A::CRC16)
145 }
146 #[doc = "CRC32 (IEEE 802.3)"]
147 #[inline(always)]
148 pub fn crc32(self) -> &'a mut W {
149 self.variant(CRCPOLY_A::CRC32)
150 }
151 #[doc = r"Writes raw bits to the field"]
152 #[inline(always)]
153 pub unsafe fn bits(self, value: u8) -> &'a mut W {
154 self.w.bits = (self.w.bits & !(0x03 << 2)) | (((value as u16) & 0x03) << 2);
155 self.w
156 }
157}
158#[doc = "CRC Input Source\n\nValue on reset: 0"]
159#[derive(Clone, Copy, Debug, PartialEq)]
160#[repr(u8)]
161pub enum CRCSRC_A {
162 #[doc = "0: CRC Disabled"]
163 DISABLE = 0,
164 #[doc = "1: I/O interface"]
165 IO = 1,
166}
167impl From<CRCSRC_A> for u8 {
168 #[inline(always)]
169 fn from(variant: CRCSRC_A) -> Self {
170 variant as _
171 }
172}
173#[doc = "Reader of field `CRCSRC`"]
174pub type CRCSRC_R = crate::R<u8, CRCSRC_A>;
175impl CRCSRC_R {
176 #[doc = r"Get enumerated values variant"]
177 #[inline(always)]
178 pub fn variant(&self) -> crate::Variant<u8, CRCSRC_A> {
179 use crate::Variant::*;
180 match self.bits {
181 0 => Val(CRCSRC_A::DISABLE),
182 1 => Val(CRCSRC_A::IO),
183 i => Res(i),
184 }
185 }
186 #[doc = "Checks if the value of the field is `DISABLE`"]
187 #[inline(always)]
188 pub fn is_disable(&self) -> bool {
189 *self == CRCSRC_A::DISABLE
190 }
191 #[doc = "Checks if the value of the field is `IO`"]
192 #[inline(always)]
193 pub fn is_io(&self) -> bool {
194 *self == CRCSRC_A::IO
195 }
196}
197#[doc = "Write proxy for field `CRCSRC`"]
198pub struct CRCSRC_W<'a> {
199 w: &'a mut W,
200}
201impl<'a> CRCSRC_W<'a> {
202 #[doc = r"Writes `variant` to the field"]
203 #[inline(always)]
204 pub fn variant(self, variant: CRCSRC_A) -> &'a mut W {
205 unsafe { self.bits(variant.into()) }
206 }
207 #[doc = "CRC Disabled"]
208 #[inline(always)]
209 pub fn disable(self) -> &'a mut W {
210 self.variant(CRCSRC_A::DISABLE)
211 }
212 #[doc = "I/O interface"]
213 #[inline(always)]
214 pub fn io(self) -> &'a mut W {
215 self.variant(CRCSRC_A::IO)
216 }
217 #[doc = r"Writes raw bits to the field"]
218 #[inline(always)]
219 pub unsafe fn bits(self, value: u8) -> &'a mut W {
220 self.w.bits = (self.w.bits & !(0x3f << 8)) | (((value as u16) & 0x3f) << 8);
221 self.w
222 }
223}
224#[doc = "CRC Operating Mode\n\nValue on reset: 0"]
225#[derive(Clone, Copy, Debug, PartialEq)]
226#[repr(u8)]
227pub enum CRCMODE_A {
228 #[doc = "0: Default operating mode"]
229 DEFAULT = 0,
230 #[doc = "2: Memory CRC monitor operating mode"]
231 CRCMON = 2,
232 #[doc = "3: Memory CRC generation operating mode"]
233 CRCGEN = 3,
234}
235impl From<CRCMODE_A> for u8 {
236 #[inline(always)]
237 fn from(variant: CRCMODE_A) -> Self {
238 variant as _
239 }
240}
241#[doc = "Reader of field `CRCMODE`"]
242pub type CRCMODE_R = crate::R<u8, CRCMODE_A>;
243impl CRCMODE_R {
244 #[doc = r"Get enumerated values variant"]
245 #[inline(always)]
246 pub fn variant(&self) -> crate::Variant<u8, CRCMODE_A> {
247 use crate::Variant::*;
248 match self.bits {
249 0 => Val(CRCMODE_A::DEFAULT),
250 2 => Val(CRCMODE_A::CRCMON),
251 3 => Val(CRCMODE_A::CRCGEN),
252 i => Res(i),
253 }
254 }
255 #[doc = "Checks if the value of the field is `DEFAULT`"]
256 #[inline(always)]
257 pub fn is_default(&self) -> bool {
258 *self == CRCMODE_A::DEFAULT
259 }
260 #[doc = "Checks if the value of the field is `CRCMON`"]
261 #[inline(always)]
262 pub fn is_crcmon(&self) -> bool {
263 *self == CRCMODE_A::CRCMON
264 }
265 #[doc = "Checks if the value of the field is `CRCGEN`"]
266 #[inline(always)]
267 pub fn is_crcgen(&self) -> bool {
268 *self == CRCMODE_A::CRCGEN
269 }
270}
271#[doc = "Write proxy for field `CRCMODE`"]
272pub struct CRCMODE_W<'a> {
273 w: &'a mut W,
274}
275impl<'a> CRCMODE_W<'a> {
276 #[doc = r"Writes `variant` to the field"]
277 #[inline(always)]
278 pub fn variant(self, variant: CRCMODE_A) -> &'a mut W {
279 unsafe { self.bits(variant.into()) }
280 }
281 #[doc = "Default operating mode"]
282 #[inline(always)]
283 pub fn default(self) -> &'a mut W {
284 self.variant(CRCMODE_A::DEFAULT)
285 }
286 #[doc = "Memory CRC monitor operating mode"]
287 #[inline(always)]
288 pub fn crcmon(self) -> &'a mut W {
289 self.variant(CRCMODE_A::CRCMON)
290 }
291 #[doc = "Memory CRC generation operating mode"]
292 #[inline(always)]
293 pub fn crcgen(self) -> &'a mut W {
294 self.variant(CRCMODE_A::CRCGEN)
295 }
296 #[doc = r"Writes raw bits to the field"]
297 #[inline(always)]
298 pub unsafe fn bits(self, value: u8) -> &'a mut W {
299 self.w.bits = (self.w.bits & !(0x03 << 14)) | (((value as u16) & 0x03) << 14);
300 self.w
301 }
302}
303impl R {
304 #[doc = "Bits 0:1 - CRC Beat Size"]
305 #[inline(always)]
306 pub fn crcbeatsize(&self) -> CRCBEATSIZE_R {
307 CRCBEATSIZE_R::new((self.bits & 0x03) as u8)
308 }
309 #[doc = "Bits 2:3 - CRC Polynomial Type"]
310 #[inline(always)]
311 pub fn crcpoly(&self) -> CRCPOLY_R {
312 CRCPOLY_R::new(((self.bits >> 2) & 0x03) as u8)
313 }
314 #[doc = "Bits 8:13 - CRC Input Source"]
315 #[inline(always)]
316 pub fn crcsrc(&self) -> CRCSRC_R {
317 CRCSRC_R::new(((self.bits >> 8) & 0x3f) as u8)
318 }
319 #[doc = "Bits 14:15 - CRC Operating Mode"]
320 #[inline(always)]
321 pub fn crcmode(&self) -> CRCMODE_R {
322 CRCMODE_R::new(((self.bits >> 14) & 0x03) as u8)
323 }
324}
325impl W {
326 #[doc = "Bits 0:1 - CRC Beat Size"]
327 #[inline(always)]
328 pub fn crcbeatsize(&mut self) -> CRCBEATSIZE_W {
329 CRCBEATSIZE_W { w: self }
330 }
331 #[doc = "Bits 2:3 - CRC Polynomial Type"]
332 #[inline(always)]
333 pub fn crcpoly(&mut self) -> CRCPOLY_W {
334 CRCPOLY_W { w: self }
335 }
336 #[doc = "Bits 8:13 - CRC Input Source"]
337 #[inline(always)]
338 pub fn crcsrc(&mut self) -> CRCSRC_W {
339 CRCSRC_W { w: self }
340 }
341 #[doc = "Bits 14:15 - CRC Operating Mode"]
342 #[inline(always)]
343 pub fn crcmode(&mut self) -> CRCMODE_W {
344 CRCMODE_W { w: self }
345 }
346}