max78000_pac/aes/
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 = "Field `EN` reader - AES Enable"]
6pub type EnR = crate::BitReader;
7#[doc = "Field `EN` writer - AES Enable"]
8pub type EnW<'a, REG> = crate::BitWriter<'a, REG>;
9#[doc = "Field `DMA_RX_EN` reader - DMA Request To Read Data Output FIFO"]
10pub type DmaRxEnR = crate::BitReader;
11#[doc = "Field `DMA_RX_EN` writer - DMA Request To Read Data Output FIFO"]
12pub type DmaRxEnW<'a, REG> = crate::BitWriter<'a, REG>;
13#[doc = "Field `DMA_TX_EN` reader - DMA Request To Write Data Input FIFO"]
14pub type DmaTxEnR = crate::BitReader;
15#[doc = "Field `DMA_TX_EN` writer - DMA Request To Write Data Input FIFO"]
16pub type DmaTxEnW<'a, REG> = crate::BitWriter<'a, REG>;
17#[doc = "Field `START` reader - Start AES Calculation"]
18pub type StartR = crate::BitReader;
19#[doc = "Field `START` writer - Start AES Calculation"]
20pub type StartW<'a, REG> = crate::BitWriter<'a, REG>;
21#[doc = "Field `INPUT_FLUSH` reader - Flush the data input FIFO"]
22pub type InputFlushR = crate::BitReader;
23#[doc = "Field `INPUT_FLUSH` writer - Flush the data input FIFO"]
24pub type InputFlushW<'a, REG> = crate::BitWriter<'a, REG>;
25#[doc = "Field `OUTPUT_FLUSH` reader - Flush the data output FIFO"]
26pub type OutputFlushR = crate::BitReader;
27#[doc = "Field `OUTPUT_FLUSH` writer - Flush the data output FIFO"]
28pub type OutputFlushW<'a, REG> = crate::BitWriter<'a, REG>;
29#[doc = "Encryption Key Size\n\nValue on reset: 0"]
30#[derive(Clone, Copy, Debug, PartialEq, Eq)]
31#[repr(u8)]
32pub enum KeySize {
33    #[doc = "0: 128 Bits."]
34    Aes128 = 0,
35    #[doc = "1: 192 Bits."]
36    Aes192 = 1,
37    #[doc = "2: 256 Bits."]
38    Aes256 = 2,
39}
40impl From<KeySize> for u8 {
41    #[inline(always)]
42    fn from(variant: KeySize) -> Self {
43        variant as _
44    }
45}
46impl crate::FieldSpec for KeySize {
47    type Ux = u8;
48}
49impl crate::IsEnum for KeySize {}
50#[doc = "Field `KEY_SIZE` reader - Encryption Key Size"]
51pub type KeySizeR = crate::FieldReader<KeySize>;
52impl KeySizeR {
53    #[doc = "Get enumerated values variant"]
54    #[inline(always)]
55    pub const fn variant(&self) -> Option<KeySize> {
56        match self.bits {
57            0 => Some(KeySize::Aes128),
58            1 => Some(KeySize::Aes192),
59            2 => Some(KeySize::Aes256),
60            _ => None,
61        }
62    }
63    #[doc = "128 Bits."]
64    #[inline(always)]
65    pub fn is_aes128(&self) -> bool {
66        *self == KeySize::Aes128
67    }
68    #[doc = "192 Bits."]
69    #[inline(always)]
70    pub fn is_aes192(&self) -> bool {
71        *self == KeySize::Aes192
72    }
73    #[doc = "256 Bits."]
74    #[inline(always)]
75    pub fn is_aes256(&self) -> bool {
76        *self == KeySize::Aes256
77    }
78}
79#[doc = "Field `KEY_SIZE` writer - Encryption Key Size"]
80pub type KeySizeW<'a, REG> = crate::FieldWriter<'a, REG, 2, KeySize>;
81impl<'a, REG> KeySizeW<'a, REG>
82where
83    REG: crate::Writable + crate::RegisterSpec,
84    REG::Ux: From<u8>,
85{
86    #[doc = "128 Bits."]
87    #[inline(always)]
88    pub fn aes128(self) -> &'a mut crate::W<REG> {
89        self.variant(KeySize::Aes128)
90    }
91    #[doc = "192 Bits."]
92    #[inline(always)]
93    pub fn aes192(self) -> &'a mut crate::W<REG> {
94        self.variant(KeySize::Aes192)
95    }
96    #[doc = "256 Bits."]
97    #[inline(always)]
98    pub fn aes256(self) -> &'a mut crate::W<REG> {
99        self.variant(KeySize::Aes256)
100    }
101}
102#[doc = "Encryption Type Selection\n\nValue on reset: 0"]
103#[derive(Clone, Copy, Debug, PartialEq, Eq)]
104#[repr(u8)]
105pub enum Type {
106    #[doc = "0: Encryption using the external AES key."]
107    EncExt = 0,
108    #[doc = "1: Decryption using the external AES key."]
109    DecExt = 1,
110    #[doc = "2: Decryption using the locally generated decryption key."]
111    DecInt = 2,
112}
113impl From<Type> for u8 {
114    #[inline(always)]
115    fn from(variant: Type) -> Self {
116        variant as _
117    }
118}
119impl crate::FieldSpec for Type {
120    type Ux = u8;
121}
122impl crate::IsEnum for Type {}
123#[doc = "Field `TYPE` reader - Encryption Type Selection"]
124pub type TypeR = crate::FieldReader<Type>;
125impl TypeR {
126    #[doc = "Get enumerated values variant"]
127    #[inline(always)]
128    pub const fn variant(&self) -> Option<Type> {
129        match self.bits {
130            0 => Some(Type::EncExt),
131            1 => Some(Type::DecExt),
132            2 => Some(Type::DecInt),
133            _ => None,
134        }
135    }
136    #[doc = "Encryption using the external AES key."]
137    #[inline(always)]
138    pub fn is_enc_ext(&self) -> bool {
139        *self == Type::EncExt
140    }
141    #[doc = "Decryption using the external AES key."]
142    #[inline(always)]
143    pub fn is_dec_ext(&self) -> bool {
144        *self == Type::DecExt
145    }
146    #[doc = "Decryption using the locally generated decryption key."]
147    #[inline(always)]
148    pub fn is_dec_int(&self) -> bool {
149        *self == Type::DecInt
150    }
151}
152#[doc = "Field `TYPE` writer - Encryption Type Selection"]
153pub type TypeW<'a, REG> = crate::FieldWriter<'a, REG, 2, Type>;
154impl<'a, REG> TypeW<'a, REG>
155where
156    REG: crate::Writable + crate::RegisterSpec,
157    REG::Ux: From<u8>,
158{
159    #[doc = "Encryption using the external AES key."]
160    #[inline(always)]
161    pub fn enc_ext(self) -> &'a mut crate::W<REG> {
162        self.variant(Type::EncExt)
163    }
164    #[doc = "Decryption using the external AES key."]
165    #[inline(always)]
166    pub fn dec_ext(self) -> &'a mut crate::W<REG> {
167        self.variant(Type::DecExt)
168    }
169    #[doc = "Decryption using the locally generated decryption key."]
170    #[inline(always)]
171    pub fn dec_int(self) -> &'a mut crate::W<REG> {
172        self.variant(Type::DecInt)
173    }
174}
175impl R {
176    #[doc = "Bit 0 - AES Enable"]
177    #[inline(always)]
178    pub fn en(&self) -> EnR {
179        EnR::new((self.bits & 1) != 0)
180    }
181    #[doc = "Bit 1 - DMA Request To Read Data Output FIFO"]
182    #[inline(always)]
183    pub fn dma_rx_en(&self) -> DmaRxEnR {
184        DmaRxEnR::new(((self.bits >> 1) & 1) != 0)
185    }
186    #[doc = "Bit 2 - DMA Request To Write Data Input FIFO"]
187    #[inline(always)]
188    pub fn dma_tx_en(&self) -> DmaTxEnR {
189        DmaTxEnR::new(((self.bits >> 2) & 1) != 0)
190    }
191    #[doc = "Bit 3 - Start AES Calculation"]
192    #[inline(always)]
193    pub fn start(&self) -> StartR {
194        StartR::new(((self.bits >> 3) & 1) != 0)
195    }
196    #[doc = "Bit 4 - Flush the data input FIFO"]
197    #[inline(always)]
198    pub fn input_flush(&self) -> InputFlushR {
199        InputFlushR::new(((self.bits >> 4) & 1) != 0)
200    }
201    #[doc = "Bit 5 - Flush the data output FIFO"]
202    #[inline(always)]
203    pub fn output_flush(&self) -> OutputFlushR {
204        OutputFlushR::new(((self.bits >> 5) & 1) != 0)
205    }
206    #[doc = "Bits 6:7 - Encryption Key Size"]
207    #[inline(always)]
208    pub fn key_size(&self) -> KeySizeR {
209        KeySizeR::new(((self.bits >> 6) & 3) as u8)
210    }
211    #[doc = "Bits 8:9 - Encryption Type Selection"]
212    #[inline(always)]
213    pub fn type_(&self) -> TypeR {
214        TypeR::new(((self.bits >> 8) & 3) as u8)
215    }
216}
217impl W {
218    #[doc = "Bit 0 - AES Enable"]
219    #[inline(always)]
220    pub fn en(&mut self) -> EnW<CtrlSpec> {
221        EnW::new(self, 0)
222    }
223    #[doc = "Bit 1 - DMA Request To Read Data Output FIFO"]
224    #[inline(always)]
225    pub fn dma_rx_en(&mut self) -> DmaRxEnW<CtrlSpec> {
226        DmaRxEnW::new(self, 1)
227    }
228    #[doc = "Bit 2 - DMA Request To Write Data Input FIFO"]
229    #[inline(always)]
230    pub fn dma_tx_en(&mut self) -> DmaTxEnW<CtrlSpec> {
231        DmaTxEnW::new(self, 2)
232    }
233    #[doc = "Bit 3 - Start AES Calculation"]
234    #[inline(always)]
235    pub fn start(&mut self) -> StartW<CtrlSpec> {
236        StartW::new(self, 3)
237    }
238    #[doc = "Bit 4 - Flush the data input FIFO"]
239    #[inline(always)]
240    pub fn input_flush(&mut self) -> InputFlushW<CtrlSpec> {
241        InputFlushW::new(self, 4)
242    }
243    #[doc = "Bit 5 - Flush the data output FIFO"]
244    #[inline(always)]
245    pub fn output_flush(&mut self) -> OutputFlushW<CtrlSpec> {
246        OutputFlushW::new(self, 5)
247    }
248    #[doc = "Bits 6:7 - Encryption Key Size"]
249    #[inline(always)]
250    pub fn key_size(&mut self) -> KeySizeW<CtrlSpec> {
251        KeySizeW::new(self, 6)
252    }
253    #[doc = "Bits 8:9 - Encryption Type Selection"]
254    #[inline(always)]
255    pub fn type_(&mut self) -> TypeW<CtrlSpec> {
256        TypeW::new(self, 8)
257    }
258}
259#[doc = "AES 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)."]
260pub struct CtrlSpec;
261impl crate::RegisterSpec for CtrlSpec {
262    type Ux = u32;
263}
264#[doc = "`read()` method returns [`ctrl::R`](R) reader structure"]
265impl crate::Readable for CtrlSpec {}
266#[doc = "`write(|w| ..)` method takes [`ctrl::W`](W) writer structure"]
267impl crate::Writable for CtrlSpec {
268    type Safety = crate::Unsafe;
269    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
270    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
271}
272#[doc = "`reset()` method sets CTRL to value 0"]
273impl crate::Resettable for CtrlSpec {
274    const RESET_VALUE: u32 = 0;
275}