Skip to main content

mcxa_pac/crc0/
ctrl.rs

1#[doc = "Register `CTRL` reader"]
2pub type R = crate::R<CtrlSpec>;
3#[doc = "Register `CTRL` writer"]
4pub type W = crate::W<CtrlSpec>;
5#[doc = "TCRC\n\nValue on reset: 0"]
6#[cfg_attr(feature = "defmt", derive(defmt::Format))]
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8pub enum Tcrc {
9    #[doc = "0: 16 bits"]
10    B16 = 0,
11    #[doc = "1: 32 bits"]
12    B32 = 1,
13}
14impl From<Tcrc> for bool {
15    #[inline(always)]
16    fn from(variant: Tcrc) -> Self {
17        variant as u8 != 0
18    }
19}
20#[doc = "Field `TCRC` reader - TCRC"]
21pub type TcrcR = crate::BitReader<Tcrc>;
22impl TcrcR {
23    #[doc = "Get enumerated values variant"]
24    #[inline(always)]
25    pub const fn variant(&self) -> Tcrc {
26        match self.bits {
27            false => Tcrc::B16,
28            true => Tcrc::B32,
29        }
30    }
31    #[doc = "16 bits"]
32    #[inline(always)]
33    pub fn is_b16(&self) -> bool {
34        *self == Tcrc::B16
35    }
36    #[doc = "32 bits"]
37    #[inline(always)]
38    pub fn is_b32(&self) -> bool {
39        *self == Tcrc::B32
40    }
41}
42#[doc = "Field `TCRC` writer - TCRC"]
43pub type TcrcW<'a, REG> = crate::BitWriter<'a, REG, Tcrc>;
44impl<'a, REG> TcrcW<'a, REG>
45where
46    REG: crate::Writable + crate::RegisterSpec,
47{
48    #[doc = "16 bits"]
49    #[inline(always)]
50    pub fn b16(self) -> &'a mut crate::W<REG> {
51        self.variant(Tcrc::B16)
52    }
53    #[doc = "32 bits"]
54    #[inline(always)]
55    pub fn b32(self) -> &'a mut crate::W<REG> {
56        self.variant(Tcrc::B32)
57    }
58}
59#[doc = "Write as Seed\n\nValue on reset: 0"]
60#[cfg_attr(feature = "defmt", derive(defmt::Format))]
61#[derive(Clone, Copy, Debug, PartialEq, Eq)]
62pub enum Was {
63    #[doc = "0: Data values"]
64    Data = 0,
65    #[doc = "1: Seed values"]
66    Seed = 1,
67}
68impl From<Was> for bool {
69    #[inline(always)]
70    fn from(variant: Was) -> Self {
71        variant as u8 != 0
72    }
73}
74#[doc = "Field `WAS` reader - Write as Seed"]
75pub type WasR = crate::BitReader<Was>;
76impl WasR {
77    #[doc = "Get enumerated values variant"]
78    #[inline(always)]
79    pub const fn variant(&self) -> Was {
80        match self.bits {
81            false => Was::Data,
82            true => Was::Seed,
83        }
84    }
85    #[doc = "Data values"]
86    #[inline(always)]
87    pub fn is_data(&self) -> bool {
88        *self == Was::Data
89    }
90    #[doc = "Seed values"]
91    #[inline(always)]
92    pub fn is_seed(&self) -> bool {
93        *self == Was::Seed
94    }
95}
96#[doc = "Field `WAS` writer - Write as Seed"]
97pub type WasW<'a, REG> = crate::BitWriter<'a, REG, Was>;
98impl<'a, REG> WasW<'a, REG>
99where
100    REG: crate::Writable + crate::RegisterSpec,
101{
102    #[doc = "Data values"]
103    #[inline(always)]
104    pub fn data(self) -> &'a mut crate::W<REG> {
105        self.variant(Was::Data)
106    }
107    #[doc = "Seed values"]
108    #[inline(always)]
109    pub fn seed(self) -> &'a mut crate::W<REG> {
110        self.variant(Was::Seed)
111    }
112}
113#[doc = "Complement Read of CRC Data Register\n\nValue on reset: 0"]
114#[cfg_attr(feature = "defmt", derive(defmt::Format))]
115#[derive(Clone, Copy, Debug, PartialEq, Eq)]
116pub enum Fxor {
117    #[doc = "0: Disables XOR on reading data."]
118    Noxor = 0,
119    #[doc = "1: Inverts or complements the read value of the CRC Data."]
120    Invert = 1,
121}
122impl From<Fxor> for bool {
123    #[inline(always)]
124    fn from(variant: Fxor) -> Self {
125        variant as u8 != 0
126    }
127}
128#[doc = "Field `FXOR` reader - Complement Read of CRC Data Register"]
129pub type FxorR = crate::BitReader<Fxor>;
130impl FxorR {
131    #[doc = "Get enumerated values variant"]
132    #[inline(always)]
133    pub const fn variant(&self) -> Fxor {
134        match self.bits {
135            false => Fxor::Noxor,
136            true => Fxor::Invert,
137        }
138    }
139    #[doc = "Disables XOR on reading data."]
140    #[inline(always)]
141    pub fn is_noxor(&self) -> bool {
142        *self == Fxor::Noxor
143    }
144    #[doc = "Inverts or complements the read value of the CRC Data."]
145    #[inline(always)]
146    pub fn is_invert(&self) -> bool {
147        *self == Fxor::Invert
148    }
149}
150#[doc = "Field `FXOR` writer - Complement Read of CRC Data Register"]
151pub type FxorW<'a, REG> = crate::BitWriter<'a, REG, Fxor>;
152impl<'a, REG> FxorW<'a, REG>
153where
154    REG: crate::Writable + crate::RegisterSpec,
155{
156    #[doc = "Disables XOR on reading data."]
157    #[inline(always)]
158    pub fn noxor(self) -> &'a mut crate::W<REG> {
159        self.variant(Fxor::Noxor)
160    }
161    #[doc = "Inverts or complements the read value of the CRC Data."]
162    #[inline(always)]
163    pub fn invert(self) -> &'a mut crate::W<REG> {
164        self.variant(Fxor::Invert)
165    }
166}
167#[doc = "Transpose Type for Read\n\nValue on reset: 0"]
168#[cfg_attr(feature = "defmt", derive(defmt::Format))]
169#[derive(Clone, Copy, Debug, PartialEq, Eq)]
170#[repr(u8)]
171pub enum Totr {
172    #[doc = "0: No transposition"]
173    Notrnps = 0,
174    #[doc = "1: Bits in bytes are transposed, but bytes are not transposed."]
175    BtsTrnps = 1,
176    #[doc = "2: Both bits in bytes and bytes are transposed."]
177    BytsBtsTrnps = 2,
178    #[doc = "3: Only bytes are transposed, no bits in a byte are transposed."]
179    BytsTrnps = 3,
180}
181impl From<Totr> for u8 {
182    #[inline(always)]
183    fn from(variant: Totr) -> Self {
184        variant as _
185    }
186}
187impl crate::FieldSpec for Totr {
188    type Ux = u8;
189}
190impl crate::IsEnum for Totr {}
191#[doc = "Field `TOTR` reader - Transpose Type for Read"]
192pub type TotrR = crate::FieldReader<Totr>;
193impl TotrR {
194    #[doc = "Get enumerated values variant"]
195    #[inline(always)]
196    pub const fn variant(&self) -> Totr {
197        match self.bits {
198            0 => Totr::Notrnps,
199            1 => Totr::BtsTrnps,
200            2 => Totr::BytsBtsTrnps,
201            3 => Totr::BytsTrnps,
202            _ => unreachable!(),
203        }
204    }
205    #[doc = "No transposition"]
206    #[inline(always)]
207    pub fn is_notrnps(&self) -> bool {
208        *self == Totr::Notrnps
209    }
210    #[doc = "Bits in bytes are transposed, but bytes are not transposed."]
211    #[inline(always)]
212    pub fn is_bts_trnps(&self) -> bool {
213        *self == Totr::BtsTrnps
214    }
215    #[doc = "Both bits in bytes and bytes are transposed."]
216    #[inline(always)]
217    pub fn is_byts_bts_trnps(&self) -> bool {
218        *self == Totr::BytsBtsTrnps
219    }
220    #[doc = "Only bytes are transposed, no bits in a byte are transposed."]
221    #[inline(always)]
222    pub fn is_byts_trnps(&self) -> bool {
223        *self == Totr::BytsTrnps
224    }
225}
226#[doc = "Field `TOTR` writer - Transpose Type for Read"]
227pub type TotrW<'a, REG> = crate::FieldWriter<'a, REG, 2, Totr, crate::Safe>;
228impl<'a, REG> TotrW<'a, REG>
229where
230    REG: crate::Writable + crate::RegisterSpec,
231    REG::Ux: From<u8>,
232{
233    #[doc = "No transposition"]
234    #[inline(always)]
235    pub fn notrnps(self) -> &'a mut crate::W<REG> {
236        self.variant(Totr::Notrnps)
237    }
238    #[doc = "Bits in bytes are transposed, but bytes are not transposed."]
239    #[inline(always)]
240    pub fn bts_trnps(self) -> &'a mut crate::W<REG> {
241        self.variant(Totr::BtsTrnps)
242    }
243    #[doc = "Both bits in bytes and bytes are transposed."]
244    #[inline(always)]
245    pub fn byts_bts_trnps(self) -> &'a mut crate::W<REG> {
246        self.variant(Totr::BytsBtsTrnps)
247    }
248    #[doc = "Only bytes are transposed, no bits in a byte are transposed."]
249    #[inline(always)]
250    pub fn byts_trnps(self) -> &'a mut crate::W<REG> {
251        self.variant(Totr::BytsTrnps)
252    }
253}
254#[doc = "Transpose Type for Write\n\nValue on reset: 0"]
255#[cfg_attr(feature = "defmt", derive(defmt::Format))]
256#[derive(Clone, Copy, Debug, PartialEq, Eq)]
257#[repr(u8)]
258pub enum Tot {
259    #[doc = "0: No transposition"]
260    Notrnps = 0,
261    #[doc = "1: Bits in bytes are transposed, but bytes are not transposed."]
262    BtsTrnps = 1,
263    #[doc = "2: Both bits in bytes and bytes are transposed."]
264    BytsBtsTrnps = 2,
265    #[doc = "3: Only bytes are transposed, no bits in a byte are transposed."]
266    BytsTrnps = 3,
267}
268impl From<Tot> for u8 {
269    #[inline(always)]
270    fn from(variant: Tot) -> Self {
271        variant as _
272    }
273}
274impl crate::FieldSpec for Tot {
275    type Ux = u8;
276}
277impl crate::IsEnum for Tot {}
278#[doc = "Field `TOT` reader - Transpose Type for Write"]
279pub type TotR = crate::FieldReader<Tot>;
280impl TotR {
281    #[doc = "Get enumerated values variant"]
282    #[inline(always)]
283    pub const fn variant(&self) -> Tot {
284        match self.bits {
285            0 => Tot::Notrnps,
286            1 => Tot::BtsTrnps,
287            2 => Tot::BytsBtsTrnps,
288            3 => Tot::BytsTrnps,
289            _ => unreachable!(),
290        }
291    }
292    #[doc = "No transposition"]
293    #[inline(always)]
294    pub fn is_notrnps(&self) -> bool {
295        *self == Tot::Notrnps
296    }
297    #[doc = "Bits in bytes are transposed, but bytes are not transposed."]
298    #[inline(always)]
299    pub fn is_bts_trnps(&self) -> bool {
300        *self == Tot::BtsTrnps
301    }
302    #[doc = "Both bits in bytes and bytes are transposed."]
303    #[inline(always)]
304    pub fn is_byts_bts_trnps(&self) -> bool {
305        *self == Tot::BytsBtsTrnps
306    }
307    #[doc = "Only bytes are transposed, no bits in a byte are transposed."]
308    #[inline(always)]
309    pub fn is_byts_trnps(&self) -> bool {
310        *self == Tot::BytsTrnps
311    }
312}
313#[doc = "Field `TOT` writer - Transpose Type for Write"]
314pub type TotW<'a, REG> = crate::FieldWriter<'a, REG, 2, Tot, crate::Safe>;
315impl<'a, REG> TotW<'a, REG>
316where
317    REG: crate::Writable + crate::RegisterSpec,
318    REG::Ux: From<u8>,
319{
320    #[doc = "No transposition"]
321    #[inline(always)]
322    pub fn notrnps(self) -> &'a mut crate::W<REG> {
323        self.variant(Tot::Notrnps)
324    }
325    #[doc = "Bits in bytes are transposed, but bytes are not transposed."]
326    #[inline(always)]
327    pub fn bts_trnps(self) -> &'a mut crate::W<REG> {
328        self.variant(Tot::BtsTrnps)
329    }
330    #[doc = "Both bits in bytes and bytes are transposed."]
331    #[inline(always)]
332    pub fn byts_bts_trnps(self) -> &'a mut crate::W<REG> {
333        self.variant(Tot::BytsBtsTrnps)
334    }
335    #[doc = "Only bytes are transposed, no bits in a byte are transposed."]
336    #[inline(always)]
337    pub fn byts_trnps(self) -> &'a mut crate::W<REG> {
338        self.variant(Tot::BytsTrnps)
339    }
340}
341impl R {
342    #[doc = "Bit 24 - TCRC"]
343    #[inline(always)]
344    pub fn tcrc(&self) -> TcrcR {
345        TcrcR::new(((self.bits >> 24) & 1) != 0)
346    }
347    #[doc = "Bit 25 - Write as Seed"]
348    #[inline(always)]
349    pub fn was(&self) -> WasR {
350        WasR::new(((self.bits >> 25) & 1) != 0)
351    }
352    #[doc = "Bit 26 - Complement Read of CRC Data Register"]
353    #[inline(always)]
354    pub fn fxor(&self) -> FxorR {
355        FxorR::new(((self.bits >> 26) & 1) != 0)
356    }
357    #[doc = "Bits 28:29 - Transpose Type for Read"]
358    #[inline(always)]
359    pub fn totr(&self) -> TotrR {
360        TotrR::new(((self.bits >> 28) & 3) as u8)
361    }
362    #[doc = "Bits 30:31 - Transpose Type for Write"]
363    #[inline(always)]
364    pub fn tot(&self) -> TotR {
365        TotR::new(((self.bits >> 30) & 3) as u8)
366    }
367}
368#[cfg(feature = "debug")]
369impl core::fmt::Debug for R {
370    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
371        f.debug_struct("CTRL")
372            .field("tcrc", &self.tcrc())
373            .field("was", &self.was())
374            .field("fxor", &self.fxor())
375            .field("totr", &self.totr())
376            .field("tot", &self.tot())
377            .finish()
378    }
379}
380impl W {
381    #[doc = "Bit 24 - TCRC"]
382    #[inline(always)]
383    pub fn tcrc(&mut self) -> TcrcW<'_, CtrlSpec> {
384        TcrcW::new(self, 24)
385    }
386    #[doc = "Bit 25 - Write as Seed"]
387    #[inline(always)]
388    pub fn was(&mut self) -> WasW<'_, CtrlSpec> {
389        WasW::new(self, 25)
390    }
391    #[doc = "Bit 26 - Complement Read of CRC Data Register"]
392    #[inline(always)]
393    pub fn fxor(&mut self) -> FxorW<'_, CtrlSpec> {
394        FxorW::new(self, 26)
395    }
396    #[doc = "Bits 28:29 - Transpose Type for Read"]
397    #[inline(always)]
398    pub fn totr(&mut self) -> TotrW<'_, CtrlSpec> {
399        TotrW::new(self, 28)
400    }
401    #[doc = "Bits 30:31 - Transpose Type for Write"]
402    #[inline(always)]
403    pub fn tot(&mut self) -> TotW<'_, CtrlSpec> {
404        TotW::new(self, 30)
405    }
406}
407#[doc = "Control\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)."]
408pub struct CtrlSpec;
409impl crate::RegisterSpec for CtrlSpec {
410    type Ux = u32;
411}
412#[doc = "`read()` method returns [`ctrl::R`](R) reader structure"]
413impl crate::Readable for CtrlSpec {}
414#[doc = "`write(|w| ..)` method takes [`ctrl::W`](W) writer structure"]
415impl crate::Writable for CtrlSpec {
416    type Safety = crate::Unsafe;
417}
418#[doc = "`reset()` method sets CTRL to value 0"]
419impl crate::Resettable for CtrlSpec {}