atsaml21e15b/dmac/
crcctrl.rs1#[doc = "Register `CRCCTRL` reader"]
2pub struct R(crate::R<CRCCTRL_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<CRCCTRL_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<CRCCTRL_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<CRCCTRL_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `CRCCTRL` writer"]
17pub struct W(crate::W<CRCCTRL_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<CRCCTRL_SPEC>;
20 #[inline(always)]
21 fn deref(&self) -> &Self::Target {
22 &self.0
23 }
24}
25impl core::ops::DerefMut for W {
26 #[inline(always)]
27 fn deref_mut(&mut self) -> &mut Self::Target {
28 &mut self.0
29 }
30}
31impl From<crate::W<CRCCTRL_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<CRCCTRL_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `CRCBEATSIZE` reader - CRC Beat Size"]
38pub type CRCBEATSIZE_R = crate::FieldReader<u8, CRCBEATSIZESELECT_A>;
39#[doc = "CRC Beat Size\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum CRCBEATSIZESELECT_A {
43 #[doc = "0: 8-bit bus transfer"]
44 BYTE = 0,
45 #[doc = "1: 16-bit bus transfer"]
46 HWORD = 1,
47 #[doc = "2: 32-bit bus transfer"]
48 WORD = 2,
49}
50impl From<CRCBEATSIZESELECT_A> for u8 {
51 #[inline(always)]
52 fn from(variant: CRCBEATSIZESELECT_A) -> Self {
53 variant as _
54 }
55}
56impl CRCBEATSIZE_R {
57 #[doc = "Get enumerated values variant"]
58 #[inline(always)]
59 pub fn variant(&self) -> Option<CRCBEATSIZESELECT_A> {
60 match self.bits {
61 0 => Some(CRCBEATSIZESELECT_A::BYTE),
62 1 => Some(CRCBEATSIZESELECT_A::HWORD),
63 2 => Some(CRCBEATSIZESELECT_A::WORD),
64 _ => None,
65 }
66 }
67 #[doc = "Checks if the value of the field is `BYTE`"]
68 #[inline(always)]
69 pub fn is_byte(&self) -> bool {
70 *self == CRCBEATSIZESELECT_A::BYTE
71 }
72 #[doc = "Checks if the value of the field is `HWORD`"]
73 #[inline(always)]
74 pub fn is_hword(&self) -> bool {
75 *self == CRCBEATSIZESELECT_A::HWORD
76 }
77 #[doc = "Checks if the value of the field is `WORD`"]
78 #[inline(always)]
79 pub fn is_word(&self) -> bool {
80 *self == CRCBEATSIZESELECT_A::WORD
81 }
82}
83#[doc = "Field `CRCBEATSIZE` writer - CRC Beat Size"]
84pub type CRCBEATSIZE_W<'a, const O: u8> =
85 crate::FieldWriter<'a, u16, CRCCTRL_SPEC, u8, CRCBEATSIZESELECT_A, 2, O>;
86impl<'a, const O: u8> CRCBEATSIZE_W<'a, O> {
87 #[doc = "8-bit bus transfer"]
88 #[inline(always)]
89 pub fn byte(self) -> &'a mut W {
90 self.variant(CRCBEATSIZESELECT_A::BYTE)
91 }
92 #[doc = "16-bit bus transfer"]
93 #[inline(always)]
94 pub fn hword(self) -> &'a mut W {
95 self.variant(CRCBEATSIZESELECT_A::HWORD)
96 }
97 #[doc = "32-bit bus transfer"]
98 #[inline(always)]
99 pub fn word(self) -> &'a mut W {
100 self.variant(CRCBEATSIZESELECT_A::WORD)
101 }
102}
103#[doc = "Field `CRCPOLY` reader - CRC Polynomial Type"]
104pub type CRCPOLY_R = crate::FieldReader<u8, CRCPOLYSELECT_A>;
105#[doc = "CRC Polynomial Type\n\nValue on reset: 0"]
106#[derive(Clone, Copy, Debug, PartialEq, Eq)]
107#[repr(u8)]
108pub enum CRCPOLYSELECT_A {
109 #[doc = "0: CRC-16 (CRC-CCITT)"]
110 CRC16 = 0,
111 #[doc = "1: CRC32 (IEEE 802.3)"]
112 CRC32 = 1,
113}
114impl From<CRCPOLYSELECT_A> for u8 {
115 #[inline(always)]
116 fn from(variant: CRCPOLYSELECT_A) -> Self {
117 variant as _
118 }
119}
120impl CRCPOLY_R {
121 #[doc = "Get enumerated values variant"]
122 #[inline(always)]
123 pub fn variant(&self) -> Option<CRCPOLYSELECT_A> {
124 match self.bits {
125 0 => Some(CRCPOLYSELECT_A::CRC16),
126 1 => Some(CRCPOLYSELECT_A::CRC32),
127 _ => None,
128 }
129 }
130 #[doc = "Checks if the value of the field is `CRC16`"]
131 #[inline(always)]
132 pub fn is_crc16(&self) -> bool {
133 *self == CRCPOLYSELECT_A::CRC16
134 }
135 #[doc = "Checks if the value of the field is `CRC32`"]
136 #[inline(always)]
137 pub fn is_crc32(&self) -> bool {
138 *self == CRCPOLYSELECT_A::CRC32
139 }
140}
141#[doc = "Field `CRCPOLY` writer - CRC Polynomial Type"]
142pub type CRCPOLY_W<'a, const O: u8> =
143 crate::FieldWriter<'a, u16, CRCCTRL_SPEC, u8, CRCPOLYSELECT_A, 2, O>;
144impl<'a, const O: u8> CRCPOLY_W<'a, O> {
145 #[doc = "CRC-16 (CRC-CCITT)"]
146 #[inline(always)]
147 pub fn crc16(self) -> &'a mut W {
148 self.variant(CRCPOLYSELECT_A::CRC16)
149 }
150 #[doc = "CRC32 (IEEE 802.3)"]
151 #[inline(always)]
152 pub fn crc32(self) -> &'a mut W {
153 self.variant(CRCPOLYSELECT_A::CRC32)
154 }
155}
156#[doc = "Field `CRCSRC` reader - CRC Input Source"]
157pub type CRCSRC_R = crate::FieldReader<u8, CRCSRCSELECT_A>;
158#[doc = "CRC Input Source\n\nValue on reset: 0"]
159#[derive(Clone, Copy, Debug, PartialEq, Eq)]
160#[repr(u8)]
161pub enum CRCSRCSELECT_A {
162 #[doc = "0: No action"]
163 NOACT = 0,
164 #[doc = "1: I/O interface"]
165 IO = 1,
166}
167impl From<CRCSRCSELECT_A> for u8 {
168 #[inline(always)]
169 fn from(variant: CRCSRCSELECT_A) -> Self {
170 variant as _
171 }
172}
173impl CRCSRC_R {
174 #[doc = "Get enumerated values variant"]
175 #[inline(always)]
176 pub fn variant(&self) -> Option<CRCSRCSELECT_A> {
177 match self.bits {
178 0 => Some(CRCSRCSELECT_A::NOACT),
179 1 => Some(CRCSRCSELECT_A::IO),
180 _ => None,
181 }
182 }
183 #[doc = "Checks if the value of the field is `NOACT`"]
184 #[inline(always)]
185 pub fn is_noact(&self) -> bool {
186 *self == CRCSRCSELECT_A::NOACT
187 }
188 #[doc = "Checks if the value of the field is `IO`"]
189 #[inline(always)]
190 pub fn is_io(&self) -> bool {
191 *self == CRCSRCSELECT_A::IO
192 }
193}
194#[doc = "Field `CRCSRC` writer - CRC Input Source"]
195pub type CRCSRC_W<'a, const O: u8> =
196 crate::FieldWriter<'a, u16, CRCCTRL_SPEC, u8, CRCSRCSELECT_A, 6, O>;
197impl<'a, const O: u8> CRCSRC_W<'a, O> {
198 #[doc = "No action"]
199 #[inline(always)]
200 pub fn noact(self) -> &'a mut W {
201 self.variant(CRCSRCSELECT_A::NOACT)
202 }
203 #[doc = "I/O interface"]
204 #[inline(always)]
205 pub fn io(self) -> &'a mut W {
206 self.variant(CRCSRCSELECT_A::IO)
207 }
208}
209impl R {
210 #[doc = "Bits 0:1 - CRC Beat Size"]
211 #[inline(always)]
212 pub fn crcbeatsize(&self) -> CRCBEATSIZE_R {
213 CRCBEATSIZE_R::new((self.bits & 3) as u8)
214 }
215 #[doc = "Bits 2:3 - CRC Polynomial Type"]
216 #[inline(always)]
217 pub fn crcpoly(&self) -> CRCPOLY_R {
218 CRCPOLY_R::new(((self.bits >> 2) & 3) as u8)
219 }
220 #[doc = "Bits 8:13 - CRC Input Source"]
221 #[inline(always)]
222 pub fn crcsrc(&self) -> CRCSRC_R {
223 CRCSRC_R::new(((self.bits >> 8) & 0x3f) as u8)
224 }
225}
226impl W {
227 #[doc = "Bits 0:1 - CRC Beat Size"]
228 #[inline(always)]
229 #[must_use]
230 pub fn crcbeatsize(&mut self) -> CRCBEATSIZE_W<0> {
231 CRCBEATSIZE_W::new(self)
232 }
233 #[doc = "Bits 2:3 - CRC Polynomial Type"]
234 #[inline(always)]
235 #[must_use]
236 pub fn crcpoly(&mut self) -> CRCPOLY_W<2> {
237 CRCPOLY_W::new(self)
238 }
239 #[doc = "Bits 8:13 - CRC Input Source"]
240 #[inline(always)]
241 #[must_use]
242 pub fn crcsrc(&mut self) -> CRCSRC_W<8> {
243 CRCSRC_W::new(self)
244 }
245 #[doc = "Writes raw bits to the register."]
246 #[inline(always)]
247 pub unsafe fn bits(&mut self, bits: u16) -> &mut Self {
248 self.0.bits(bits);
249 self
250 }
251}
252#[doc = "CRC Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [crcctrl](index.html) module"]
253pub struct CRCCTRL_SPEC;
254impl crate::RegisterSpec for CRCCTRL_SPEC {
255 type Ux = u16;
256}
257#[doc = "`read()` method returns [crcctrl::R](R) reader structure"]
258impl crate::Readable for CRCCTRL_SPEC {
259 type Reader = R;
260}
261#[doc = "`write(|w| ..)` method takes [crcctrl::W](W) writer structure"]
262impl crate::Writable for CRCCTRL_SPEC {
263 type Writer = W;
264 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
265 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
266}
267#[doc = "`reset()` method sets CRCCTRL to value 0"]
268impl crate::Resettable for CRCCTRL_SPEC {
269 const RESET_VALUE: Self::Ux = 0;
270}