at32f4xx_pac/at32f421/crc/
ctrl.rs

1#[doc = "Register `CTRL` reader"]
2pub type R = crate::R<CTRL_SPEC>;
3#[doc = "Register `CTRL` writer"]
4pub type W = crate::W<CTRL_SPEC>;
5#[doc = "Reset bit\n\nValue on reset: 0"]
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7pub enum RSTW_A {
8    #[doc = "1: Reset CRC calculation unit, the data register is set as 0xFFFF FFFF"]
9    Reset = 1,
10}
11impl From<RSTW_A> for bool {
12    #[inline(always)]
13    fn from(variant: RSTW_A) -> Self {
14        variant as u8 != 0
15    }
16}
17#[doc = "Field `RST` reader - Reset bit"]
18pub type RST_R = crate::BitReader<RSTW_A>;
19impl RST_R {
20    #[doc = "Get enumerated values variant"]
21    #[inline(always)]
22    pub const fn variant(&self) -> Option<RSTW_A> {
23        match self.bits {
24            true => Some(RSTW_A::Reset),
25            _ => None,
26        }
27    }
28    #[doc = "Reset CRC calculation unit, the data register is set as 0xFFFF FFFF"]
29    #[inline(always)]
30    pub fn is_reset(&self) -> bool {
31        *self == RSTW_A::Reset
32    }
33}
34#[doc = "Field `RST` writer - Reset bit"]
35pub type RST_W<'a, REG> = crate::BitWriter1S<'a, REG, RSTW_A>;
36impl<'a, REG> RST_W<'a, REG>
37where
38    REG: crate::Writable + crate::RegisterSpec,
39{
40    #[doc = "Reset CRC calculation unit, the data register is set as 0xFFFF FFFF"]
41    #[inline(always)]
42    pub fn reset(self) -> &'a mut crate::W<REG> {
43        self.variant(RSTW_A::Reset)
44    }
45}
46#[doc = "Polynomial size\n\nValue on reset: 0"]
47#[derive(Clone, Copy, Debug, PartialEq, Eq)]
48#[repr(u8)]
49pub enum POLY_SIZE_A {
50    #[doc = "0: 32 bits"]
51    Bits32 = 0,
52    #[doc = "1: 16 bits"]
53    Bits16 = 1,
54    #[doc = "2: 8 bits"]
55    Bits8 = 2,
56    #[doc = "3: 7 bits"]
57    Bits7 = 3,
58}
59impl From<POLY_SIZE_A> for u8 {
60    #[inline(always)]
61    fn from(variant: POLY_SIZE_A) -> Self {
62        variant as _
63    }
64}
65impl crate::FieldSpec for POLY_SIZE_A {
66    type Ux = u8;
67}
68impl crate::IsEnum for POLY_SIZE_A {}
69#[doc = "Field `POLY_SIZE` reader - Polynomial size"]
70pub type POLY_SIZE_R = crate::FieldReader<POLY_SIZE_A>;
71impl POLY_SIZE_R {
72    #[doc = "Get enumerated values variant"]
73    #[inline(always)]
74    pub const fn variant(&self) -> POLY_SIZE_A {
75        match self.bits {
76            0 => POLY_SIZE_A::Bits32,
77            1 => POLY_SIZE_A::Bits16,
78            2 => POLY_SIZE_A::Bits8,
79            3 => POLY_SIZE_A::Bits7,
80            _ => unreachable!(),
81        }
82    }
83    #[doc = "32 bits"]
84    #[inline(always)]
85    pub fn is_bits32(&self) -> bool {
86        *self == POLY_SIZE_A::Bits32
87    }
88    #[doc = "16 bits"]
89    #[inline(always)]
90    pub fn is_bits16(&self) -> bool {
91        *self == POLY_SIZE_A::Bits16
92    }
93    #[doc = "8 bits"]
94    #[inline(always)]
95    pub fn is_bits8(&self) -> bool {
96        *self == POLY_SIZE_A::Bits8
97    }
98    #[doc = "7 bits"]
99    #[inline(always)]
100    pub fn is_bits7(&self) -> bool {
101        *self == POLY_SIZE_A::Bits7
102    }
103}
104#[doc = "Field `POLY_SIZE` writer - Polynomial size"]
105pub type POLY_SIZE_W<'a, REG> = crate::FieldWriter<'a, REG, 2, POLY_SIZE_A, crate::Safe>;
106impl<'a, REG> POLY_SIZE_W<'a, REG>
107where
108    REG: crate::Writable + crate::RegisterSpec,
109    REG::Ux: From<u8>,
110{
111    #[doc = "32 bits"]
112    #[inline(always)]
113    pub fn bits32(self) -> &'a mut crate::W<REG> {
114        self.variant(POLY_SIZE_A::Bits32)
115    }
116    #[doc = "16 bits"]
117    #[inline(always)]
118    pub fn bits16(self) -> &'a mut crate::W<REG> {
119        self.variant(POLY_SIZE_A::Bits16)
120    }
121    #[doc = "8 bits"]
122    #[inline(always)]
123    pub fn bits8(self) -> &'a mut crate::W<REG> {
124        self.variant(POLY_SIZE_A::Bits8)
125    }
126    #[doc = "7 bits"]
127    #[inline(always)]
128    pub fn bits7(self) -> &'a mut crate::W<REG> {
129        self.variant(POLY_SIZE_A::Bits7)
130    }
131}
132#[doc = "Reverse input data\n\nValue on reset: 0"]
133#[derive(Clone, Copy, Debug, PartialEq, Eq)]
134#[repr(u8)]
135pub enum REVID_A {
136    #[doc = "0: No effect"]
137    NoEffect = 0,
138    #[doc = "1: Byte reverse"]
139    ByteReverse = 1,
140    #[doc = "2: Half-word reverse"]
141    HalfWordReverse = 2,
142    #[doc = "3: Word reverse"]
143    WordReverse = 3,
144}
145impl From<REVID_A> for u8 {
146    #[inline(always)]
147    fn from(variant: REVID_A) -> Self {
148        variant as _
149    }
150}
151impl crate::FieldSpec for REVID_A {
152    type Ux = u8;
153}
154impl crate::IsEnum for REVID_A {}
155#[doc = "Field `REVID` reader - Reverse input data"]
156pub type REVID_R = crate::FieldReader<REVID_A>;
157impl REVID_R {
158    #[doc = "Get enumerated values variant"]
159    #[inline(always)]
160    pub const fn variant(&self) -> REVID_A {
161        match self.bits {
162            0 => REVID_A::NoEffect,
163            1 => REVID_A::ByteReverse,
164            2 => REVID_A::HalfWordReverse,
165            3 => REVID_A::WordReverse,
166            _ => unreachable!(),
167        }
168    }
169    #[doc = "No effect"]
170    #[inline(always)]
171    pub fn is_no_effect(&self) -> bool {
172        *self == REVID_A::NoEffect
173    }
174    #[doc = "Byte reverse"]
175    #[inline(always)]
176    pub fn is_byte_reverse(&self) -> bool {
177        *self == REVID_A::ByteReverse
178    }
179    #[doc = "Half-word reverse"]
180    #[inline(always)]
181    pub fn is_half_word_reverse(&self) -> bool {
182        *self == REVID_A::HalfWordReverse
183    }
184    #[doc = "Word reverse"]
185    #[inline(always)]
186    pub fn is_word_reverse(&self) -> bool {
187        *self == REVID_A::WordReverse
188    }
189}
190#[doc = "Field `REVID` writer - Reverse input data"]
191pub type REVID_W<'a, REG> = crate::FieldWriter<'a, REG, 2, REVID_A, crate::Safe>;
192impl<'a, REG> REVID_W<'a, REG>
193where
194    REG: crate::Writable + crate::RegisterSpec,
195    REG::Ux: From<u8>,
196{
197    #[doc = "No effect"]
198    #[inline(always)]
199    pub fn no_effect(self) -> &'a mut crate::W<REG> {
200        self.variant(REVID_A::NoEffect)
201    }
202    #[doc = "Byte reverse"]
203    #[inline(always)]
204    pub fn byte_reverse(self) -> &'a mut crate::W<REG> {
205        self.variant(REVID_A::ByteReverse)
206    }
207    #[doc = "Half-word reverse"]
208    #[inline(always)]
209    pub fn half_word_reverse(self) -> &'a mut crate::W<REG> {
210        self.variant(REVID_A::HalfWordReverse)
211    }
212    #[doc = "Word reverse"]
213    #[inline(always)]
214    pub fn word_reverse(self) -> &'a mut crate::W<REG> {
215        self.variant(REVID_A::WordReverse)
216    }
217}
218#[doc = "Reverse output data\n\nValue on reset: 0"]
219#[derive(Clone, Copy, Debug, PartialEq, Eq)]
220pub enum REVOD_A {
221    #[doc = "0: No effect"]
222    NoEffect = 0,
223    #[doc = "1: Word reverse"]
224    WordReverse = 1,
225}
226impl From<REVOD_A> for bool {
227    #[inline(always)]
228    fn from(variant: REVOD_A) -> Self {
229        variant as u8 != 0
230    }
231}
232#[doc = "Field `REVOD` reader - Reverse output data"]
233pub type REVOD_R = crate::BitReader<REVOD_A>;
234impl REVOD_R {
235    #[doc = "Get enumerated values variant"]
236    #[inline(always)]
237    pub const fn variant(&self) -> REVOD_A {
238        match self.bits {
239            false => REVOD_A::NoEffect,
240            true => REVOD_A::WordReverse,
241        }
242    }
243    #[doc = "No effect"]
244    #[inline(always)]
245    pub fn is_no_effect(&self) -> bool {
246        *self == REVOD_A::NoEffect
247    }
248    #[doc = "Word reverse"]
249    #[inline(always)]
250    pub fn is_word_reverse(&self) -> bool {
251        *self == REVOD_A::WordReverse
252    }
253}
254impl R {
255    #[doc = "Bit 0 - Reset bit"]
256    #[inline(always)]
257    pub fn rst(&self) -> RST_R {
258        RST_R::new((self.bits & 1) != 0)
259    }
260    #[doc = "Bits 3:4 - Polynomial size"]
261    #[inline(always)]
262    pub fn poly_size(&self) -> POLY_SIZE_R {
263        POLY_SIZE_R::new(((self.bits >> 3) & 3) as u8)
264    }
265    #[doc = "Bits 5:6 - Reverse input data"]
266    #[inline(always)]
267    pub fn revid(&self) -> REVID_R {
268        REVID_R::new(((self.bits >> 5) & 3) as u8)
269    }
270    #[doc = "Bit 7 - Reverse output data"]
271    #[inline(always)]
272    pub fn revod(&self) -> REVOD_R {
273        REVOD_R::new(((self.bits >> 7) & 1) != 0)
274    }
275}
276impl core::fmt::Debug for R {
277    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
278        f.debug_struct("CTRL")
279            .field("rst", &self.rst())
280            .field("poly_size", &self.poly_size())
281            .field("revid", &self.revid())
282            .field("revod", &self.revod())
283            .finish()
284    }
285}
286impl W {
287    #[doc = "Bit 0 - Reset bit"]
288    #[inline(always)]
289    pub fn rst(&mut self) -> RST_W<'_, CTRL_SPEC> {
290        RST_W::new(self, 0)
291    }
292    #[doc = "Bits 3:4 - Polynomial size"]
293    #[inline(always)]
294    pub fn poly_size(&mut self) -> POLY_SIZE_W<'_, CTRL_SPEC> {
295        POLY_SIZE_W::new(self, 3)
296    }
297    #[doc = "Bits 5:6 - Reverse input data"]
298    #[inline(always)]
299    pub fn revid(&mut self) -> REVID_W<'_, CTRL_SPEC> {
300        REVID_W::new(self, 5)
301    }
302}
303#[doc = "Control register\n\nYou can [`read`](crate::Reg::read) this register and get [`ctrl::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`ctrl::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
304pub struct CTRL_SPEC;
305impl crate::RegisterSpec for CTRL_SPEC {
306    type Ux = u32;
307}
308#[doc = "`read()` method returns [`ctrl::R`](R) reader structure"]
309impl crate::Readable for CTRL_SPEC {}
310#[doc = "`write(|w| ..)` method takes [`ctrl::W`](W) writer structure"]
311impl crate::Writable for CTRL_SPEC {
312    type Safety = crate::Unsafe;
313    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0x01;
314}
315#[doc = "`reset()` method sets CTRL to value 0"]
316impl crate::Resettable for CTRL_SPEC {}