| 1 | #![allow (clippy::missing_safety_doc)] |
| 2 | #![allow (clippy::identity_op)] |
| 3 | #![allow (clippy::unnecessary_cast)] |
| 4 | #![allow (clippy::erasing_op)] |
| 5 | |
| 6 | #[doc = "Advanced encryption standard hardware accelerator" ] |
| 7 | #[derive (Copy, Clone, Eq, PartialEq)] |
| 8 | pub struct Aes { |
| 9 | ptr: *mut u8, |
| 10 | } |
| 11 | unsafe impl Send for Aes {} |
| 12 | unsafe impl Sync for Aes {} |
| 13 | impl Aes { |
| 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 = "Status register" ] |
| 28 | #[inline (always)] |
| 29 | pub const fn sr(self) -> crate::common::Reg<regs::Sr, crate::common::RW> { |
| 30 | unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x04usize) as _) } |
| 31 | } |
| 32 | #[doc = "Data input register" ] |
| 33 | #[inline (always)] |
| 34 | pub const fn dinr(self) -> crate::common::Reg<u32, crate::common::RW> { |
| 35 | unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x08usize) as _) } |
| 36 | } |
| 37 | #[doc = "Data output register" ] |
| 38 | #[inline (always)] |
| 39 | pub const fn doutr(self) -> crate::common::Reg<u32, crate::common::RW> { |
| 40 | unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x0cusize) as _) } |
| 41 | } |
| 42 | #[doc = "Key register" ] |
| 43 | #[inline (always)] |
| 44 | pub const fn keyr(self, n: usize) -> crate::common::Reg<u32, crate::common::RW> { |
| 45 | assert!(n < 8usize); |
| 46 | unsafe { |
| 47 | crate::common::Reg::from_ptr( |
| 48 | self.ptr.add( |
| 49 | 0x10usize + ([0usize, 4usize, 8usize, 12usize, 32usize, 36usize, 40usize, 44usize][n] as usize), |
| 50 | ) as _, |
| 51 | ) |
| 52 | } |
| 53 | } |
| 54 | #[doc = "Initialization vector register" ] |
| 55 | #[inline (always)] |
| 56 | pub const fn ivr(self, n: usize) -> crate::common::Reg<u32, crate::common::RW> { |
| 57 | assert!(n < 4usize); |
| 58 | unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x20usize + n * 4usize) as _) } |
| 59 | } |
| 60 | #[doc = "Suspend register" ] |
| 61 | #[inline (always)] |
| 62 | pub const fn suspr(self, n: usize) -> crate::common::Reg<u32, crate::common::RW> { |
| 63 | assert!(n < 8usize); |
| 64 | unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x40usize + n * 4usize) as _) } |
| 65 | } |
| 66 | #[doc = "interrupt enable register" ] |
| 67 | #[inline (always)] |
| 68 | pub const fn ier(self) -> crate::common::Reg<regs::Ier, crate::common::RW> { |
| 69 | unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x0300usize) as _) } |
| 70 | } |
| 71 | #[doc = "interrupt status register" ] |
| 72 | #[inline (always)] |
| 73 | pub const fn isr(self) -> crate::common::Reg<regs::Isr, crate::common::RW> { |
| 74 | unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x0304usize) as _) } |
| 75 | } |
| 76 | #[doc = "interrupt clear register" ] |
| 77 | #[inline (always)] |
| 78 | pub const fn icr(self) -> crate::common::Reg<regs::Icr, crate::common::RW> { |
| 79 | unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x0308usize) as _) } |
| 80 | } |
| 81 | } |
| 82 | pub mod regs { |
| 83 | #[doc = "Control register" ] |
| 84 | #[repr (transparent)] |
| 85 | #[derive (Copy, Clone, Eq, PartialEq)] |
| 86 | pub struct Cr(pub u32); |
| 87 | impl Cr { |
| 88 | #[doc = "AES enable" ] |
| 89 | #[inline (always)] |
| 90 | pub const fn en(&self) -> bool { |
| 91 | let val = (self.0 >> 0usize) & 0x01; |
| 92 | val != 0 |
| 93 | } |
| 94 | #[doc = "AES enable" ] |
| 95 | #[inline (always)] |
| 96 | pub fn set_en(&mut self, val: bool) { |
| 97 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); |
| 98 | } |
| 99 | #[doc = "Data type selection" ] |
| 100 | #[inline (always)] |
| 101 | pub const fn datatype(&self) -> super::vals::Datatype { |
| 102 | let val = (self.0 >> 1usize) & 0x03; |
| 103 | super::vals::Datatype::from_bits(val as u8) |
| 104 | } |
| 105 | #[doc = "Data type selection" ] |
| 106 | #[inline (always)] |
| 107 | pub fn set_datatype(&mut self, val: super::vals::Datatype) { |
| 108 | self.0 = (self.0 & !(0x03 << 1usize)) | (((val.to_bits() as u32) & 0x03) << 1usize); |
| 109 | } |
| 110 | #[doc = "Operating mode" ] |
| 111 | #[inline (always)] |
| 112 | pub const fn mode(&self) -> super::vals::Mode { |
| 113 | let val = (self.0 >> 3usize) & 0x03; |
| 114 | super::vals::Mode::from_bits(val as u8) |
| 115 | } |
| 116 | #[doc = "Operating mode" ] |
| 117 | #[inline (always)] |
| 118 | pub fn set_mode(&mut self, val: super::vals::Mode) { |
| 119 | self.0 = (self.0 & !(0x03 << 3usize)) | (((val.to_bits() as u32) & 0x03) << 3usize); |
| 120 | } |
| 121 | #[doc = "Chaining mode selection" ] |
| 122 | #[inline (always)] |
| 123 | pub const fn chmod(&self) -> super::vals::Chmod { |
| 124 | let mut val = 0; |
| 125 | val += (((self.0 >> 5usize) & 0x03) << 0usize); |
| 126 | val += (((self.0 >> 16usize) & 0x01) << 2usize); |
| 127 | super::vals::Chmod::from_bits(val as u8) |
| 128 | } |
| 129 | #[doc = "Chaining mode selection" ] |
| 130 | #[inline (always)] |
| 131 | pub fn set_chmod(&mut self, val: super::vals::Chmod) { |
| 132 | self.0 = (self.0 & !(0x03 << 5usize)) | (((val.to_bits() as u32 >> 0usize) & 0x03) << 5usize); |
| 133 | self.0 = (self.0 & !(0x01 << 16usize)) | (((val.to_bits() as u32 >> 2usize) & 0x01) << 16usize); |
| 134 | } |
| 135 | #[doc = "Enable DMA management of data input phase" ] |
| 136 | #[inline (always)] |
| 137 | pub const fn dmainen(&self) -> bool { |
| 138 | let val = (self.0 >> 11usize) & 0x01; |
| 139 | val != 0 |
| 140 | } |
| 141 | #[doc = "Enable DMA management of data input phase" ] |
| 142 | #[inline (always)] |
| 143 | pub fn set_dmainen(&mut self, val: bool) { |
| 144 | self.0 = (self.0 & !(0x01 << 11usize)) | (((val as u32) & 0x01) << 11usize); |
| 145 | } |
| 146 | #[doc = "Enable DMA management of data output phase" ] |
| 147 | #[inline (always)] |
| 148 | pub const fn dmaouten(&self) -> bool { |
| 149 | let val = (self.0 >> 12usize) & 0x01; |
| 150 | val != 0 |
| 151 | } |
| 152 | #[doc = "Enable DMA management of data output phase" ] |
| 153 | #[inline (always)] |
| 154 | pub fn set_dmaouten(&mut self, val: bool) { |
| 155 | self.0 = (self.0 & !(0x01 << 12usize)) | (((val as u32) & 0x01) << 12usize); |
| 156 | } |
| 157 | #[doc = "GCM or CCM phase selection" ] |
| 158 | #[inline (always)] |
| 159 | pub const fn gcmph(&self) -> super::vals::Gcmph { |
| 160 | let val = (self.0 >> 13usize) & 0x03; |
| 161 | super::vals::Gcmph::from_bits(val as u8) |
| 162 | } |
| 163 | #[doc = "GCM or CCM phase selection" ] |
| 164 | #[inline (always)] |
| 165 | pub fn set_gcmph(&mut self, val: super::vals::Gcmph) { |
| 166 | self.0 = (self.0 & !(0x03 << 13usize)) | (((val.to_bits() as u32) & 0x03) << 13usize); |
| 167 | } |
| 168 | #[doc = "Key size selection" ] |
| 169 | #[inline (always)] |
| 170 | pub const fn keysize(&self) -> bool { |
| 171 | let val = (self.0 >> 18usize) & 0x01; |
| 172 | val != 0 |
| 173 | } |
| 174 | #[doc = "Key size selection" ] |
| 175 | #[inline (always)] |
| 176 | pub fn set_keysize(&mut self, val: bool) { |
| 177 | self.0 = (self.0 & !(0x01 << 18usize)) | (((val as u32) & 0x01) << 18usize); |
| 178 | } |
| 179 | #[doc = "Number of padding bytes in last block of payload" ] |
| 180 | #[inline (always)] |
| 181 | pub const fn npblb(&self) -> u8 { |
| 182 | let val = (self.0 >> 20usize) & 0x0f; |
| 183 | val as u8 |
| 184 | } |
| 185 | #[doc = "Number of padding bytes in last block of payload" ] |
| 186 | #[inline (always)] |
| 187 | pub fn set_npblb(&mut self, val: u8) { |
| 188 | self.0 = (self.0 & !(0x0f << 20usize)) | (((val as u32) & 0x0f) << 20usize); |
| 189 | } |
| 190 | #[doc = "Key mode selection" ] |
| 191 | #[inline (always)] |
| 192 | pub const fn kmod(&self) -> u8 { |
| 193 | let val = (self.0 >> 24usize) & 0x03; |
| 194 | val as u8 |
| 195 | } |
| 196 | #[doc = "Key mode selection" ] |
| 197 | #[inline (always)] |
| 198 | pub fn set_kmod(&mut self, val: u8) { |
| 199 | self.0 = (self.0 & !(0x03 << 24usize)) | (((val as u32) & 0x03) << 24usize); |
| 200 | } |
| 201 | #[doc = "AES peripheral software reset" ] |
| 202 | #[inline (always)] |
| 203 | pub const fn iprst(&self) -> bool { |
| 204 | let val = (self.0 >> 31usize) & 0x01; |
| 205 | val != 0 |
| 206 | } |
| 207 | #[doc = "AES peripheral software reset" ] |
| 208 | #[inline (always)] |
| 209 | pub fn set_iprst(&mut self, val: bool) { |
| 210 | self.0 = (self.0 & !(0x01 << 31usize)) | (((val as u32) & 0x01) << 31usize); |
| 211 | } |
| 212 | } |
| 213 | impl Default for Cr { |
| 214 | #[inline (always)] |
| 215 | fn default() -> Cr { |
| 216 | Cr(0) |
| 217 | } |
| 218 | } |
| 219 | impl core::fmt::Debug for Cr { |
| 220 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { |
| 221 | f.debug_struct("Cr" ) |
| 222 | .field("en" , &self.en()) |
| 223 | .field("datatype" , &self.datatype()) |
| 224 | .field("mode" , &self.mode()) |
| 225 | .field("chmod" , &self.chmod()) |
| 226 | .field("dmainen" , &self.dmainen()) |
| 227 | .field("dmaouten" , &self.dmaouten()) |
| 228 | .field("gcmph" , &self.gcmph()) |
| 229 | .field("keysize" , &self.keysize()) |
| 230 | .field("npblb" , &self.npblb()) |
| 231 | .field("kmod" , &self.kmod()) |
| 232 | .field("iprst" , &self.iprst()) |
| 233 | .finish() |
| 234 | } |
| 235 | } |
| 236 | #[cfg (feature = "defmt" )] |
| 237 | impl defmt::Format for Cr { |
| 238 | fn format(&self, f: defmt::Formatter) { |
| 239 | #[derive (defmt :: Format)] |
| 240 | struct Cr { |
| 241 | en: bool, |
| 242 | datatype: super::vals::Datatype, |
| 243 | mode: super::vals::Mode, |
| 244 | chmod: super::vals::Chmod, |
| 245 | dmainen: bool, |
| 246 | dmaouten: bool, |
| 247 | gcmph: super::vals::Gcmph, |
| 248 | keysize: bool, |
| 249 | npblb: u8, |
| 250 | kmod: u8, |
| 251 | iprst: bool, |
| 252 | } |
| 253 | let proxy = Cr { |
| 254 | en: self.en(), |
| 255 | datatype: self.datatype(), |
| 256 | mode: self.mode(), |
| 257 | chmod: self.chmod(), |
| 258 | dmainen: self.dmainen(), |
| 259 | dmaouten: self.dmaouten(), |
| 260 | gcmph: self.gcmph(), |
| 261 | keysize: self.keysize(), |
| 262 | npblb: self.npblb(), |
| 263 | kmod: self.kmod(), |
| 264 | iprst: self.iprst(), |
| 265 | }; |
| 266 | defmt::write!(f, "{}" , proxy) |
| 267 | } |
| 268 | } |
| 269 | #[doc = "Interrupt clear register" ] |
| 270 | #[repr (transparent)] |
| 271 | #[derive (Copy, Clone, Eq, PartialEq)] |
| 272 | pub struct Icr(pub u32); |
| 273 | impl Icr { |
| 274 | #[doc = "Computation complete flag clear" ] |
| 275 | #[inline (always)] |
| 276 | pub const fn ccf(&self) -> bool { |
| 277 | let val = (self.0 >> 0usize) & 0x01; |
| 278 | val != 0 |
| 279 | } |
| 280 | #[doc = "Computation complete flag clear" ] |
| 281 | #[inline (always)] |
| 282 | pub fn set_ccf(&mut self, val: bool) { |
| 283 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); |
| 284 | } |
| 285 | #[doc = "Read or write error interrupt flag clear" ] |
| 286 | #[inline (always)] |
| 287 | pub const fn rweif(&self) -> bool { |
| 288 | let val = (self.0 >> 1usize) & 0x01; |
| 289 | val != 0 |
| 290 | } |
| 291 | #[doc = "Read or write error interrupt flag clear" ] |
| 292 | #[inline (always)] |
| 293 | pub fn set_rweif(&mut self, val: bool) { |
| 294 | self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize); |
| 295 | } |
| 296 | #[doc = "Key error interrupt flag clear" ] |
| 297 | #[inline (always)] |
| 298 | pub const fn keif(&self) -> bool { |
| 299 | let val = (self.0 >> 2usize) & 0x01; |
| 300 | val != 0 |
| 301 | } |
| 302 | #[doc = "Key error interrupt flag clear" ] |
| 303 | #[inline (always)] |
| 304 | pub fn set_keif(&mut self, val: bool) { |
| 305 | self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize); |
| 306 | } |
| 307 | } |
| 308 | impl Default for Icr { |
| 309 | #[inline (always)] |
| 310 | fn default() -> Icr { |
| 311 | Icr(0) |
| 312 | } |
| 313 | } |
| 314 | impl core::fmt::Debug for Icr { |
| 315 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { |
| 316 | f.debug_struct("Icr" ) |
| 317 | .field("ccf" , &self.ccf()) |
| 318 | .field("rweif" , &self.rweif()) |
| 319 | .field("keif" , &self.keif()) |
| 320 | .finish() |
| 321 | } |
| 322 | } |
| 323 | #[cfg (feature = "defmt" )] |
| 324 | impl defmt::Format for Icr { |
| 325 | fn format(&self, f: defmt::Formatter) { |
| 326 | #[derive (defmt :: Format)] |
| 327 | struct Icr { |
| 328 | ccf: bool, |
| 329 | rweif: bool, |
| 330 | keif: bool, |
| 331 | } |
| 332 | let proxy = Icr { |
| 333 | ccf: self.ccf(), |
| 334 | rweif: self.rweif(), |
| 335 | keif: self.keif(), |
| 336 | }; |
| 337 | defmt::write!(f, "{}" , proxy) |
| 338 | } |
| 339 | } |
| 340 | #[doc = "Interrupt enable register" ] |
| 341 | #[repr (transparent)] |
| 342 | #[derive (Copy, Clone, Eq, PartialEq)] |
| 343 | pub struct Ier(pub u32); |
| 344 | impl Ier { |
| 345 | #[doc = "Computation complete flag interrupt enable" ] |
| 346 | #[inline (always)] |
| 347 | pub const fn ccfie(&self) -> bool { |
| 348 | let val = (self.0 >> 0usize) & 0x01; |
| 349 | val != 0 |
| 350 | } |
| 351 | #[doc = "Computation complete flag interrupt enable" ] |
| 352 | #[inline (always)] |
| 353 | pub fn set_ccfie(&mut self, val: bool) { |
| 354 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); |
| 355 | } |
| 356 | #[doc = "Read or write error interrupt enable" ] |
| 357 | #[inline (always)] |
| 358 | pub const fn rweie(&self) -> bool { |
| 359 | let val = (self.0 >> 1usize) & 0x01; |
| 360 | val != 0 |
| 361 | } |
| 362 | #[doc = "Read or write error interrupt enable" ] |
| 363 | #[inline (always)] |
| 364 | pub fn set_rweie(&mut self, val: bool) { |
| 365 | self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize); |
| 366 | } |
| 367 | #[doc = "Key error interrupt enable" ] |
| 368 | #[inline (always)] |
| 369 | pub const fn keie(&self) -> bool { |
| 370 | let val = (self.0 >> 2usize) & 0x01; |
| 371 | val != 0 |
| 372 | } |
| 373 | #[doc = "Key error interrupt enable" ] |
| 374 | #[inline (always)] |
| 375 | pub fn set_keie(&mut self, val: bool) { |
| 376 | self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize); |
| 377 | } |
| 378 | } |
| 379 | impl Default for Ier { |
| 380 | #[inline (always)] |
| 381 | fn default() -> Ier { |
| 382 | Ier(0) |
| 383 | } |
| 384 | } |
| 385 | impl core::fmt::Debug for Ier { |
| 386 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { |
| 387 | f.debug_struct("Ier" ) |
| 388 | .field("ccfie" , &self.ccfie()) |
| 389 | .field("rweie" , &self.rweie()) |
| 390 | .field("keie" , &self.keie()) |
| 391 | .finish() |
| 392 | } |
| 393 | } |
| 394 | #[cfg (feature = "defmt" )] |
| 395 | impl defmt::Format for Ier { |
| 396 | fn format(&self, f: defmt::Formatter) { |
| 397 | #[derive (defmt :: Format)] |
| 398 | struct Ier { |
| 399 | ccfie: bool, |
| 400 | rweie: bool, |
| 401 | keie: bool, |
| 402 | } |
| 403 | let proxy = Ier { |
| 404 | ccfie: self.ccfie(), |
| 405 | rweie: self.rweie(), |
| 406 | keie: self.keie(), |
| 407 | }; |
| 408 | defmt::write!(f, "{}" , proxy) |
| 409 | } |
| 410 | } |
| 411 | #[doc = "Interrupt status register" ] |
| 412 | #[repr (transparent)] |
| 413 | #[derive (Copy, Clone, Eq, PartialEq)] |
| 414 | pub struct Isr(pub u32); |
| 415 | impl Isr { |
| 416 | #[doc = "Computation complete flag" ] |
| 417 | #[inline (always)] |
| 418 | pub const fn ccf(&self) -> bool { |
| 419 | let val = (self.0 >> 0usize) & 0x01; |
| 420 | val != 0 |
| 421 | } |
| 422 | #[doc = "Computation complete flag" ] |
| 423 | #[inline (always)] |
| 424 | pub fn set_ccf(&mut self, val: bool) { |
| 425 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); |
| 426 | } |
| 427 | #[doc = "Read or write error interrupt flag" ] |
| 428 | #[inline (always)] |
| 429 | pub const fn rweif(&self) -> bool { |
| 430 | let val = (self.0 >> 1usize) & 0x01; |
| 431 | val != 0 |
| 432 | } |
| 433 | #[doc = "Read or write error interrupt flag" ] |
| 434 | #[inline (always)] |
| 435 | pub fn set_rweif(&mut self, val: bool) { |
| 436 | self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize); |
| 437 | } |
| 438 | #[doc = "Key error interrupt flag" ] |
| 439 | #[inline (always)] |
| 440 | pub const fn keif(&self) -> bool { |
| 441 | let val = (self.0 >> 2usize) & 0x01; |
| 442 | val != 0 |
| 443 | } |
| 444 | #[doc = "Key error interrupt flag" ] |
| 445 | #[inline (always)] |
| 446 | pub fn set_keif(&mut self, val: bool) { |
| 447 | self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize); |
| 448 | } |
| 449 | } |
| 450 | impl Default for Isr { |
| 451 | #[inline (always)] |
| 452 | fn default() -> Isr { |
| 453 | Isr(0) |
| 454 | } |
| 455 | } |
| 456 | impl core::fmt::Debug for Isr { |
| 457 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { |
| 458 | f.debug_struct("Isr" ) |
| 459 | .field("ccf" , &self.ccf()) |
| 460 | .field("rweif" , &self.rweif()) |
| 461 | .field("keif" , &self.keif()) |
| 462 | .finish() |
| 463 | } |
| 464 | } |
| 465 | #[cfg (feature = "defmt" )] |
| 466 | impl defmt::Format for Isr { |
| 467 | fn format(&self, f: defmt::Formatter) { |
| 468 | #[derive (defmt :: Format)] |
| 469 | struct Isr { |
| 470 | ccf: bool, |
| 471 | rweif: bool, |
| 472 | keif: bool, |
| 473 | } |
| 474 | let proxy = Isr { |
| 475 | ccf: self.ccf(), |
| 476 | rweif: self.rweif(), |
| 477 | keif: self.keif(), |
| 478 | }; |
| 479 | defmt::write!(f, "{}" , proxy) |
| 480 | } |
| 481 | } |
| 482 | #[doc = "Status register" ] |
| 483 | #[repr (transparent)] |
| 484 | #[derive (Copy, Clone, Eq, PartialEq)] |
| 485 | pub struct Sr(pub u32); |
| 486 | impl Sr { |
| 487 | #[doc = "Computation complete flag" ] |
| 488 | #[inline (always)] |
| 489 | pub const fn ccf(&self) -> bool { |
| 490 | let val = (self.0 >> 0usize) & 0x01; |
| 491 | val != 0 |
| 492 | } |
| 493 | #[doc = "Computation complete flag" ] |
| 494 | #[inline (always)] |
| 495 | pub fn set_ccf(&mut self, val: bool) { |
| 496 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); |
| 497 | } |
| 498 | #[doc = "Read error flag" ] |
| 499 | #[inline (always)] |
| 500 | pub const fn rderr(&self) -> bool { |
| 501 | let val = (self.0 >> 1usize) & 0x01; |
| 502 | val != 0 |
| 503 | } |
| 504 | #[doc = "Read error flag" ] |
| 505 | #[inline (always)] |
| 506 | pub fn set_rderr(&mut self, val: bool) { |
| 507 | self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize); |
| 508 | } |
| 509 | #[doc = "Write error flag" ] |
| 510 | #[inline (always)] |
| 511 | pub const fn wrerr(&self) -> bool { |
| 512 | let val = (self.0 >> 2usize) & 0x01; |
| 513 | val != 0 |
| 514 | } |
| 515 | #[doc = "Write error flag" ] |
| 516 | #[inline (always)] |
| 517 | pub fn set_wrerr(&mut self, val: bool) { |
| 518 | self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize); |
| 519 | } |
| 520 | #[doc = "Busy flag" ] |
| 521 | #[inline (always)] |
| 522 | pub const fn busy(&self) -> bool { |
| 523 | let val = (self.0 >> 3usize) & 0x01; |
| 524 | val != 0 |
| 525 | } |
| 526 | #[doc = "Busy flag" ] |
| 527 | #[inline (always)] |
| 528 | pub fn set_busy(&mut self, val: bool) { |
| 529 | self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize); |
| 530 | } |
| 531 | #[doc = "Key valid flag" ] |
| 532 | #[inline (always)] |
| 533 | pub const fn keyvalid(&self) -> bool { |
| 534 | let val = (self.0 >> 7usize) & 0x01; |
| 535 | val != 0 |
| 536 | } |
| 537 | #[doc = "Key valid flag" ] |
| 538 | #[inline (always)] |
| 539 | pub fn set_keyvalid(&mut self, val: bool) { |
| 540 | self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize); |
| 541 | } |
| 542 | } |
| 543 | impl Default for Sr { |
| 544 | #[inline (always)] |
| 545 | fn default() -> Sr { |
| 546 | Sr(0) |
| 547 | } |
| 548 | } |
| 549 | impl core::fmt::Debug for Sr { |
| 550 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { |
| 551 | f.debug_struct("Sr" ) |
| 552 | .field("ccf" , &self.ccf()) |
| 553 | .field("rderr" , &self.rderr()) |
| 554 | .field("wrerr" , &self.wrerr()) |
| 555 | .field("busy" , &self.busy()) |
| 556 | .field("keyvalid" , &self.keyvalid()) |
| 557 | .finish() |
| 558 | } |
| 559 | } |
| 560 | #[cfg (feature = "defmt" )] |
| 561 | impl defmt::Format for Sr { |
| 562 | fn format(&self, f: defmt::Formatter) { |
| 563 | #[derive (defmt :: Format)] |
| 564 | struct Sr { |
| 565 | ccf: bool, |
| 566 | rderr: bool, |
| 567 | wrerr: bool, |
| 568 | busy: bool, |
| 569 | keyvalid: bool, |
| 570 | } |
| 571 | let proxy = Sr { |
| 572 | ccf: self.ccf(), |
| 573 | rderr: self.rderr(), |
| 574 | wrerr: self.wrerr(), |
| 575 | busy: self.busy(), |
| 576 | keyvalid: self.keyvalid(), |
| 577 | }; |
| 578 | defmt::write!(f, "{}" , proxy) |
| 579 | } |
| 580 | } |
| 581 | } |
| 582 | pub mod vals { |
| 583 | #[repr (u8)] |
| 584 | #[derive (Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)] |
| 585 | #[cfg_attr (feature = "defmt" , derive(defmt::Format))] |
| 586 | pub enum Chmod { |
| 587 | #[doc = "Electronic codebook" ] |
| 588 | ECB = 0x0, |
| 589 | #[doc = "Cipher-block chaining" ] |
| 590 | CBC = 0x01, |
| 591 | #[doc = "Counter mode" ] |
| 592 | CTR = 0x02, |
| 593 | #[doc = "Galois counter mode and Galois message authentication code" ] |
| 594 | GCM_GMAC = 0x03, |
| 595 | #[doc = "Counter with CBC-MAC" ] |
| 596 | CCM = 0x04, |
| 597 | _RESERVED_5 = 0x05, |
| 598 | _RESERVED_6 = 0x06, |
| 599 | _RESERVED_7 = 0x07, |
| 600 | } |
| 601 | impl Chmod { |
| 602 | #[inline (always)] |
| 603 | pub const fn from_bits(val: u8) -> Chmod { |
| 604 | unsafe { core::mem::transmute(val & 0x07) } |
| 605 | } |
| 606 | #[inline (always)] |
| 607 | pub const fn to_bits(self) -> u8 { |
| 608 | unsafe { core::mem::transmute(self) } |
| 609 | } |
| 610 | } |
| 611 | impl From<u8> for Chmod { |
| 612 | #[inline (always)] |
| 613 | fn from(val: u8) -> Chmod { |
| 614 | Chmod::from_bits(val) |
| 615 | } |
| 616 | } |
| 617 | impl From<Chmod> for u8 { |
| 618 | #[inline (always)] |
| 619 | fn from(val: Chmod) -> u8 { |
| 620 | Chmod::to_bits(val) |
| 621 | } |
| 622 | } |
| 623 | #[repr (u8)] |
| 624 | #[derive (Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)] |
| 625 | #[cfg_attr (feature = "defmt" , derive(defmt::Format))] |
| 626 | pub enum Datatype { |
| 627 | #[doc = "Word" ] |
| 628 | NONE = 0x0, |
| 629 | #[doc = "Half-word (16-bit)" ] |
| 630 | HALF_WORD = 0x01, |
| 631 | #[doc = "Byte (8-bit)" ] |
| 632 | BYTE = 0x02, |
| 633 | #[doc = "Bit" ] |
| 634 | BIT = 0x03, |
| 635 | } |
| 636 | impl Datatype { |
| 637 | #[inline (always)] |
| 638 | pub const fn from_bits(val: u8) -> Datatype { |
| 639 | unsafe { core::mem::transmute(val & 0x03) } |
| 640 | } |
| 641 | #[inline (always)] |
| 642 | pub const fn to_bits(self) -> u8 { |
| 643 | unsafe { core::mem::transmute(self) } |
| 644 | } |
| 645 | } |
| 646 | impl From<u8> for Datatype { |
| 647 | #[inline (always)] |
| 648 | fn from(val: u8) -> Datatype { |
| 649 | Datatype::from_bits(val) |
| 650 | } |
| 651 | } |
| 652 | impl From<Datatype> for u8 { |
| 653 | #[inline (always)] |
| 654 | fn from(val: Datatype) -> u8 { |
| 655 | Datatype::to_bits(val) |
| 656 | } |
| 657 | } |
| 658 | #[repr (u8)] |
| 659 | #[derive (Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)] |
| 660 | #[cfg_attr (feature = "defmt" , derive(defmt::Format))] |
| 661 | pub enum Gcmph { |
| 662 | #[doc = "Init phase" ] |
| 663 | INIT_PHASE = 0x0, |
| 664 | #[doc = "Header phase" ] |
| 665 | HEADER_PHASE = 0x01, |
| 666 | #[doc = "Payload phase" ] |
| 667 | PAYLOAD_PHASE = 0x02, |
| 668 | #[doc = "Final phase" ] |
| 669 | FINAL_PHASE = 0x03, |
| 670 | } |
| 671 | impl Gcmph { |
| 672 | #[inline (always)] |
| 673 | pub const fn from_bits(val: u8) -> Gcmph { |
| 674 | unsafe { core::mem::transmute(val & 0x03) } |
| 675 | } |
| 676 | #[inline (always)] |
| 677 | pub const fn to_bits(self) -> u8 { |
| 678 | unsafe { core::mem::transmute(self) } |
| 679 | } |
| 680 | } |
| 681 | impl From<u8> for Gcmph { |
| 682 | #[inline (always)] |
| 683 | fn from(val: u8) -> Gcmph { |
| 684 | Gcmph::from_bits(val) |
| 685 | } |
| 686 | } |
| 687 | impl From<Gcmph> for u8 { |
| 688 | #[inline (always)] |
| 689 | fn from(val: Gcmph) -> u8 { |
| 690 | Gcmph::to_bits(val) |
| 691 | } |
| 692 | } |
| 693 | #[repr (u8)] |
| 694 | #[derive (Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)] |
| 695 | #[cfg_attr (feature = "defmt" , derive(defmt::Format))] |
| 696 | pub enum Mode { |
| 697 | #[doc = "Encryption" ] |
| 698 | MODE1 = 0x0, |
| 699 | #[doc = "Key derivation (or key preparation for ECB/CBC decryption)" ] |
| 700 | MODE2 = 0x01, |
| 701 | #[doc = "Decryption" ] |
| 702 | MODE3 = 0x02, |
| 703 | _RESERVED_3 = 0x03, |
| 704 | } |
| 705 | impl Mode { |
| 706 | #[inline (always)] |
| 707 | pub const fn from_bits(val: u8) -> Mode { |
| 708 | unsafe { core::mem::transmute(val & 0x03) } |
| 709 | } |
| 710 | #[inline (always)] |
| 711 | pub const fn to_bits(self) -> u8 { |
| 712 | unsafe { core::mem::transmute(self) } |
| 713 | } |
| 714 | } |
| 715 | impl From<u8> for Mode { |
| 716 | #[inline (always)] |
| 717 | fn from(val: u8) -> Mode { |
| 718 | Mode::from_bits(val) |
| 719 | } |
| 720 | } |
| 721 | impl From<Mode> for u8 { |
| 722 | #[inline (always)] |
| 723 | fn from(val: Mode) -> u8 { |
| 724 | Mode::to_bits(val) |
| 725 | } |
| 726 | } |
| 727 | } |
| 728 | |