1 | #![allow (clippy::missing_safety_doc)] |
2 | #![allow (clippy::identity_op)] |
3 | #![allow (clippy::unnecessary_cast)] |
4 | #![allow (clippy::erasing_op)] |
5 | |
6 | #[doc = "Hash processor." ] |
7 | #[derive (Copy, Clone, Eq, PartialEq)] |
8 | pub struct Hash { |
9 | ptr: *mut u8, |
10 | } |
11 | unsafe impl Send for Hash {} |
12 | unsafe impl Sync for Hash {} |
13 | impl Hash { |
14 | #[inline (always)] |
15 | pub const unsafe fn from_ptr(ptr: *mut ()) -> Self { |
16 | Self { ptr: ptr as _ } |
17 | } |
18 | #[inline (always)] |
19 | pub const fn as_ptr(&self) -> *mut () { |
20 | self.ptr as _ |
21 | } |
22 | #[doc = "control register." ] |
23 | #[inline (always)] |
24 | pub const fn cr(self) -> crate::common::Reg<regs::Cr, crate::common::RW> { |
25 | unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x0usize) as _) } |
26 | } |
27 | #[doc = "data input register." ] |
28 | #[inline (always)] |
29 | pub const fn din(self) -> crate::common::Reg<u32, crate::common::W> { |
30 | unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x04usize) as _) } |
31 | } |
32 | #[doc = "start register." ] |
33 | #[inline (always)] |
34 | pub const fn str(self) -> crate::common::Reg<regs::Str, crate::common::RW> { |
35 | unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x08usize) as _) } |
36 | } |
37 | #[doc = "digest registers." ] |
38 | #[inline (always)] |
39 | pub const fn hra(self, n: usize) -> crate::common::Reg<u32, crate::common::RW> { |
40 | assert!(n < 5usize); |
41 | unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x0cusize + n * 4usize) as _) } |
42 | } |
43 | #[doc = "interrupt enable register." ] |
44 | #[inline (always)] |
45 | pub const fn imr(self) -> crate::common::Reg<regs::Imr, crate::common::RW> { |
46 | unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x20usize) as _) } |
47 | } |
48 | #[doc = "status register." ] |
49 | #[inline (always)] |
50 | pub const fn sr(self) -> crate::common::Reg<regs::Sr, crate::common::RW> { |
51 | unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x24usize) as _) } |
52 | } |
53 | #[doc = "context swap registers." ] |
54 | #[inline (always)] |
55 | pub const fn csr(self, n: usize) -> crate::common::Reg<u32, crate::common::RW> { |
56 | assert!(n < 54usize); |
57 | unsafe { crate::common::Reg::from_ptr(self.ptr.add(0xf8usize + n * 4usize) as _) } |
58 | } |
59 | #[doc = "HASH digest register." ] |
60 | #[inline (always)] |
61 | pub const fn hr(self, n: usize) -> crate::common::Reg<u32, crate::common::R> { |
62 | assert!(n < 8usize); |
63 | unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x0310usize + n * 4usize) as _) } |
64 | } |
65 | } |
66 | pub mod regs { |
67 | #[doc = "control register." ] |
68 | #[repr (transparent)] |
69 | #[derive (Copy, Clone, Eq, PartialEq)] |
70 | pub struct Cr(pub u32); |
71 | impl Cr { |
72 | #[doc = "Initialize message digest calculation." ] |
73 | #[inline (always)] |
74 | pub const fn init(&self) -> bool { |
75 | let val = (self.0 >> 2usize) & 0x01; |
76 | val != 0 |
77 | } |
78 | #[doc = "Initialize message digest calculation." ] |
79 | #[inline (always)] |
80 | pub fn set_init(&mut self, val: bool) { |
81 | self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize); |
82 | } |
83 | #[doc = "DMA enable." ] |
84 | #[inline (always)] |
85 | pub const fn dmae(&self) -> bool { |
86 | let val = (self.0 >> 3usize) & 0x01; |
87 | val != 0 |
88 | } |
89 | #[doc = "DMA enable." ] |
90 | #[inline (always)] |
91 | pub fn set_dmae(&mut self, val: bool) { |
92 | self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize); |
93 | } |
94 | #[doc = "Data type selection." ] |
95 | #[inline (always)] |
96 | pub const fn datatype(&self) -> u8 { |
97 | let val = (self.0 >> 4usize) & 0x03; |
98 | val as u8 |
99 | } |
100 | #[doc = "Data type selection." ] |
101 | #[inline (always)] |
102 | pub fn set_datatype(&mut self, val: u8) { |
103 | self.0 = (self.0 & !(0x03 << 4usize)) | (((val as u32) & 0x03) << 4usize); |
104 | } |
105 | #[doc = "Mode selection." ] |
106 | #[inline (always)] |
107 | pub const fn mode(&self) -> bool { |
108 | let val = (self.0 >> 6usize) & 0x01; |
109 | val != 0 |
110 | } |
111 | #[doc = "Mode selection." ] |
112 | #[inline (always)] |
113 | pub fn set_mode(&mut self, val: bool) { |
114 | self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize); |
115 | } |
116 | #[doc = "Number of words already pushed." ] |
117 | #[inline (always)] |
118 | pub const fn nbw(&self) -> u8 { |
119 | let val = (self.0 >> 8usize) & 0x0f; |
120 | val as u8 |
121 | } |
122 | #[doc = "Number of words already pushed." ] |
123 | #[inline (always)] |
124 | pub fn set_nbw(&mut self, val: u8) { |
125 | self.0 = (self.0 & !(0x0f << 8usize)) | (((val as u32) & 0x0f) << 8usize); |
126 | } |
127 | #[doc = "DIN not empty." ] |
128 | #[inline (always)] |
129 | pub const fn dinne(&self) -> bool { |
130 | let val = (self.0 >> 12usize) & 0x01; |
131 | val != 0 |
132 | } |
133 | #[doc = "DIN not empty." ] |
134 | #[inline (always)] |
135 | pub fn set_dinne(&mut self, val: bool) { |
136 | self.0 = (self.0 & !(0x01 << 12usize)) | (((val as u32) & 0x01) << 12usize); |
137 | } |
138 | #[doc = "Multiple DMA Transfers." ] |
139 | #[inline (always)] |
140 | pub const fn mdmat(&self) -> bool { |
141 | let val = (self.0 >> 13usize) & 0x01; |
142 | val != 0 |
143 | } |
144 | #[doc = "Multiple DMA Transfers." ] |
145 | #[inline (always)] |
146 | pub fn set_mdmat(&mut self, val: bool) { |
147 | self.0 = (self.0 & !(0x01 << 13usize)) | (((val as u32) & 0x01) << 13usize); |
148 | } |
149 | #[doc = "Long key selection." ] |
150 | #[inline (always)] |
151 | pub const fn lkey(&self) -> bool { |
152 | let val = (self.0 >> 16usize) & 0x01; |
153 | val != 0 |
154 | } |
155 | #[doc = "Long key selection." ] |
156 | #[inline (always)] |
157 | pub fn set_lkey(&mut self, val: bool) { |
158 | self.0 = (self.0 & !(0x01 << 16usize)) | (((val as u32) & 0x01) << 16usize); |
159 | } |
160 | #[doc = "Algorithm selection." ] |
161 | #[inline (always)] |
162 | pub const fn algo(&self) -> u8 { |
163 | let val = (self.0 >> 17usize) & 0x03; |
164 | val as u8 |
165 | } |
166 | #[doc = "Algorithm selection." ] |
167 | #[inline (always)] |
168 | pub fn set_algo(&mut self, val: u8) { |
169 | self.0 = (self.0 & !(0x03 << 17usize)) | (((val as u32) & 0x03) << 17usize); |
170 | } |
171 | } |
172 | impl Default for Cr { |
173 | #[inline (always)] |
174 | fn default() -> Cr { |
175 | Cr(0) |
176 | } |
177 | } |
178 | impl core::fmt::Debug for Cr { |
179 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { |
180 | f.debug_struct("Cr" ) |
181 | .field("init" , &self.init()) |
182 | .field("dmae" , &self.dmae()) |
183 | .field("datatype" , &self.datatype()) |
184 | .field("mode" , &self.mode()) |
185 | .field("nbw" , &self.nbw()) |
186 | .field("dinne" , &self.dinne()) |
187 | .field("mdmat" , &self.mdmat()) |
188 | .field("lkey" , &self.lkey()) |
189 | .field("algo" , &self.algo()) |
190 | .finish() |
191 | } |
192 | } |
193 | #[cfg (feature = "defmt" )] |
194 | impl defmt::Format for Cr { |
195 | fn format(&self, f: defmt::Formatter) { |
196 | #[derive (defmt :: Format)] |
197 | struct Cr { |
198 | init: bool, |
199 | dmae: bool, |
200 | datatype: u8, |
201 | mode: bool, |
202 | nbw: u8, |
203 | dinne: bool, |
204 | mdmat: bool, |
205 | lkey: bool, |
206 | algo: u8, |
207 | } |
208 | let proxy = Cr { |
209 | init: self.init(), |
210 | dmae: self.dmae(), |
211 | datatype: self.datatype(), |
212 | mode: self.mode(), |
213 | nbw: self.nbw(), |
214 | dinne: self.dinne(), |
215 | mdmat: self.mdmat(), |
216 | lkey: self.lkey(), |
217 | algo: self.algo(), |
218 | }; |
219 | defmt::write!(f, "{}" , proxy) |
220 | } |
221 | } |
222 | #[doc = "interrupt enable register." ] |
223 | #[repr (transparent)] |
224 | #[derive (Copy, Clone, Eq, PartialEq)] |
225 | pub struct Imr(pub u32); |
226 | impl Imr { |
227 | #[doc = "Data input interrupt enable." ] |
228 | #[inline (always)] |
229 | pub const fn dinie(&self) -> bool { |
230 | let val = (self.0 >> 0usize) & 0x01; |
231 | val != 0 |
232 | } |
233 | #[doc = "Data input interrupt enable." ] |
234 | #[inline (always)] |
235 | pub fn set_dinie(&mut self, val: bool) { |
236 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); |
237 | } |
238 | #[doc = "Digest calculation completion interrupt enable." ] |
239 | #[inline (always)] |
240 | pub const fn dcie(&self) -> bool { |
241 | let val = (self.0 >> 1usize) & 0x01; |
242 | val != 0 |
243 | } |
244 | #[doc = "Digest calculation completion interrupt enable." ] |
245 | #[inline (always)] |
246 | pub fn set_dcie(&mut self, val: bool) { |
247 | self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize); |
248 | } |
249 | } |
250 | impl Default for Imr { |
251 | #[inline (always)] |
252 | fn default() -> Imr { |
253 | Imr(0) |
254 | } |
255 | } |
256 | impl core::fmt::Debug for Imr { |
257 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { |
258 | f.debug_struct("Imr" ) |
259 | .field("dinie" , &self.dinie()) |
260 | .field("dcie" , &self.dcie()) |
261 | .finish() |
262 | } |
263 | } |
264 | #[cfg (feature = "defmt" )] |
265 | impl defmt::Format for Imr { |
266 | fn format(&self, f: defmt::Formatter) { |
267 | #[derive (defmt :: Format)] |
268 | struct Imr { |
269 | dinie: bool, |
270 | dcie: bool, |
271 | } |
272 | let proxy = Imr { |
273 | dinie: self.dinie(), |
274 | dcie: self.dcie(), |
275 | }; |
276 | defmt::write!(f, "{}" , proxy) |
277 | } |
278 | } |
279 | #[doc = "status register." ] |
280 | #[repr (transparent)] |
281 | #[derive (Copy, Clone, Eq, PartialEq)] |
282 | pub struct Sr(pub u32); |
283 | impl Sr { |
284 | #[doc = "Data input interrupt status." ] |
285 | #[inline (always)] |
286 | pub const fn dinis(&self) -> bool { |
287 | let val = (self.0 >> 0usize) & 0x01; |
288 | val != 0 |
289 | } |
290 | #[doc = "Data input interrupt status." ] |
291 | #[inline (always)] |
292 | pub fn set_dinis(&mut self, val: bool) { |
293 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); |
294 | } |
295 | #[doc = "Digest calculation completion interrupt status." ] |
296 | #[inline (always)] |
297 | pub const fn dcis(&self) -> bool { |
298 | let val = (self.0 >> 1usize) & 0x01; |
299 | val != 0 |
300 | } |
301 | #[doc = "Digest calculation completion interrupt status." ] |
302 | #[inline (always)] |
303 | pub fn set_dcis(&mut self, val: bool) { |
304 | self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize); |
305 | } |
306 | #[doc = "DMA Status." ] |
307 | #[inline (always)] |
308 | pub const fn dmas(&self) -> bool { |
309 | let val = (self.0 >> 2usize) & 0x01; |
310 | val != 0 |
311 | } |
312 | #[doc = "DMA Status." ] |
313 | #[inline (always)] |
314 | pub fn set_dmas(&mut self, val: bool) { |
315 | self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize); |
316 | } |
317 | #[doc = "Busy bit." ] |
318 | #[inline (always)] |
319 | pub const fn busy(&self) -> bool { |
320 | let val = (self.0 >> 3usize) & 0x01; |
321 | val != 0 |
322 | } |
323 | #[doc = "Busy bit." ] |
324 | #[inline (always)] |
325 | pub fn set_busy(&mut self, val: bool) { |
326 | self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize); |
327 | } |
328 | #[doc = "Number of words already pushed." ] |
329 | #[inline (always)] |
330 | pub const fn nbwp(&self) -> u8 { |
331 | let val = (self.0 >> 9usize) & 0x1f; |
332 | val as u8 |
333 | } |
334 | #[doc = "Number of words already pushed." ] |
335 | #[inline (always)] |
336 | pub fn set_nbwp(&mut self, val: u8) { |
337 | self.0 = (self.0 & !(0x1f << 9usize)) | (((val as u32) & 0x1f) << 9usize); |
338 | } |
339 | #[doc = "DIN not empty." ] |
340 | #[inline (always)] |
341 | pub const fn dinne(&self) -> bool { |
342 | let val = (self.0 >> 15usize) & 0x01; |
343 | val != 0 |
344 | } |
345 | #[doc = "DIN not empty." ] |
346 | #[inline (always)] |
347 | pub fn set_dinne(&mut self, val: bool) { |
348 | self.0 = (self.0 & !(0x01 << 15usize)) | (((val as u32) & 0x01) << 15usize); |
349 | } |
350 | #[doc = "Number of words expected." ] |
351 | #[inline (always)] |
352 | pub const fn nbwe(&self) -> u8 { |
353 | let val = (self.0 >> 16usize) & 0x1f; |
354 | val as u8 |
355 | } |
356 | #[doc = "Number of words expected." ] |
357 | #[inline (always)] |
358 | pub fn set_nbwe(&mut self, val: u8) { |
359 | self.0 = (self.0 & !(0x1f << 16usize)) | (((val as u32) & 0x1f) << 16usize); |
360 | } |
361 | } |
362 | impl Default for Sr { |
363 | #[inline (always)] |
364 | fn default() -> Sr { |
365 | Sr(0) |
366 | } |
367 | } |
368 | impl core::fmt::Debug for Sr { |
369 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { |
370 | f.debug_struct("Sr" ) |
371 | .field("dinis" , &self.dinis()) |
372 | .field("dcis" , &self.dcis()) |
373 | .field("dmas" , &self.dmas()) |
374 | .field("busy" , &self.busy()) |
375 | .field("nbwp" , &self.nbwp()) |
376 | .field("dinne" , &self.dinne()) |
377 | .field("nbwe" , &self.nbwe()) |
378 | .finish() |
379 | } |
380 | } |
381 | #[cfg (feature = "defmt" )] |
382 | impl defmt::Format for Sr { |
383 | fn format(&self, f: defmt::Formatter) { |
384 | #[derive (defmt :: Format)] |
385 | struct Sr { |
386 | dinis: bool, |
387 | dcis: bool, |
388 | dmas: bool, |
389 | busy: bool, |
390 | nbwp: u8, |
391 | dinne: bool, |
392 | nbwe: u8, |
393 | } |
394 | let proxy = Sr { |
395 | dinis: self.dinis(), |
396 | dcis: self.dcis(), |
397 | dmas: self.dmas(), |
398 | busy: self.busy(), |
399 | nbwp: self.nbwp(), |
400 | dinne: self.dinne(), |
401 | nbwe: self.nbwe(), |
402 | }; |
403 | defmt::write!(f, "{}" , proxy) |
404 | } |
405 | } |
406 | #[doc = "start register." ] |
407 | #[repr (transparent)] |
408 | #[derive (Copy, Clone, Eq, PartialEq)] |
409 | pub struct Str(pub u32); |
410 | impl Str { |
411 | #[doc = "Number of valid bits in the last word of the message." ] |
412 | #[inline (always)] |
413 | pub const fn nblw(&self) -> u8 { |
414 | let val = (self.0 >> 0usize) & 0x1f; |
415 | val as u8 |
416 | } |
417 | #[doc = "Number of valid bits in the last word of the message." ] |
418 | #[inline (always)] |
419 | pub fn set_nblw(&mut self, val: u8) { |
420 | self.0 = (self.0 & !(0x1f << 0usize)) | (((val as u32) & 0x1f) << 0usize); |
421 | } |
422 | #[doc = "Digest calculation." ] |
423 | #[inline (always)] |
424 | pub const fn dcal(&self) -> bool { |
425 | let val = (self.0 >> 8usize) & 0x01; |
426 | val != 0 |
427 | } |
428 | #[doc = "Digest calculation." ] |
429 | #[inline (always)] |
430 | pub fn set_dcal(&mut self, val: bool) { |
431 | self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize); |
432 | } |
433 | } |
434 | impl Default for Str { |
435 | #[inline (always)] |
436 | fn default() -> Str { |
437 | Str(0) |
438 | } |
439 | } |
440 | impl core::fmt::Debug for Str { |
441 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { |
442 | f.debug_struct("Str" ) |
443 | .field("nblw" , &self.nblw()) |
444 | .field("dcal" , &self.dcal()) |
445 | .finish() |
446 | } |
447 | } |
448 | #[cfg (feature = "defmt" )] |
449 | impl defmt::Format for Str { |
450 | fn format(&self, f: defmt::Formatter) { |
451 | #[derive (defmt :: Format)] |
452 | struct Str { |
453 | nblw: u8, |
454 | dcal: bool, |
455 | } |
456 | let proxy = Str { |
457 | nblw: self.nblw(), |
458 | dcal: self.dcal(), |
459 | }; |
460 | defmt::write!(f, "{}" , proxy) |
461 | } |
462 | } |
463 | } |
464 | |