stm32g0/stm32g041/aes/
cr.rs

1///Register `CR` reader
2pub type R = crate::R<CRrs>;
3///Register `CR` writer
4pub type W = crate::W<CRrs>;
5/**AES enable
6
7Value on reset: 0*/
8#[cfg_attr(feature = "defmt", derive(defmt::Format))]
9#[derive(Clone, Copy, Debug, PartialEq, Eq)]
10pub enum EN {
11    ///0: Disable AES
12    Disabled = 0,
13    ///1: Enable AES
14    Enabled = 1,
15}
16impl From<EN> for bool {
17    #[inline(always)]
18    fn from(variant: EN) -> Self {
19        variant as u8 != 0
20    }
21}
22///Field `EN` reader - AES enable
23pub type EN_R = crate::BitReader<EN>;
24impl EN_R {
25    ///Get enumerated values variant
26    #[inline(always)]
27    pub const fn variant(&self) -> EN {
28        match self.bits {
29            false => EN::Disabled,
30            true => EN::Enabled,
31        }
32    }
33    ///Disable AES
34    #[inline(always)]
35    pub fn is_disabled(&self) -> bool {
36        *self == EN::Disabled
37    }
38    ///Enable AES
39    #[inline(always)]
40    pub fn is_enabled(&self) -> bool {
41        *self == EN::Enabled
42    }
43}
44///Field `EN` writer - AES enable
45pub type EN_W<'a, REG> = crate::BitWriter<'a, REG, EN>;
46impl<'a, REG> EN_W<'a, REG>
47where
48    REG: crate::Writable + crate::RegisterSpec,
49{
50    ///Disable AES
51    #[inline(always)]
52    pub fn disabled(self) -> &'a mut crate::W<REG> {
53        self.variant(EN::Disabled)
54    }
55    ///Enable AES
56    #[inline(always)]
57    pub fn enabled(self) -> &'a mut crate::W<REG> {
58        self.variant(EN::Enabled)
59    }
60}
61/**Data type selection (for data in and data out to/from the cryptographic block)
62
63Value on reset: 0*/
64#[cfg_attr(feature = "defmt", derive(defmt::Format))]
65#[derive(Clone, Copy, Debug, PartialEq, Eq)]
66#[repr(u8)]
67pub enum DATATYPE {
68    ///0: Word
69    None = 0,
70    ///1: Half-word (16-bit)
71    HalfWord = 1,
72    ///2: Byte (8-bit)
73    Byte = 2,
74    ///3: Bit
75    Bit = 3,
76}
77impl From<DATATYPE> for u8 {
78    #[inline(always)]
79    fn from(variant: DATATYPE) -> Self {
80        variant as _
81    }
82}
83impl crate::FieldSpec for DATATYPE {
84    type Ux = u8;
85}
86impl crate::IsEnum for DATATYPE {}
87///Field `DATATYPE` reader - Data type selection (for data in and data out to/from the cryptographic block)
88pub type DATATYPE_R = crate::FieldReader<DATATYPE>;
89impl DATATYPE_R {
90    ///Get enumerated values variant
91    #[inline(always)]
92    pub const fn variant(&self) -> DATATYPE {
93        match self.bits {
94            0 => DATATYPE::None,
95            1 => DATATYPE::HalfWord,
96            2 => DATATYPE::Byte,
97            3 => DATATYPE::Bit,
98            _ => unreachable!(),
99        }
100    }
101    ///Word
102    #[inline(always)]
103    pub fn is_none(&self) -> bool {
104        *self == DATATYPE::None
105    }
106    ///Half-word (16-bit)
107    #[inline(always)]
108    pub fn is_half_word(&self) -> bool {
109        *self == DATATYPE::HalfWord
110    }
111    ///Byte (8-bit)
112    #[inline(always)]
113    pub fn is_byte(&self) -> bool {
114        *self == DATATYPE::Byte
115    }
116    ///Bit
117    #[inline(always)]
118    pub fn is_bit(&self) -> bool {
119        *self == DATATYPE::Bit
120    }
121}
122///Field `DATATYPE` writer - Data type selection (for data in and data out to/from the cryptographic block)
123pub type DATATYPE_W<'a, REG> = crate::FieldWriter<'a, REG, 2, DATATYPE, crate::Safe>;
124impl<'a, REG> DATATYPE_W<'a, REG>
125where
126    REG: crate::Writable + crate::RegisterSpec,
127    REG::Ux: From<u8>,
128{
129    ///Word
130    #[inline(always)]
131    pub fn none(self) -> &'a mut crate::W<REG> {
132        self.variant(DATATYPE::None)
133    }
134    ///Half-word (16-bit)
135    #[inline(always)]
136    pub fn half_word(self) -> &'a mut crate::W<REG> {
137        self.variant(DATATYPE::HalfWord)
138    }
139    ///Byte (8-bit)
140    #[inline(always)]
141    pub fn byte(self) -> &'a mut crate::W<REG> {
142        self.variant(DATATYPE::Byte)
143    }
144    ///Bit
145    #[inline(always)]
146    pub fn bit_(self) -> &'a mut crate::W<REG> {
147        self.variant(DATATYPE::Bit)
148    }
149}
150/**AES operating mode
151
152Value on reset: 0*/
153#[cfg_attr(feature = "defmt", derive(defmt::Format))]
154#[derive(Clone, Copy, Debug, PartialEq, Eq)]
155#[repr(u8)]
156pub enum MODE {
157    ///0: Mode 1: encryption
158    Mode1 = 0,
159    ///1: Mode 2: key derivation (or key preparation for ECB/CBC decryption)
160    Mode2 = 1,
161    ///2: Mode 3: decryption
162    Mode3 = 2,
163    ///3: Mode 4: key derivation then single decryption
164    Mode4 = 3,
165}
166impl From<MODE> for u8 {
167    #[inline(always)]
168    fn from(variant: MODE) -> Self {
169        variant as _
170    }
171}
172impl crate::FieldSpec for MODE {
173    type Ux = u8;
174}
175impl crate::IsEnum for MODE {}
176///Field `MODE` reader - AES operating mode
177pub type MODE_R = crate::FieldReader<MODE>;
178impl MODE_R {
179    ///Get enumerated values variant
180    #[inline(always)]
181    pub const fn variant(&self) -> MODE {
182        match self.bits {
183            0 => MODE::Mode1,
184            1 => MODE::Mode2,
185            2 => MODE::Mode3,
186            3 => MODE::Mode4,
187            _ => unreachable!(),
188        }
189    }
190    ///Mode 1: encryption
191    #[inline(always)]
192    pub fn is_mode1(&self) -> bool {
193        *self == MODE::Mode1
194    }
195    ///Mode 2: key derivation (or key preparation for ECB/CBC decryption)
196    #[inline(always)]
197    pub fn is_mode2(&self) -> bool {
198        *self == MODE::Mode2
199    }
200    ///Mode 3: decryption
201    #[inline(always)]
202    pub fn is_mode3(&self) -> bool {
203        *self == MODE::Mode3
204    }
205    ///Mode 4: key derivation then single decryption
206    #[inline(always)]
207    pub fn is_mode4(&self) -> bool {
208        *self == MODE::Mode4
209    }
210}
211///Field `MODE` writer - AES operating mode
212pub type MODE_W<'a, REG> = crate::FieldWriter<'a, REG, 2, MODE, crate::Safe>;
213impl<'a, REG> MODE_W<'a, REG>
214where
215    REG: crate::Writable + crate::RegisterSpec,
216    REG::Ux: From<u8>,
217{
218    ///Mode 1: encryption
219    #[inline(always)]
220    pub fn mode1(self) -> &'a mut crate::W<REG> {
221        self.variant(MODE::Mode1)
222    }
223    ///Mode 2: key derivation (or key preparation for ECB/CBC decryption)
224    #[inline(always)]
225    pub fn mode2(self) -> &'a mut crate::W<REG> {
226        self.variant(MODE::Mode2)
227    }
228    ///Mode 3: decryption
229    #[inline(always)]
230    pub fn mode3(self) -> &'a mut crate::W<REG> {
231        self.variant(MODE::Mode3)
232    }
233    ///Mode 4: key derivation then single decryption
234    #[inline(always)]
235    pub fn mode4(self) -> &'a mut crate::W<REG> {
236        self.variant(MODE::Mode4)
237    }
238}
239/**AES chaining mode Bit1 Bit0
240
241Value on reset: 0*/
242#[cfg_attr(feature = "defmt", derive(defmt::Format))]
243#[derive(Clone, Copy, Debug, PartialEq, Eq)]
244#[repr(u8)]
245pub enum CHMOD10 {
246    ///0: Electronic codebook (ECB) / Counter with CBC-MAC (CCM) if CHMOD2 is 1
247    Ecb = 0,
248    ///1: Cipher-block chaining (CBC)
249    Cbc = 1,
250    ///2: Counter mode (CTR)
251    Ctr = 2,
252    ///3: Galois counter mode (GCM) and Galois message authentication code (GMAC)
253    Gcm = 3,
254}
255impl From<CHMOD10> for u8 {
256    #[inline(always)]
257    fn from(variant: CHMOD10) -> Self {
258        variant as _
259    }
260}
261impl crate::FieldSpec for CHMOD10 {
262    type Ux = u8;
263}
264impl crate::IsEnum for CHMOD10 {}
265///Field `CHMOD10` reader - AES chaining mode Bit1 Bit0
266pub type CHMOD10_R = crate::FieldReader<CHMOD10>;
267impl CHMOD10_R {
268    ///Get enumerated values variant
269    #[inline(always)]
270    pub const fn variant(&self) -> CHMOD10 {
271        match self.bits {
272            0 => CHMOD10::Ecb,
273            1 => CHMOD10::Cbc,
274            2 => CHMOD10::Ctr,
275            3 => CHMOD10::Gcm,
276            _ => unreachable!(),
277        }
278    }
279    ///Electronic codebook (ECB) / Counter with CBC-MAC (CCM) if CHMOD2 is 1
280    #[inline(always)]
281    pub fn is_ecb(&self) -> bool {
282        *self == CHMOD10::Ecb
283    }
284    ///Cipher-block chaining (CBC)
285    #[inline(always)]
286    pub fn is_cbc(&self) -> bool {
287        *self == CHMOD10::Cbc
288    }
289    ///Counter mode (CTR)
290    #[inline(always)]
291    pub fn is_ctr(&self) -> bool {
292        *self == CHMOD10::Ctr
293    }
294    ///Galois counter mode (GCM) and Galois message authentication code (GMAC)
295    #[inline(always)]
296    pub fn is_gcm(&self) -> bool {
297        *self == CHMOD10::Gcm
298    }
299}
300///Field `CHMOD10` writer - AES chaining mode Bit1 Bit0
301pub type CHMOD10_W<'a, REG> = crate::FieldWriter<'a, REG, 2, CHMOD10, crate::Safe>;
302impl<'a, REG> CHMOD10_W<'a, REG>
303where
304    REG: crate::Writable + crate::RegisterSpec,
305    REG::Ux: From<u8>,
306{
307    ///Electronic codebook (ECB) / Counter with CBC-MAC (CCM) if CHMOD2 is 1
308    #[inline(always)]
309    pub fn ecb(self) -> &'a mut crate::W<REG> {
310        self.variant(CHMOD10::Ecb)
311    }
312    ///Cipher-block chaining (CBC)
313    #[inline(always)]
314    pub fn cbc(self) -> &'a mut crate::W<REG> {
315        self.variant(CHMOD10::Cbc)
316    }
317    ///Counter mode (CTR)
318    #[inline(always)]
319    pub fn ctr(self) -> &'a mut crate::W<REG> {
320        self.variant(CHMOD10::Ctr)
321    }
322    ///Galois counter mode (GCM) and Galois message authentication code (GMAC)
323    #[inline(always)]
324    pub fn gcm(self) -> &'a mut crate::W<REG> {
325        self.variant(CHMOD10::Gcm)
326    }
327}
328/**Computation Complete Flag Clear
329
330Value on reset: 0*/
331#[cfg_attr(feature = "defmt", derive(defmt::Format))]
332#[derive(Clone, Copy, Debug, PartialEq, Eq)]
333pub enum CCFCW {
334    ///1: Clear computation complete flag
335    Clear = 1,
336}
337impl From<CCFCW> for bool {
338    #[inline(always)]
339    fn from(variant: CCFCW) -> Self {
340        variant as u8 != 0
341    }
342}
343///Field `CCFC` reader - Computation Complete Flag Clear
344pub type CCFC_R = crate::BitReader<CCFCW>;
345impl CCFC_R {
346    ///Get enumerated values variant
347    #[inline(always)]
348    pub const fn variant(&self) -> Option<CCFCW> {
349        match self.bits {
350            true => Some(CCFCW::Clear),
351            _ => None,
352        }
353    }
354    ///Clear computation complete flag
355    #[inline(always)]
356    pub fn is_clear(&self) -> bool {
357        *self == CCFCW::Clear
358    }
359}
360///Field `CCFC` writer - Computation Complete Flag Clear
361pub type CCFC_W<'a, REG> = crate::BitWriter<'a, REG, CCFCW>;
362impl<'a, REG> CCFC_W<'a, REG>
363where
364    REG: crate::Writable + crate::RegisterSpec,
365{
366    ///Clear computation complete flag
367    #[inline(always)]
368    pub fn clear(self) -> &'a mut crate::W<REG> {
369        self.variant(CCFCW::Clear)
370    }
371}
372/**Error clear
373
374Value on reset: 0*/
375#[cfg_attr(feature = "defmt", derive(defmt::Format))]
376#[derive(Clone, Copy, Debug, PartialEq, Eq)]
377pub enum ERRCW {
378    ///1: Clear RDERR and WRERR flags
379    Clear = 1,
380}
381impl From<ERRCW> for bool {
382    #[inline(always)]
383    fn from(variant: ERRCW) -> Self {
384        variant as u8 != 0
385    }
386}
387///Field `ERRC` reader - Error clear
388pub type ERRC_R = crate::BitReader<ERRCW>;
389impl ERRC_R {
390    ///Get enumerated values variant
391    #[inline(always)]
392    pub const fn variant(&self) -> Option<ERRCW> {
393        match self.bits {
394            true => Some(ERRCW::Clear),
395            _ => None,
396        }
397    }
398    ///Clear RDERR and WRERR flags
399    #[inline(always)]
400    pub fn is_clear(&self) -> bool {
401        *self == ERRCW::Clear
402    }
403}
404///Field `ERRC` writer - Error clear
405pub type ERRC_W<'a, REG> = crate::BitWriter<'a, REG, ERRCW>;
406impl<'a, REG> ERRC_W<'a, REG>
407where
408    REG: crate::Writable + crate::RegisterSpec,
409{
410    ///Clear RDERR and WRERR flags
411    #[inline(always)]
412    pub fn clear(self) -> &'a mut crate::W<REG> {
413        self.variant(ERRCW::Clear)
414    }
415}
416/**CCF flag interrupt enable
417
418Value on reset: 0*/
419#[cfg_attr(feature = "defmt", derive(defmt::Format))]
420#[derive(Clone, Copy, Debug, PartialEq, Eq)]
421pub enum CCFIE {
422    ///0: Disable (mask) CCF interrupt
423    Disabled = 0,
424    ///1: Enable CCF interrupt
425    Enabled = 1,
426}
427impl From<CCFIE> for bool {
428    #[inline(always)]
429    fn from(variant: CCFIE) -> Self {
430        variant as u8 != 0
431    }
432}
433///Field `CCFIE` reader - CCF flag interrupt enable
434pub type CCFIE_R = crate::BitReader<CCFIE>;
435impl CCFIE_R {
436    ///Get enumerated values variant
437    #[inline(always)]
438    pub const fn variant(&self) -> CCFIE {
439        match self.bits {
440            false => CCFIE::Disabled,
441            true => CCFIE::Enabled,
442        }
443    }
444    ///Disable (mask) CCF interrupt
445    #[inline(always)]
446    pub fn is_disabled(&self) -> bool {
447        *self == CCFIE::Disabled
448    }
449    ///Enable CCF interrupt
450    #[inline(always)]
451    pub fn is_enabled(&self) -> bool {
452        *self == CCFIE::Enabled
453    }
454}
455///Field `CCFIE` writer - CCF flag interrupt enable
456pub type CCFIE_W<'a, REG> = crate::BitWriter<'a, REG, CCFIE>;
457impl<'a, REG> CCFIE_W<'a, REG>
458where
459    REG: crate::Writable + crate::RegisterSpec,
460{
461    ///Disable (mask) CCF interrupt
462    #[inline(always)]
463    pub fn disabled(self) -> &'a mut crate::W<REG> {
464        self.variant(CCFIE::Disabled)
465    }
466    ///Enable CCF interrupt
467    #[inline(always)]
468    pub fn enabled(self) -> &'a mut crate::W<REG> {
469        self.variant(CCFIE::Enabled)
470    }
471}
472/**Error interrupt enable
473
474Value on reset: 0*/
475#[cfg_attr(feature = "defmt", derive(defmt::Format))]
476#[derive(Clone, Copy, Debug, PartialEq, Eq)]
477pub enum ERRIE {
478    ///0: Disable (mask) error interrupt
479    Disabled = 0,
480    ///1: Enable error interrupt
481    Enabled = 1,
482}
483impl From<ERRIE> for bool {
484    #[inline(always)]
485    fn from(variant: ERRIE) -> Self {
486        variant as u8 != 0
487    }
488}
489///Field `ERRIE` reader - Error interrupt enable
490pub type ERRIE_R = crate::BitReader<ERRIE>;
491impl ERRIE_R {
492    ///Get enumerated values variant
493    #[inline(always)]
494    pub const fn variant(&self) -> ERRIE {
495        match self.bits {
496            false => ERRIE::Disabled,
497            true => ERRIE::Enabled,
498        }
499    }
500    ///Disable (mask) error interrupt
501    #[inline(always)]
502    pub fn is_disabled(&self) -> bool {
503        *self == ERRIE::Disabled
504    }
505    ///Enable error interrupt
506    #[inline(always)]
507    pub fn is_enabled(&self) -> bool {
508        *self == ERRIE::Enabled
509    }
510}
511///Field `ERRIE` writer - Error interrupt enable
512pub type ERRIE_W<'a, REG> = crate::BitWriter<'a, REG, ERRIE>;
513impl<'a, REG> ERRIE_W<'a, REG>
514where
515    REG: crate::Writable + crate::RegisterSpec,
516{
517    ///Disable (mask) error interrupt
518    #[inline(always)]
519    pub fn disabled(self) -> &'a mut crate::W<REG> {
520        self.variant(ERRIE::Disabled)
521    }
522    ///Enable error interrupt
523    #[inline(always)]
524    pub fn enabled(self) -> &'a mut crate::W<REG> {
525        self.variant(ERRIE::Enabled)
526    }
527}
528/**Enable DMA management of data input phase
529
530Value on reset: 0*/
531#[cfg_attr(feature = "defmt", derive(defmt::Format))]
532#[derive(Clone, Copy, Debug, PartialEq, Eq)]
533pub enum DMAINEN {
534    ///0: Disable DMA Input
535    Disabled = 0,
536    ///1: Enable DMA Input
537    Enabled = 1,
538}
539impl From<DMAINEN> for bool {
540    #[inline(always)]
541    fn from(variant: DMAINEN) -> Self {
542        variant as u8 != 0
543    }
544}
545///Field `DMAINEN` reader - Enable DMA management of data input phase
546pub type DMAINEN_R = crate::BitReader<DMAINEN>;
547impl DMAINEN_R {
548    ///Get enumerated values variant
549    #[inline(always)]
550    pub const fn variant(&self) -> DMAINEN {
551        match self.bits {
552            false => DMAINEN::Disabled,
553            true => DMAINEN::Enabled,
554        }
555    }
556    ///Disable DMA Input
557    #[inline(always)]
558    pub fn is_disabled(&self) -> bool {
559        *self == DMAINEN::Disabled
560    }
561    ///Enable DMA Input
562    #[inline(always)]
563    pub fn is_enabled(&self) -> bool {
564        *self == DMAINEN::Enabled
565    }
566}
567///Field `DMAINEN` writer - Enable DMA management of data input phase
568pub type DMAINEN_W<'a, REG> = crate::BitWriter<'a, REG, DMAINEN>;
569impl<'a, REG> DMAINEN_W<'a, REG>
570where
571    REG: crate::Writable + crate::RegisterSpec,
572{
573    ///Disable DMA Input
574    #[inline(always)]
575    pub fn disabled(self) -> &'a mut crate::W<REG> {
576        self.variant(DMAINEN::Disabled)
577    }
578    ///Enable DMA Input
579    #[inline(always)]
580    pub fn enabled(self) -> &'a mut crate::W<REG> {
581        self.variant(DMAINEN::Enabled)
582    }
583}
584/**Enable DMA management of data output phase
585
586Value on reset: 0*/
587#[cfg_attr(feature = "defmt", derive(defmt::Format))]
588#[derive(Clone, Copy, Debug, PartialEq, Eq)]
589pub enum DMAOUTEN {
590    ///0: Disable DMA Output
591    Disabled = 0,
592    ///1: Enabled DMA Output
593    Enabled = 1,
594}
595impl From<DMAOUTEN> for bool {
596    #[inline(always)]
597    fn from(variant: DMAOUTEN) -> Self {
598        variant as u8 != 0
599    }
600}
601///Field `DMAOUTEN` reader - Enable DMA management of data output phase
602pub type DMAOUTEN_R = crate::BitReader<DMAOUTEN>;
603impl DMAOUTEN_R {
604    ///Get enumerated values variant
605    #[inline(always)]
606    pub const fn variant(&self) -> DMAOUTEN {
607        match self.bits {
608            false => DMAOUTEN::Disabled,
609            true => DMAOUTEN::Enabled,
610        }
611    }
612    ///Disable DMA Output
613    #[inline(always)]
614    pub fn is_disabled(&self) -> bool {
615        *self == DMAOUTEN::Disabled
616    }
617    ///Enabled DMA Output
618    #[inline(always)]
619    pub fn is_enabled(&self) -> bool {
620        *self == DMAOUTEN::Enabled
621    }
622}
623///Field `DMAOUTEN` writer - Enable DMA management of data output phase
624pub type DMAOUTEN_W<'a, REG> = crate::BitWriter<'a, REG, DMAOUTEN>;
625impl<'a, REG> DMAOUTEN_W<'a, REG>
626where
627    REG: crate::Writable + crate::RegisterSpec,
628{
629    ///Disable DMA Output
630    #[inline(always)]
631    pub fn disabled(self) -> &'a mut crate::W<REG> {
632        self.variant(DMAOUTEN::Disabled)
633    }
634    ///Enabled DMA Output
635    #[inline(always)]
636    pub fn enabled(self) -> &'a mut crate::W<REG> {
637        self.variant(DMAOUTEN::Enabled)
638    }
639}
640/**Used only for GCM, CCM and GMAC algorithms and has no effect when other algorithms are selected
641
642Value on reset: 0*/
643#[cfg_attr(feature = "defmt", derive(defmt::Format))]
644#[derive(Clone, Copy, Debug, PartialEq, Eq)]
645#[repr(u8)]
646pub enum GCMPH {
647    ///0: Init phase
648    Init = 0,
649    ///1: Header phase
650    Header = 1,
651    ///2: Payload phase
652    Payload = 2,
653    ///3: Final Phase
654    Final = 3,
655}
656impl From<GCMPH> for u8 {
657    #[inline(always)]
658    fn from(variant: GCMPH) -> Self {
659        variant as _
660    }
661}
662impl crate::FieldSpec for GCMPH {
663    type Ux = u8;
664}
665impl crate::IsEnum for GCMPH {}
666///Field `GCMPH` reader - Used only for GCM, CCM and GMAC algorithms and has no effect when other algorithms are selected
667pub type GCMPH_R = crate::FieldReader<GCMPH>;
668impl GCMPH_R {
669    ///Get enumerated values variant
670    #[inline(always)]
671    pub const fn variant(&self) -> GCMPH {
672        match self.bits {
673            0 => GCMPH::Init,
674            1 => GCMPH::Header,
675            2 => GCMPH::Payload,
676            3 => GCMPH::Final,
677            _ => unreachable!(),
678        }
679    }
680    ///Init phase
681    #[inline(always)]
682    pub fn is_init(&self) -> bool {
683        *self == GCMPH::Init
684    }
685    ///Header phase
686    #[inline(always)]
687    pub fn is_header(&self) -> bool {
688        *self == GCMPH::Header
689    }
690    ///Payload phase
691    #[inline(always)]
692    pub fn is_payload(&self) -> bool {
693        *self == GCMPH::Payload
694    }
695    ///Final Phase
696    #[inline(always)]
697    pub fn is_final(&self) -> bool {
698        *self == GCMPH::Final
699    }
700}
701///Field `GCMPH` writer - Used only for GCM, CCM and GMAC algorithms and has no effect when other algorithms are selected
702pub type GCMPH_W<'a, REG> = crate::FieldWriter<'a, REG, 2, GCMPH, crate::Safe>;
703impl<'a, REG> GCMPH_W<'a, REG>
704where
705    REG: crate::Writable + crate::RegisterSpec,
706    REG::Ux: From<u8>,
707{
708    ///Init phase
709    #[inline(always)]
710    pub fn init(self) -> &'a mut crate::W<REG> {
711        self.variant(GCMPH::Init)
712    }
713    ///Header phase
714    #[inline(always)]
715    pub fn header(self) -> &'a mut crate::W<REG> {
716        self.variant(GCMPH::Header)
717    }
718    ///Payload phase
719    #[inline(always)]
720    pub fn payload(self) -> &'a mut crate::W<REG> {
721        self.variant(GCMPH::Payload)
722    }
723    ///Final Phase
724    #[inline(always)]
725    pub fn final_(self) -> &'a mut crate::W<REG> {
726        self.variant(GCMPH::Final)
727    }
728}
729/**AES chaining mode Bit2
730
731Value on reset: 0*/
732#[cfg_attr(feature = "defmt", derive(defmt::Format))]
733#[derive(Clone, Copy, Debug, PartialEq, Eq)]
734pub enum CHMOD2 {
735    ///0: Mode as per CHMOD (ECB, CBC, CTR, GCM)
736    Chmod = 0,
737    ///1: Counter with CBC-MAC (CCM) - CHMOD must be 0 (ECB)
738    Ccm = 1,
739}
740impl From<CHMOD2> for bool {
741    #[inline(always)]
742    fn from(variant: CHMOD2) -> Self {
743        variant as u8 != 0
744    }
745}
746///Field `CHMOD2` reader - AES chaining mode Bit2
747pub type CHMOD2_R = crate::BitReader<CHMOD2>;
748impl CHMOD2_R {
749    ///Get enumerated values variant
750    #[inline(always)]
751    pub const fn variant(&self) -> CHMOD2 {
752        match self.bits {
753            false => CHMOD2::Chmod,
754            true => CHMOD2::Ccm,
755        }
756    }
757    ///Mode as per CHMOD (ECB, CBC, CTR, GCM)
758    #[inline(always)]
759    pub fn is_chmod(&self) -> bool {
760        *self == CHMOD2::Chmod
761    }
762    ///Counter with CBC-MAC (CCM) - CHMOD must be 0 (ECB)
763    #[inline(always)]
764    pub fn is_ccm(&self) -> bool {
765        *self == CHMOD2::Ccm
766    }
767}
768///Field `CHMOD2` writer - AES chaining mode Bit2
769pub type CHMOD2_W<'a, REG> = crate::BitWriter<'a, REG, CHMOD2>;
770impl<'a, REG> CHMOD2_W<'a, REG>
771where
772    REG: crate::Writable + crate::RegisterSpec,
773{
774    ///Mode as per CHMOD (ECB, CBC, CTR, GCM)
775    #[inline(always)]
776    pub fn chmod(self) -> &'a mut crate::W<REG> {
777        self.variant(CHMOD2::Chmod)
778    }
779    ///Counter with CBC-MAC (CCM) - CHMOD must be 0 (ECB)
780    #[inline(always)]
781    pub fn ccm(self) -> &'a mut crate::W<REG> {
782        self.variant(CHMOD2::Ccm)
783    }
784}
785/**Key size selection
786
787Value on reset: 0*/
788#[cfg_attr(feature = "defmt", derive(defmt::Format))]
789#[derive(Clone, Copy, Debug, PartialEq, Eq)]
790pub enum KEYSIZE {
791    ///0: 128
792    Aes128 = 0,
793    ///1: 256
794    Aes256 = 1,
795}
796impl From<KEYSIZE> for bool {
797    #[inline(always)]
798    fn from(variant: KEYSIZE) -> Self {
799        variant as u8 != 0
800    }
801}
802///Field `KEYSIZE` reader - Key size selection
803pub type KEYSIZE_R = crate::BitReader<KEYSIZE>;
804impl KEYSIZE_R {
805    ///Get enumerated values variant
806    #[inline(always)]
807    pub const fn variant(&self) -> KEYSIZE {
808        match self.bits {
809            false => KEYSIZE::Aes128,
810            true => KEYSIZE::Aes256,
811        }
812    }
813    ///128
814    #[inline(always)]
815    pub fn is_aes128(&self) -> bool {
816        *self == KEYSIZE::Aes128
817    }
818    ///256
819    #[inline(always)]
820    pub fn is_aes256(&self) -> bool {
821        *self == KEYSIZE::Aes256
822    }
823}
824///Field `KEYSIZE` writer - Key size selection
825pub type KEYSIZE_W<'a, REG> = crate::BitWriter<'a, REG, KEYSIZE>;
826impl<'a, REG> KEYSIZE_W<'a, REG>
827where
828    REG: crate::Writable + crate::RegisterSpec,
829{
830    ///128
831    #[inline(always)]
832    pub fn aes128(self) -> &'a mut crate::W<REG> {
833        self.variant(KEYSIZE::Aes128)
834    }
835    ///256
836    #[inline(always)]
837    pub fn aes256(self) -> &'a mut crate::W<REG> {
838        self.variant(KEYSIZE::Aes256)
839    }
840}
841///Field `NPBLB` reader - Number of padding bytes in last block of payload
842pub type NPBLB_R = crate::FieldReader;
843///Field `NPBLB` writer - Number of padding bytes in last block of payload
844pub type NPBLB_W<'a, REG> = crate::FieldWriter<'a, REG, 4, u8, crate::Safe>;
845impl R {
846    ///Bit 0 - AES enable
847    #[inline(always)]
848    pub fn en(&self) -> EN_R {
849        EN_R::new((self.bits & 1) != 0)
850    }
851    ///Bits 1:2 - Data type selection (for data in and data out to/from the cryptographic block)
852    #[inline(always)]
853    pub fn datatype(&self) -> DATATYPE_R {
854        DATATYPE_R::new(((self.bits >> 1) & 3) as u8)
855    }
856    ///Bits 3:4 - AES operating mode
857    #[inline(always)]
858    pub fn mode(&self) -> MODE_R {
859        MODE_R::new(((self.bits >> 3) & 3) as u8)
860    }
861    ///Bits 5:6 - AES chaining mode Bit1 Bit0
862    #[inline(always)]
863    pub fn chmod10(&self) -> CHMOD10_R {
864        CHMOD10_R::new(((self.bits >> 5) & 3) as u8)
865    }
866    ///Bit 7 - Computation Complete Flag Clear
867    #[inline(always)]
868    pub fn ccfc(&self) -> CCFC_R {
869        CCFC_R::new(((self.bits >> 7) & 1) != 0)
870    }
871    ///Bit 8 - Error clear
872    #[inline(always)]
873    pub fn errc(&self) -> ERRC_R {
874        ERRC_R::new(((self.bits >> 8) & 1) != 0)
875    }
876    ///Bit 9 - CCF flag interrupt enable
877    #[inline(always)]
878    pub fn ccfie(&self) -> CCFIE_R {
879        CCFIE_R::new(((self.bits >> 9) & 1) != 0)
880    }
881    ///Bit 10 - Error interrupt enable
882    #[inline(always)]
883    pub fn errie(&self) -> ERRIE_R {
884        ERRIE_R::new(((self.bits >> 10) & 1) != 0)
885    }
886    ///Bit 11 - Enable DMA management of data input phase
887    #[inline(always)]
888    pub fn dmainen(&self) -> DMAINEN_R {
889        DMAINEN_R::new(((self.bits >> 11) & 1) != 0)
890    }
891    ///Bit 12 - Enable DMA management of data output phase
892    #[inline(always)]
893    pub fn dmaouten(&self) -> DMAOUTEN_R {
894        DMAOUTEN_R::new(((self.bits >> 12) & 1) != 0)
895    }
896    ///Bits 13:14 - Used only for GCM, CCM and GMAC algorithms and has no effect when other algorithms are selected
897    #[inline(always)]
898    pub fn gcmph(&self) -> GCMPH_R {
899        GCMPH_R::new(((self.bits >> 13) & 3) as u8)
900    }
901    ///Bit 16 - AES chaining mode Bit2
902    #[inline(always)]
903    pub fn chmod2(&self) -> CHMOD2_R {
904        CHMOD2_R::new(((self.bits >> 16) & 1) != 0)
905    }
906    ///Bit 18 - Key size selection
907    #[inline(always)]
908    pub fn keysize(&self) -> KEYSIZE_R {
909        KEYSIZE_R::new(((self.bits >> 18) & 1) != 0)
910    }
911    ///Bits 20:23 - Number of padding bytes in last block of payload
912    #[inline(always)]
913    pub fn npblb(&self) -> NPBLB_R {
914        NPBLB_R::new(((self.bits >> 20) & 0x0f) as u8)
915    }
916}
917impl core::fmt::Debug for R {
918    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
919        f.debug_struct("CR")
920            .field("npblb", &self.npblb())
921            .field("keysize", &self.keysize())
922            .field("chmod2", &self.chmod2())
923            .field("gcmph", &self.gcmph())
924            .field("dmaouten", &self.dmaouten())
925            .field("dmainen", &self.dmainen())
926            .field("errie", &self.errie())
927            .field("ccfie", &self.ccfie())
928            .field("errc", &self.errc())
929            .field("ccfc", &self.ccfc())
930            .field("chmod10", &self.chmod10())
931            .field("mode", &self.mode())
932            .field("datatype", &self.datatype())
933            .field("en", &self.en())
934            .finish()
935    }
936}
937impl W {
938    ///Bit 0 - AES enable
939    #[inline(always)]
940    pub fn en(&mut self) -> EN_W<CRrs> {
941        EN_W::new(self, 0)
942    }
943    ///Bits 1:2 - Data type selection (for data in and data out to/from the cryptographic block)
944    #[inline(always)]
945    pub fn datatype(&mut self) -> DATATYPE_W<CRrs> {
946        DATATYPE_W::new(self, 1)
947    }
948    ///Bits 3:4 - AES operating mode
949    #[inline(always)]
950    pub fn mode(&mut self) -> MODE_W<CRrs> {
951        MODE_W::new(self, 3)
952    }
953    ///Bits 5:6 - AES chaining mode Bit1 Bit0
954    #[inline(always)]
955    pub fn chmod10(&mut self) -> CHMOD10_W<CRrs> {
956        CHMOD10_W::new(self, 5)
957    }
958    ///Bit 7 - Computation Complete Flag Clear
959    #[inline(always)]
960    pub fn ccfc(&mut self) -> CCFC_W<CRrs> {
961        CCFC_W::new(self, 7)
962    }
963    ///Bit 8 - Error clear
964    #[inline(always)]
965    pub fn errc(&mut self) -> ERRC_W<CRrs> {
966        ERRC_W::new(self, 8)
967    }
968    ///Bit 9 - CCF flag interrupt enable
969    #[inline(always)]
970    pub fn ccfie(&mut self) -> CCFIE_W<CRrs> {
971        CCFIE_W::new(self, 9)
972    }
973    ///Bit 10 - Error interrupt enable
974    #[inline(always)]
975    pub fn errie(&mut self) -> ERRIE_W<CRrs> {
976        ERRIE_W::new(self, 10)
977    }
978    ///Bit 11 - Enable DMA management of data input phase
979    #[inline(always)]
980    pub fn dmainen(&mut self) -> DMAINEN_W<CRrs> {
981        DMAINEN_W::new(self, 11)
982    }
983    ///Bit 12 - Enable DMA management of data output phase
984    #[inline(always)]
985    pub fn dmaouten(&mut self) -> DMAOUTEN_W<CRrs> {
986        DMAOUTEN_W::new(self, 12)
987    }
988    ///Bits 13:14 - Used only for GCM, CCM and GMAC algorithms and has no effect when other algorithms are selected
989    #[inline(always)]
990    pub fn gcmph(&mut self) -> GCMPH_W<CRrs> {
991        GCMPH_W::new(self, 13)
992    }
993    ///Bit 16 - AES chaining mode Bit2
994    #[inline(always)]
995    pub fn chmod2(&mut self) -> CHMOD2_W<CRrs> {
996        CHMOD2_W::new(self, 16)
997    }
998    ///Bit 18 - Key size selection
999    #[inline(always)]
1000    pub fn keysize(&mut self) -> KEYSIZE_W<CRrs> {
1001        KEYSIZE_W::new(self, 18)
1002    }
1003    ///Bits 20:23 - Number of padding bytes in last block of payload
1004    #[inline(always)]
1005    pub fn npblb(&mut self) -> NPBLB_W<CRrs> {
1006        NPBLB_W::new(self, 20)
1007    }
1008}
1009/**control register
1010
1011You can [`read`](crate::Reg::read) this register and get [`cr::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`cr::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api).
1012
1013See register [structure](https://stm32-rs.github.io/stm32-rs/STM32G041.html#AES:CR)*/
1014pub struct CRrs;
1015impl crate::RegisterSpec for CRrs {
1016    type Ux = u32;
1017}
1018///`read()` method returns [`cr::R`](R) reader structure
1019impl crate::Readable for CRrs {}
1020///`write(|w| ..)` method takes [`cr::W`](W) writer structure
1021impl crate::Writable for CRrs {
1022    type Safety = crate::Unsafe;
1023}
1024///`reset()` method sets CR to value 0
1025impl crate::Resettable for CRrs {}