ra2e1/crc/
crccr0.rs

1#[doc = "Register `CRCCR0` reader"]
2pub struct R(crate::R<CRCCR0_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CRCCR0_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CRCCR0_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CRCCR0_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `CRCCR0` writer"]
17pub struct W(crate::W<CRCCR0_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CRCCR0_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<CRCCR0_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CRCCR0_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `GPS` reader - CRC Generating Polynomial Switching"]
38pub type GPS_R = crate::FieldReader<u8, GPS_A>;
39#[doc = "CRC Generating Polynomial Switching\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum GPS_A {
43    #[doc = "1: 8-bit CRC-8 (X8 + X2 + X + 1)"]
44    _001 = 1,
45    #[doc = "2: 16-bit CRC-16 (X16 + X15 + X2 + 1)"]
46    _010 = 2,
47    #[doc = "3: 16-bit CRC-CCITT (X16 + X12 + X5 + 1)"]
48    _011 = 3,
49    #[doc = "4: 32-bit CRC-32 (X32 + X26 + X23 + X22 + X16 + X12 + X11 +X10 + X8 + X7 + X5 + X4 + X2 + X + 1)"]
50    _100 = 4,
51    #[doc = "5: 32-bit CRC-32C (X32 + X28 + X27 + X26 + X25 + X23 + X22 + X20 + X19 + X18 + X14 + X13 + X11 + X10 + X9 + X8 + X6 + 1)"]
52    _101 = 5,
53}
54impl From<GPS_A> for u8 {
55    #[inline(always)]
56    fn from(variant: GPS_A) -> Self {
57        variant as _
58    }
59}
60impl GPS_R {
61    #[doc = "Get enumerated values variant"]
62    #[inline(always)]
63    pub fn variant(&self) -> Option<GPS_A> {
64        match self.bits {
65            1 => Some(GPS_A::_001),
66            2 => Some(GPS_A::_010),
67            3 => Some(GPS_A::_011),
68            4 => Some(GPS_A::_100),
69            5 => Some(GPS_A::_101),
70            _ => None,
71        }
72    }
73    #[doc = "Checks if the value of the field is `_001`"]
74    #[inline(always)]
75    pub fn is_001(&self) -> bool {
76        *self == GPS_A::_001
77    }
78    #[doc = "Checks if the value of the field is `_010`"]
79    #[inline(always)]
80    pub fn is_010(&self) -> bool {
81        *self == GPS_A::_010
82    }
83    #[doc = "Checks if the value of the field is `_011`"]
84    #[inline(always)]
85    pub fn is_011(&self) -> bool {
86        *self == GPS_A::_011
87    }
88    #[doc = "Checks if the value of the field is `_100`"]
89    #[inline(always)]
90    pub fn is_100(&self) -> bool {
91        *self == GPS_A::_100
92    }
93    #[doc = "Checks if the value of the field is `_101`"]
94    #[inline(always)]
95    pub fn is_101(&self) -> bool {
96        *self == GPS_A::_101
97    }
98}
99#[doc = "Field `GPS` writer - CRC Generating Polynomial Switching"]
100pub type GPS_W<'a, const O: u8> = crate::FieldWriter<'a, u8, CRCCR0_SPEC, u8, GPS_A, 3, O>;
101impl<'a, const O: u8> GPS_W<'a, O> {
102    #[doc = "8-bit CRC-8 (X8 + X2 + X + 1)"]
103    #[inline(always)]
104    pub fn _001(self) -> &'a mut W {
105        self.variant(GPS_A::_001)
106    }
107    #[doc = "16-bit CRC-16 (X16 + X15 + X2 + 1)"]
108    #[inline(always)]
109    pub fn _010(self) -> &'a mut W {
110        self.variant(GPS_A::_010)
111    }
112    #[doc = "16-bit CRC-CCITT (X16 + X12 + X5 + 1)"]
113    #[inline(always)]
114    pub fn _011(self) -> &'a mut W {
115        self.variant(GPS_A::_011)
116    }
117    #[doc = "32-bit CRC-32 (X32 + X26 + X23 + X22 + X16 + X12 + X11 +X10 + X8 + X7 + X5 + X4 + X2 + X + 1)"]
118    #[inline(always)]
119    pub fn _100(self) -> &'a mut W {
120        self.variant(GPS_A::_100)
121    }
122    #[doc = "32-bit CRC-32C (X32 + X28 + X27 + X26 + X25 + X23 + X22 + X20 + X19 + X18 + X14 + X13 + X11 + X10 + X9 + X8 + X6 + 1)"]
123    #[inline(always)]
124    pub fn _101(self) -> &'a mut W {
125        self.variant(GPS_A::_101)
126    }
127}
128#[doc = "Field `LMS` reader - CRC Calculation Switching"]
129pub type LMS_R = crate::BitReader<LMS_A>;
130#[doc = "CRC Calculation Switching\n\nValue on reset: 0"]
131#[derive(Clone, Copy, Debug, PartialEq, Eq)]
132pub enum LMS_A {
133    #[doc = "0: Generate CRC code for LSB-first communication"]
134    _0 = 0,
135    #[doc = "1: Generate CRC code for MSB-first communication"]
136    _1 = 1,
137}
138impl From<LMS_A> for bool {
139    #[inline(always)]
140    fn from(variant: LMS_A) -> Self {
141        variant as u8 != 0
142    }
143}
144impl LMS_R {
145    #[doc = "Get enumerated values variant"]
146    #[inline(always)]
147    pub fn variant(&self) -> LMS_A {
148        match self.bits {
149            false => LMS_A::_0,
150            true => LMS_A::_1,
151        }
152    }
153    #[doc = "Checks if the value of the field is `_0`"]
154    #[inline(always)]
155    pub fn is_0(&self) -> bool {
156        *self == LMS_A::_0
157    }
158    #[doc = "Checks if the value of the field is `_1`"]
159    #[inline(always)]
160    pub fn is_1(&self) -> bool {
161        *self == LMS_A::_1
162    }
163}
164#[doc = "Field `LMS` writer - CRC Calculation Switching"]
165pub type LMS_W<'a, const O: u8> = crate::BitWriter<'a, u8, CRCCR0_SPEC, LMS_A, O>;
166impl<'a, const O: u8> LMS_W<'a, O> {
167    #[doc = "Generate CRC code for LSB-first communication"]
168    #[inline(always)]
169    pub fn _0(self) -> &'a mut W {
170        self.variant(LMS_A::_0)
171    }
172    #[doc = "Generate CRC code for MSB-first communication"]
173    #[inline(always)]
174    pub fn _1(self) -> &'a mut W {
175        self.variant(LMS_A::_1)
176    }
177}
178#[doc = "CRCDOR/CRCDOR_HA/CRCDOR_BY Register Clear\n\nValue on reset: 0"]
179#[derive(Clone, Copy, Debug, PartialEq, Eq)]
180pub enum DORCLR_AW {
181    #[doc = "0: No effect"]
182    _0 = 0,
183    #[doc = "1: Clear the CRCDOR/CRCDOR_HA/CRCDOR_BY register"]
184    _1 = 1,
185}
186impl From<DORCLR_AW> for bool {
187    #[inline(always)]
188    fn from(variant: DORCLR_AW) -> Self {
189        variant as u8 != 0
190    }
191}
192#[doc = "Field `DORCLR` writer - CRCDOR/CRCDOR_HA/CRCDOR_BY Register Clear"]
193pub type DORCLR_W<'a, const O: u8> = crate::BitWriter<'a, u8, CRCCR0_SPEC, DORCLR_AW, O>;
194impl<'a, const O: u8> DORCLR_W<'a, O> {
195    #[doc = "No effect"]
196    #[inline(always)]
197    pub fn _0(self) -> &'a mut W {
198        self.variant(DORCLR_AW::_0)
199    }
200    #[doc = "Clear the CRCDOR/CRCDOR_HA/CRCDOR_BY register"]
201    #[inline(always)]
202    pub fn _1(self) -> &'a mut W {
203        self.variant(DORCLR_AW::_1)
204    }
205}
206impl R {
207    #[doc = "Bits 0:2 - CRC Generating Polynomial Switching"]
208    #[inline(always)]
209    pub fn gps(&self) -> GPS_R {
210        GPS_R::new(self.bits & 7)
211    }
212    #[doc = "Bit 6 - CRC Calculation Switching"]
213    #[inline(always)]
214    pub fn lms(&self) -> LMS_R {
215        LMS_R::new(((self.bits >> 6) & 1) != 0)
216    }
217}
218impl W {
219    #[doc = "Bits 0:2 - CRC Generating Polynomial Switching"]
220    #[inline(always)]
221    #[must_use]
222    pub fn gps(&mut self) -> GPS_W<0> {
223        GPS_W::new(self)
224    }
225    #[doc = "Bit 6 - CRC Calculation Switching"]
226    #[inline(always)]
227    #[must_use]
228    pub fn lms(&mut self) -> LMS_W<6> {
229        LMS_W::new(self)
230    }
231    #[doc = "Bit 7 - CRCDOR/CRCDOR_HA/CRCDOR_BY Register Clear"]
232    #[inline(always)]
233    #[must_use]
234    pub fn dorclr(&mut self) -> DORCLR_W<7> {
235        DORCLR_W::new(self)
236    }
237    #[doc = "Writes raw bits to the register."]
238    #[inline(always)]
239    pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
240        self.0.bits(bits);
241        self
242    }
243}
244#[doc = "CRC Control Register 0\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 [crccr0](index.html) module"]
245pub struct CRCCR0_SPEC;
246impl crate::RegisterSpec for CRCCR0_SPEC {
247    type Ux = u8;
248}
249#[doc = "`read()` method returns [crccr0::R](R) reader structure"]
250impl crate::Readable for CRCCR0_SPEC {
251    type Reader = R;
252}
253#[doc = "`write(|w| ..)` method takes [crccr0::W](W) writer structure"]
254impl crate::Writable for CRCCR0_SPEC {
255    type Writer = W;
256    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
257    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
258}
259#[doc = "`reset()` method sets CRCCR0 to value 0"]
260impl crate::Resettable for CRCCR0_SPEC {
261    const RESET_VALUE: Self::Ux = 0;
262}