1 | #![allow (clippy::missing_safety_doc)] |
2 | #![allow (clippy::identity_op)] |
3 | #![allow (clippy::unnecessary_cast)] |
4 | #![allow (clippy::erasing_op)] |
5 | |
6 | #[doc = "Tamper and backup registers" ] |
7 | #[derive (Copy, Clone, Eq, PartialEq)] |
8 | pub struct Tamp { |
9 | ptr: *mut u8, |
10 | } |
11 | unsafe impl Send for Tamp {} |
12 | unsafe impl Sync for Tamp {} |
13 | impl Tamp { |
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 = "TAMP control register 1" ] |
23 | #[inline (always)] |
24 | pub const fn cr1(self) -> crate::common::Reg<regs::Cr1, crate::common::RW> { |
25 | unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x0usize) as _) } |
26 | } |
27 | #[doc = "TAMP control register 2" ] |
28 | #[inline (always)] |
29 | pub const fn cr2(self) -> crate::common::Reg<regs::Cr2, crate::common::RW> { |
30 | unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x04usize) as _) } |
31 | } |
32 | #[doc = "TAMP control register 3" ] |
33 | #[inline (always)] |
34 | pub const fn cr3(self) -> crate::common::Reg<regs::Cr3, crate::common::RW> { |
35 | unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x08usize) as _) } |
36 | } |
37 | #[doc = "TAMP filter control register" ] |
38 | #[inline (always)] |
39 | pub const fn fltcr(self) -> crate::common::Reg<regs::Fltcr, crate::common::RW> { |
40 | unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x0cusize) as _) } |
41 | } |
42 | #[doc = "TAMP active tamper control register 1" ] |
43 | #[inline (always)] |
44 | pub const fn atcr1(self) -> crate::common::Reg<regs::Atcr1, crate::common::RW> { |
45 | unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x10usize) as _) } |
46 | } |
47 | #[doc = "TAMP active tamper seed register" ] |
48 | #[inline (always)] |
49 | pub const fn atseedr(self) -> crate::common::Reg<regs::Atseedr, crate::common::RW> { |
50 | unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x14usize) as _) } |
51 | } |
52 | #[doc = "TAMP active tamper output register" ] |
53 | #[inline (always)] |
54 | pub const fn ator(self) -> crate::common::Reg<regs::Ator, crate::common::RW> { |
55 | unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x18usize) as _) } |
56 | } |
57 | #[doc = "TAMP active tamper control register 2" ] |
58 | #[inline (always)] |
59 | pub const fn atcr2(self) -> crate::common::Reg<regs::Atcr2, crate::common::RW> { |
60 | unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x1cusize) as _) } |
61 | } |
62 | #[doc = "TAMP secure mode register" ] |
63 | #[inline (always)] |
64 | pub const fn seccfgr(self) -> crate::common::Reg<regs::Seccfgr, crate::common::RW> { |
65 | unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x20usize) as _) } |
66 | } |
67 | #[doc = "TAMP privilege mode control register" ] |
68 | #[inline (always)] |
69 | pub const fn privcr(self) -> crate::common::Reg<regs::Privcr, crate::common::RW> { |
70 | unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x24usize) as _) } |
71 | } |
72 | #[doc = "TAMP interrupt enable register" ] |
73 | #[inline (always)] |
74 | pub const fn ier(self) -> crate::common::Reg<regs::Ier, crate::common::RW> { |
75 | unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x2cusize) as _) } |
76 | } |
77 | #[doc = "TAMP status register" ] |
78 | #[inline (always)] |
79 | pub const fn sr(self) -> crate::common::Reg<regs::Sr, crate::common::RW> { |
80 | unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x30usize) as _) } |
81 | } |
82 | #[doc = "TAMP non-secure masked interrupt status register" ] |
83 | #[inline (always)] |
84 | pub const fn misr(self) -> crate::common::Reg<regs::Misr, crate::common::RW> { |
85 | unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x34usize) as _) } |
86 | } |
87 | #[doc = "TAMP secure masked interrupt status register" ] |
88 | #[inline (always)] |
89 | pub const fn smisr(self) -> crate::common::Reg<regs::Smisr, crate::common::RW> { |
90 | unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x38usize) as _) } |
91 | } |
92 | #[doc = "TAMP status clear register" ] |
93 | #[inline (always)] |
94 | pub const fn scr(self) -> crate::common::Reg<regs::Scr, crate::common::RW> { |
95 | unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x3cusize) as _) } |
96 | } |
97 | #[doc = "TAMP monotonic counter 1 register" ] |
98 | #[inline (always)] |
99 | pub const fn countr(self) -> crate::common::Reg<regs::Countr, crate::common::RW> { |
100 | unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x40usize) as _) } |
101 | } |
102 | #[doc = "TAMP erase configuration register" ] |
103 | #[inline (always)] |
104 | pub const fn ercfgr(self) -> crate::common::Reg<regs::Ercfgr, crate::common::RW> { |
105 | unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x54usize) as _) } |
106 | } |
107 | #[doc = "TAMP backup X register" ] |
108 | #[inline (always)] |
109 | pub const fn bkpr(self, n: usize) -> crate::common::Reg<regs::Bkpr, crate::common::RW> { |
110 | assert!(n < 32usize); |
111 | unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x0100usize + n * 4usize) as _) } |
112 | } |
113 | } |
114 | pub mod regs { |
115 | #[doc = "TAMP active tamper control register 1" ] |
116 | #[repr (transparent)] |
117 | #[derive (Copy, Clone, Eq, PartialEq)] |
118 | pub struct Atcr1(pub u32); |
119 | impl Atcr1 { |
120 | #[doc = "Tamper X active mode" ] |
121 | #[inline (always)] |
122 | pub const fn tampam(&self, n: usize) -> bool { |
123 | assert!(n < 8usize); |
124 | let offs = 0usize + n * 1usize; |
125 | let val = (self.0 >> offs) & 0x01; |
126 | val != 0 |
127 | } |
128 | #[doc = "Tamper X active mode" ] |
129 | #[inline (always)] |
130 | pub fn set_tampam(&mut self, n: usize, val: bool) { |
131 | assert!(n < 8usize); |
132 | let offs = 0usize + n * 1usize; |
133 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); |
134 | } |
135 | #[doc = "Active tamper shared output X selection. The selected output must be available in the package pinout" ] |
136 | #[inline (always)] |
137 | pub const fn atosel(&self, n: usize) -> u8 { |
138 | assert!(n < 4usize); |
139 | let offs = 8usize + n * 2usize; |
140 | let val = (self.0 >> offs) & 0x03; |
141 | val as u8 |
142 | } |
143 | #[doc = "Active tamper shared output X selection. The selected output must be available in the package pinout" ] |
144 | #[inline (always)] |
145 | pub fn set_atosel(&mut self, n: usize, val: u8) { |
146 | assert!(n < 4usize); |
147 | let offs = 8usize + n * 2usize; |
148 | self.0 = (self.0 & !(0x03 << offs)) | (((val as u32) & 0x03) << offs); |
149 | } |
150 | #[doc = "Active tamper RTC asynchronous prescaler clock selection. These bits selects the RTC asynchronous prescaler stage output.The selected clock is CK_ATPRE.. fCK_ATPRE = fRTCCLK / 2ATCKSEL when (PREDIV_A+1) = 128.. .... These bits can be written only when all active tampers are disabled. The write protection remains for up to 1.5 ck_atpre cycles after all the active tampers are disable." ] |
151 | #[inline (always)] |
152 | pub const fn atcksel(&self) -> super::vals::Atcksel { |
153 | let val = (self.0 >> 16usize) & 0x07; |
154 | super::vals::Atcksel::from_bits(val as u8) |
155 | } |
156 | #[doc = "Active tamper RTC asynchronous prescaler clock selection. These bits selects the RTC asynchronous prescaler stage output.The selected clock is CK_ATPRE.. fCK_ATPRE = fRTCCLK / 2ATCKSEL when (PREDIV_A+1) = 128.. .... These bits can be written only when all active tampers are disabled. The write protection remains for up to 1.5 ck_atpre cycles after all the active tampers are disable." ] |
157 | #[inline (always)] |
158 | pub fn set_atcksel(&mut self, val: super::vals::Atcksel) { |
159 | self.0 = (self.0 & !(0x07 << 16usize)) | (((val.to_bits() as u32) & 0x07) << 16usize); |
160 | } |
161 | #[doc = "Active tamper output change period. The tamper output is changed every CK_ATPER = (2ATPER x CK_ATPRE) cycles. Refer to ." ] |
162 | #[inline (always)] |
163 | pub const fn atper(&self) -> u8 { |
164 | let val = (self.0 >> 24usize) & 0x07; |
165 | val as u8 |
166 | } |
167 | #[doc = "Active tamper output change period. The tamper output is changed every CK_ATPER = (2ATPER x CK_ATPRE) cycles. Refer to ." ] |
168 | #[inline (always)] |
169 | pub fn set_atper(&mut self, val: u8) { |
170 | self.0 = (self.0 & !(0x07 << 24usize)) | (((val as u32) & 0x07) << 24usize); |
171 | } |
172 | #[doc = "Active tamper output sharing. IN1 is compared with TAMPOUTSEL1. IN2 is compared with TAMPOUTSEL2. IN3 is compared with TAMPOUTSEL3. IN4 is compared with TAMPOUTSEL4. IN5 is compared with TAMPOUTSEL5. IN6 is compared with TAMPOUTSEL6. IN7 is compared with TAMPOUTSEL7. IN8 is compared with TAMPOUTSEL8" ] |
173 | #[inline (always)] |
174 | pub const fn atoshare(&self) -> bool { |
175 | let val = (self.0 >> 30usize) & 0x01; |
176 | val != 0 |
177 | } |
178 | #[doc = "Active tamper output sharing. IN1 is compared with TAMPOUTSEL1. IN2 is compared with TAMPOUTSEL2. IN3 is compared with TAMPOUTSEL3. IN4 is compared with TAMPOUTSEL4. IN5 is compared with TAMPOUTSEL5. IN6 is compared with TAMPOUTSEL6. IN7 is compared with TAMPOUTSEL7. IN8 is compared with TAMPOUTSEL8" ] |
179 | #[inline (always)] |
180 | pub fn set_atoshare(&mut self, val: bool) { |
181 | self.0 = (self.0 & !(0x01 << 30usize)) | (((val as u32) & 0x01) << 30usize); |
182 | } |
183 | #[doc = "Active tamper filter enable" ] |
184 | #[inline (always)] |
185 | pub const fn flten(&self) -> bool { |
186 | let val = (self.0 >> 31usize) & 0x01; |
187 | val != 0 |
188 | } |
189 | #[doc = "Active tamper filter enable" ] |
190 | #[inline (always)] |
191 | pub fn set_flten(&mut self, val: bool) { |
192 | self.0 = (self.0 & !(0x01 << 31usize)) | (((val as u32) & 0x01) << 31usize); |
193 | } |
194 | } |
195 | impl Default for Atcr1 { |
196 | #[inline (always)] |
197 | fn default() -> Atcr1 { |
198 | Atcr1(0) |
199 | } |
200 | } |
201 | impl core::fmt::Debug for Atcr1 { |
202 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { |
203 | f.debug_struct("Atcr1" ) |
204 | .field( |
205 | "tampam" , |
206 | &[ |
207 | self.tampam(0usize), |
208 | self.tampam(1usize), |
209 | self.tampam(2usize), |
210 | self.tampam(3usize), |
211 | self.tampam(4usize), |
212 | self.tampam(5usize), |
213 | self.tampam(6usize), |
214 | self.tampam(7usize), |
215 | ], |
216 | ) |
217 | .field( |
218 | "atosel" , |
219 | &[ |
220 | self.atosel(0usize), |
221 | self.atosel(1usize), |
222 | self.atosel(2usize), |
223 | self.atosel(3usize), |
224 | ], |
225 | ) |
226 | .field("atcksel" , &self.atcksel()) |
227 | .field("atper" , &self.atper()) |
228 | .field("atoshare" , &self.atoshare()) |
229 | .field("flten" , &self.flten()) |
230 | .finish() |
231 | } |
232 | } |
233 | #[cfg (feature = "defmt" )] |
234 | impl defmt::Format for Atcr1 { |
235 | fn format(&self, f: defmt::Formatter) { |
236 | #[derive (defmt :: Format)] |
237 | struct Atcr1 { |
238 | tampam: [bool; 8usize], |
239 | atosel: [u8; 4usize], |
240 | atcksel: super::vals::Atcksel, |
241 | atper: u8, |
242 | atoshare: bool, |
243 | flten: bool, |
244 | } |
245 | let proxy = Atcr1 { |
246 | tampam: [ |
247 | self.tampam(0usize), |
248 | self.tampam(1usize), |
249 | self.tampam(2usize), |
250 | self.tampam(3usize), |
251 | self.tampam(4usize), |
252 | self.tampam(5usize), |
253 | self.tampam(6usize), |
254 | self.tampam(7usize), |
255 | ], |
256 | atosel: [ |
257 | self.atosel(0usize), |
258 | self.atosel(1usize), |
259 | self.atosel(2usize), |
260 | self.atosel(3usize), |
261 | ], |
262 | atcksel: self.atcksel(), |
263 | atper: self.atper(), |
264 | atoshare: self.atoshare(), |
265 | flten: self.flten(), |
266 | }; |
267 | defmt::write!(f, "{}" , proxy) |
268 | } |
269 | } |
270 | #[doc = "TAMP active tamper control register 2" ] |
271 | #[repr (transparent)] |
272 | #[derive (Copy, Clone, Eq, PartialEq)] |
273 | pub struct Atcr2(pub u32); |
274 | impl Atcr2 { |
275 | #[doc = "Active tamper shared output X selection. The selected output must be available in the package pinout. Bits 9:8 are the mirror of ATOSEL1 \\[1:0 \\] |
276 | in the ATCR1, and so can also be read or. written through ATCR1." ] |
277 | #[inline (always)] |
278 | pub const fn atosel(&self, n: usize) -> u8 { |
279 | assert!(n < 8usize); |
280 | let offs = 8usize + n * 3usize; |
281 | let val = (self.0 >> offs) & 0x07; |
282 | val as u8 |
283 | } |
284 | #[doc = "Active tamper shared output X selection. The selected output must be available in the package pinout. Bits 9:8 are the mirror of ATOSEL1 \\[1:0 \\] |
285 | in the ATCR1, and so can also be read or. written through ATCR1." ] |
286 | #[inline (always)] |
287 | pub fn set_atosel(&mut self, n: usize, val: u8) { |
288 | assert!(n < 8usize); |
289 | let offs = 8usize + n * 3usize; |
290 | self.0 = (self.0 & !(0x07 << offs)) | (((val as u32) & 0x07) << offs); |
291 | } |
292 | } |
293 | impl Default for Atcr2 { |
294 | #[inline (always)] |
295 | fn default() -> Atcr2 { |
296 | Atcr2(0) |
297 | } |
298 | } |
299 | impl core::fmt::Debug for Atcr2 { |
300 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { |
301 | f.debug_struct("Atcr2" ) |
302 | .field( |
303 | "atosel" , |
304 | &[ |
305 | self.atosel(0usize), |
306 | self.atosel(1usize), |
307 | self.atosel(2usize), |
308 | self.atosel(3usize), |
309 | self.atosel(4usize), |
310 | self.atosel(5usize), |
311 | self.atosel(6usize), |
312 | self.atosel(7usize), |
313 | ], |
314 | ) |
315 | .finish() |
316 | } |
317 | } |
318 | #[cfg (feature = "defmt" )] |
319 | impl defmt::Format for Atcr2 { |
320 | fn format(&self, f: defmt::Formatter) { |
321 | #[derive (defmt :: Format)] |
322 | struct Atcr2 { |
323 | atosel: [u8; 8usize], |
324 | } |
325 | let proxy = Atcr2 { |
326 | atosel: [ |
327 | self.atosel(0usize), |
328 | self.atosel(1usize), |
329 | self.atosel(2usize), |
330 | self.atosel(3usize), |
331 | self.atosel(4usize), |
332 | self.atosel(5usize), |
333 | self.atosel(6usize), |
334 | self.atosel(7usize), |
335 | ], |
336 | }; |
337 | defmt::write!(f, "{}" , proxy) |
338 | } |
339 | } |
340 | #[doc = "TAMP active tamper output register" ] |
341 | #[repr (transparent)] |
342 | #[derive (Copy, Clone, Eq, PartialEq)] |
343 | pub struct Ator(pub u32); |
344 | impl Ator { |
345 | #[doc = "Pseudo-random generator value. This field provides the values of the PRNG output. Because of potential inconsistencies due to synchronization delays, PRNG must be read at least twice. The read value is correct if it is equal to previous read value. This field can only be read when the APB is in secure mode." ] |
346 | #[inline (always)] |
347 | pub const fn prng(&self) -> u8 { |
348 | let val = (self.0 >> 0usize) & 0xff; |
349 | val as u8 |
350 | } |
351 | #[doc = "Pseudo-random generator value. This field provides the values of the PRNG output. Because of potential inconsistencies due to synchronization delays, PRNG must be read at least twice. The read value is correct if it is equal to previous read value. This field can only be read when the APB is in secure mode." ] |
352 | #[inline (always)] |
353 | pub fn set_prng(&mut self, val: u8) { |
354 | self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize); |
355 | } |
356 | #[doc = "Seed running flag. This flag is set by hardware when a new seed is written in the ATSEEDR. It is cleared by hardware when the PRNG has absorbed this new seed, and by system reset. The TAMP APB cock must not be switched off as long as SEEDF is set." ] |
357 | #[inline (always)] |
358 | pub const fn seedf(&self) -> bool { |
359 | let val = (self.0 >> 14usize) & 0x01; |
360 | val != 0 |
361 | } |
362 | #[doc = "Seed running flag. This flag is set by hardware when a new seed is written in the ATSEEDR. It is cleared by hardware when the PRNG has absorbed this new seed, and by system reset. The TAMP APB cock must not be switched off as long as SEEDF is set." ] |
363 | #[inline (always)] |
364 | pub fn set_seedf(&mut self, val: bool) { |
365 | self.0 = (self.0 & !(0x01 << 14usize)) | (((val as u32) & 0x01) << 14usize); |
366 | } |
367 | #[doc = "Active tamper initialization status. This flag is set by hardware when the PRNG has absorbed the first 128-bit seed, meaning that the enabled active tampers are functional. This flag is cleared when the active tampers are disabled." ] |
368 | #[inline (always)] |
369 | pub const fn inits(&self) -> bool { |
370 | let val = (self.0 >> 15usize) & 0x01; |
371 | val != 0 |
372 | } |
373 | #[doc = "Active tamper initialization status. This flag is set by hardware when the PRNG has absorbed the first 128-bit seed, meaning that the enabled active tampers are functional. This flag is cleared when the active tampers are disabled." ] |
374 | #[inline (always)] |
375 | pub fn set_inits(&mut self, val: bool) { |
376 | self.0 = (self.0 & !(0x01 << 15usize)) | (((val as u32) & 0x01) << 15usize); |
377 | } |
378 | } |
379 | impl Default for Ator { |
380 | #[inline (always)] |
381 | fn default() -> Ator { |
382 | Ator(0) |
383 | } |
384 | } |
385 | impl core::fmt::Debug for Ator { |
386 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { |
387 | f.debug_struct("Ator" ) |
388 | .field("prng" , &self.prng()) |
389 | .field("seedf" , &self.seedf()) |
390 | .field("inits" , &self.inits()) |
391 | .finish() |
392 | } |
393 | } |
394 | #[cfg (feature = "defmt" )] |
395 | impl defmt::Format for Ator { |
396 | fn format(&self, f: defmt::Formatter) { |
397 | #[derive (defmt :: Format)] |
398 | struct Ator { |
399 | prng: u8, |
400 | seedf: bool, |
401 | inits: bool, |
402 | } |
403 | let proxy = Ator { |
404 | prng: self.prng(), |
405 | seedf: self.seedf(), |
406 | inits: self.inits(), |
407 | }; |
408 | defmt::write!(f, "{}" , proxy) |
409 | } |
410 | } |
411 | #[doc = "TAMP active tamper seed register" ] |
412 | #[repr (transparent)] |
413 | #[derive (Copy, Clone, Eq, PartialEq)] |
414 | pub struct Atseedr(pub u32); |
415 | impl Atseedr { |
416 | #[doc = "Pseudo-random generator seed value. This register must be written four times with 32-bit values to provide the 128-bit seed to the PRNG. Writing to this register automatically sends the seed value to the PRNG." ] |
417 | #[inline (always)] |
418 | pub const fn seed(&self) -> u32 { |
419 | let val = (self.0 >> 0usize) & 0xffff_ffff; |
420 | val as u32 |
421 | } |
422 | #[doc = "Pseudo-random generator seed value. This register must be written four times with 32-bit values to provide the 128-bit seed to the PRNG. Writing to this register automatically sends the seed value to the PRNG." ] |
423 | #[inline (always)] |
424 | pub fn set_seed(&mut self, val: u32) { |
425 | self.0 = (self.0 & !(0xffff_ffff << 0usize)) | (((val as u32) & 0xffff_ffff) << 0usize); |
426 | } |
427 | } |
428 | impl Default for Atseedr { |
429 | #[inline (always)] |
430 | fn default() -> Atseedr { |
431 | Atseedr(0) |
432 | } |
433 | } |
434 | impl core::fmt::Debug for Atseedr { |
435 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { |
436 | f.debug_struct("Atseedr" ).field("seed" , &self.seed()).finish() |
437 | } |
438 | } |
439 | #[cfg (feature = "defmt" )] |
440 | impl defmt::Format for Atseedr { |
441 | fn format(&self, f: defmt::Formatter) { |
442 | #[derive (defmt :: Format)] |
443 | struct Atseedr { |
444 | seed: u32, |
445 | } |
446 | let proxy = Atseedr { seed: self.seed() }; |
447 | defmt::write!(f, "{}" , proxy) |
448 | } |
449 | } |
450 | #[doc = "TAMP backup register" ] |
451 | #[repr (transparent)] |
452 | #[derive (Copy, Clone, Eq, PartialEq)] |
453 | pub struct Bkpr(pub u32); |
454 | impl Bkpr { |
455 | #[doc = "The application can write or read data to and from these registers. In the default (ERASE) configuration this register is reset on a tamper detection event. It is forced to reset value as long as there is at least one internal or external tamper flag being set. This register is also reset when the readout protection (RDP) is disabled." ] |
456 | #[inline (always)] |
457 | pub const fn bkp(&self) -> u32 { |
458 | let val = (self.0 >> 0usize) & 0xffff_ffff; |
459 | val as u32 |
460 | } |
461 | #[doc = "The application can write or read data to and from these registers. In the default (ERASE) configuration this register is reset on a tamper detection event. It is forced to reset value as long as there is at least one internal or external tamper flag being set. This register is also reset when the readout protection (RDP) is disabled." ] |
462 | #[inline (always)] |
463 | pub fn set_bkp(&mut self, val: u32) { |
464 | self.0 = (self.0 & !(0xffff_ffff << 0usize)) | (((val as u32) & 0xffff_ffff) << 0usize); |
465 | } |
466 | } |
467 | impl Default for Bkpr { |
468 | #[inline (always)] |
469 | fn default() -> Bkpr { |
470 | Bkpr(0) |
471 | } |
472 | } |
473 | impl core::fmt::Debug for Bkpr { |
474 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { |
475 | f.debug_struct("Bkpr" ).field("bkp" , &self.bkp()).finish() |
476 | } |
477 | } |
478 | #[cfg (feature = "defmt" )] |
479 | impl defmt::Format for Bkpr { |
480 | fn format(&self, f: defmt::Formatter) { |
481 | #[derive (defmt :: Format)] |
482 | struct Bkpr { |
483 | bkp: u32, |
484 | } |
485 | let proxy = Bkpr { bkp: self.bkp() }; |
486 | defmt::write!(f, "{}" , proxy) |
487 | } |
488 | } |
489 | #[doc = "TAMP monotonic counter 1 register" ] |
490 | #[repr (transparent)] |
491 | #[derive (Copy, Clone, Eq, PartialEq)] |
492 | pub struct Countr(pub u32); |
493 | impl Countr { |
494 | #[doc = "This register is read-only only and is incremented by one when a write access is done to this register. This register cannot roll-over and is frozen when reaching the maximum value." ] |
495 | #[inline (always)] |
496 | pub const fn count(&self) -> u32 { |
497 | let val = (self.0 >> 0usize) & 0xffff_ffff; |
498 | val as u32 |
499 | } |
500 | #[doc = "This register is read-only only and is incremented by one when a write access is done to this register. This register cannot roll-over and is frozen when reaching the maximum value." ] |
501 | #[inline (always)] |
502 | pub fn set_count(&mut self, val: u32) { |
503 | self.0 = (self.0 & !(0xffff_ffff << 0usize)) | (((val as u32) & 0xffff_ffff) << 0usize); |
504 | } |
505 | } |
506 | impl Default for Countr { |
507 | #[inline (always)] |
508 | fn default() -> Countr { |
509 | Countr(0) |
510 | } |
511 | } |
512 | impl core::fmt::Debug for Countr { |
513 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { |
514 | f.debug_struct("Countr" ).field("count" , &self.count()).finish() |
515 | } |
516 | } |
517 | #[cfg (feature = "defmt" )] |
518 | impl defmt::Format for Countr { |
519 | fn format(&self, f: defmt::Formatter) { |
520 | #[derive (defmt :: Format)] |
521 | struct Countr { |
522 | count: u32, |
523 | } |
524 | let proxy = Countr { count: self.count() }; |
525 | defmt::write!(f, "{}" , proxy) |
526 | } |
527 | } |
528 | #[doc = "TAMP control register 1" ] |
529 | #[repr (transparent)] |
530 | #[derive (Copy, Clone, Eq, PartialEq)] |
531 | pub struct Cr1(pub u32); |
532 | impl Cr1 { |
533 | #[doc = "Tamper detection on INx enable" ] |
534 | #[inline (always)] |
535 | pub const fn tampe(&self, n: usize) -> bool { |
536 | assert!(n < 8usize); |
537 | let offs = 0usize + n * 1usize; |
538 | let val = (self.0 >> offs) & 0x01; |
539 | val != 0 |
540 | } |
541 | #[doc = "Tamper detection on INx enable" ] |
542 | #[inline (always)] |
543 | pub fn set_tampe(&mut self, n: usize, val: bool) { |
544 | assert!(n < 8usize); |
545 | let offs = 0usize + n * 1usize; |
546 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); |
547 | } |
548 | #[doc = "Internal tamper X enable" ] |
549 | #[inline (always)] |
550 | pub const fn itampe(&self, n: usize) -> bool { |
551 | assert!(n < 13usize); |
552 | let offs = 16usize + n * 1usize; |
553 | let val = (self.0 >> offs) & 0x01; |
554 | val != 0 |
555 | } |
556 | #[doc = "Internal tamper X enable" ] |
557 | #[inline (always)] |
558 | pub fn set_itampe(&mut self, n: usize, val: bool) { |
559 | assert!(n < 13usize); |
560 | let offs = 16usize + n * 1usize; |
561 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); |
562 | } |
563 | } |
564 | impl Default for Cr1 { |
565 | #[inline (always)] |
566 | fn default() -> Cr1 { |
567 | Cr1(0) |
568 | } |
569 | } |
570 | impl core::fmt::Debug for Cr1 { |
571 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { |
572 | f.debug_struct("Cr1" ) |
573 | .field( |
574 | "tampe" , |
575 | &[ |
576 | self.tampe(0usize), |
577 | self.tampe(1usize), |
578 | self.tampe(2usize), |
579 | self.tampe(3usize), |
580 | self.tampe(4usize), |
581 | self.tampe(5usize), |
582 | self.tampe(6usize), |
583 | self.tampe(7usize), |
584 | ], |
585 | ) |
586 | .field( |
587 | "itampe" , |
588 | &[ |
589 | self.itampe(0usize), |
590 | self.itampe(1usize), |
591 | self.itampe(2usize), |
592 | self.itampe(3usize), |
593 | self.itampe(4usize), |
594 | self.itampe(5usize), |
595 | self.itampe(6usize), |
596 | self.itampe(7usize), |
597 | self.itampe(8usize), |
598 | self.itampe(9usize), |
599 | self.itampe(10usize), |
600 | self.itampe(11usize), |
601 | self.itampe(12usize), |
602 | ], |
603 | ) |
604 | .finish() |
605 | } |
606 | } |
607 | #[cfg (feature = "defmt" )] |
608 | impl defmt::Format for Cr1 { |
609 | fn format(&self, f: defmt::Formatter) { |
610 | #[derive (defmt :: Format)] |
611 | struct Cr1 { |
612 | tampe: [bool; 8usize], |
613 | itampe: [bool; 13usize], |
614 | } |
615 | let proxy = Cr1 { |
616 | tampe: [ |
617 | self.tampe(0usize), |
618 | self.tampe(1usize), |
619 | self.tampe(2usize), |
620 | self.tampe(3usize), |
621 | self.tampe(4usize), |
622 | self.tampe(5usize), |
623 | self.tampe(6usize), |
624 | self.tampe(7usize), |
625 | ], |
626 | itampe: [ |
627 | self.itampe(0usize), |
628 | self.itampe(1usize), |
629 | self.itampe(2usize), |
630 | self.itampe(3usize), |
631 | self.itampe(4usize), |
632 | self.itampe(5usize), |
633 | self.itampe(6usize), |
634 | self.itampe(7usize), |
635 | self.itampe(8usize), |
636 | self.itampe(9usize), |
637 | self.itampe(10usize), |
638 | self.itampe(11usize), |
639 | self.itampe(12usize), |
640 | ], |
641 | }; |
642 | defmt::write!(f, "{}" , proxy) |
643 | } |
644 | } |
645 | #[doc = "TAMP control register 2" ] |
646 | #[repr (transparent)] |
647 | #[derive (Copy, Clone, Eq, PartialEq)] |
648 | pub struct Cr2(pub u32); |
649 | impl Cr2 { |
650 | #[doc = "Tamper X no erase" ] |
651 | #[inline (always)] |
652 | pub const fn tampnoer(&self, n: usize) -> bool { |
653 | assert!(n < 8usize); |
654 | let offs = 0usize + n * 1usize; |
655 | let val = (self.0 >> offs) & 0x01; |
656 | val != 0 |
657 | } |
658 | #[doc = "Tamper X no erase" ] |
659 | #[inline (always)] |
660 | pub fn set_tampnoer(&mut self, n: usize, val: bool) { |
661 | assert!(n < 8usize); |
662 | let offs = 0usize + n * 1usize; |
663 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); |
664 | } |
665 | #[doc = "Tamper X mask. The tamper 1 interrupt must not be enabled when TAMP1MSK is set." ] |
666 | #[inline (always)] |
667 | pub const fn tampmsk(&self, n: usize) -> bool { |
668 | assert!(n < 3usize); |
669 | let offs = 16usize + n * 1usize; |
670 | let val = (self.0 >> offs) & 0x01; |
671 | val != 0 |
672 | } |
673 | #[doc = "Tamper X mask. The tamper 1 interrupt must not be enabled when TAMP1MSK is set." ] |
674 | #[inline (always)] |
675 | pub fn set_tampmsk(&mut self, n: usize, val: bool) { |
676 | assert!(n < 3usize); |
677 | let offs = 16usize + n * 1usize; |
678 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); |
679 | } |
680 | #[doc = "Backup registers and device secrets access blocked" ] |
681 | #[inline (always)] |
682 | pub const fn bkblock(&self) -> bool { |
683 | let val = (self.0 >> 22usize) & 0x01; |
684 | val != 0 |
685 | } |
686 | #[doc = "Backup registers and device secrets access blocked" ] |
687 | #[inline (always)] |
688 | pub fn set_bkblock(&mut self, val: bool) { |
689 | self.0 = (self.0 & !(0x01 << 22usize)) | (((val as u32) & 0x01) << 22usize); |
690 | } |
691 | #[doc = "Backup registers and device secrets erase. Writing '1 to this bit reset the backup registers and device secrets(1). Writing 0 has no effect. This bit is always read as 0." ] |
692 | #[inline (always)] |
693 | pub const fn bkerase(&self) -> bool { |
694 | let val = (self.0 >> 23usize) & 0x01; |
695 | val != 0 |
696 | } |
697 | #[doc = "Backup registers and device secrets erase. Writing '1 to this bit reset the backup registers and device secrets(1). Writing 0 has no effect. This bit is always read as 0." ] |
698 | #[inline (always)] |
699 | pub fn set_bkerase(&mut self, val: bool) { |
700 | self.0 = (self.0 & !(0x01 << 23usize)) | (((val as u32) & 0x01) << 23usize); |
701 | } |
702 | #[doc = "Active level for tamper 1 input." ] |
703 | #[inline (always)] |
704 | pub const fn tamptrg(&self, n: usize) -> super::vals::Tamptrg { |
705 | assert!(n < 8usize); |
706 | let offs = 24usize + n * 1usize; |
707 | let val = (self.0 >> offs) & 0x01; |
708 | super::vals::Tamptrg::from_bits(val as u8) |
709 | } |
710 | #[doc = "Active level for tamper 1 input." ] |
711 | #[inline (always)] |
712 | pub fn set_tamptrg(&mut self, n: usize, val: super::vals::Tamptrg) { |
713 | assert!(n < 8usize); |
714 | let offs = 24usize + n * 1usize; |
715 | self.0 = (self.0 & !(0x01 << offs)) | (((val.to_bits() as u32) & 0x01) << offs); |
716 | } |
717 | } |
718 | impl Default for Cr2 { |
719 | #[inline (always)] |
720 | fn default() -> Cr2 { |
721 | Cr2(0) |
722 | } |
723 | } |
724 | impl core::fmt::Debug for Cr2 { |
725 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { |
726 | f.debug_struct("Cr2" ) |
727 | .field( |
728 | "tampnoer" , |
729 | &[ |
730 | self.tampnoer(0usize), |
731 | self.tampnoer(1usize), |
732 | self.tampnoer(2usize), |
733 | self.tampnoer(3usize), |
734 | self.tampnoer(4usize), |
735 | self.tampnoer(5usize), |
736 | self.tampnoer(6usize), |
737 | self.tampnoer(7usize), |
738 | ], |
739 | ) |
740 | .field( |
741 | "tampmsk" , |
742 | &[self.tampmsk(0usize), self.tampmsk(1usize), self.tampmsk(2usize)], |
743 | ) |
744 | .field("bkblock" , &self.bkblock()) |
745 | .field("bkerase" , &self.bkerase()) |
746 | .field( |
747 | "tamptrg" , |
748 | &[ |
749 | self.tamptrg(0usize), |
750 | self.tamptrg(1usize), |
751 | self.tamptrg(2usize), |
752 | self.tamptrg(3usize), |
753 | self.tamptrg(4usize), |
754 | self.tamptrg(5usize), |
755 | self.tamptrg(6usize), |
756 | self.tamptrg(7usize), |
757 | ], |
758 | ) |
759 | .finish() |
760 | } |
761 | } |
762 | #[cfg (feature = "defmt" )] |
763 | impl defmt::Format for Cr2 { |
764 | fn format(&self, f: defmt::Formatter) { |
765 | #[derive (defmt :: Format)] |
766 | struct Cr2 { |
767 | tampnoer: [bool; 8usize], |
768 | tampmsk: [bool; 3usize], |
769 | bkblock: bool, |
770 | bkerase: bool, |
771 | tamptrg: [super::vals::Tamptrg; 8usize], |
772 | } |
773 | let proxy = Cr2 { |
774 | tampnoer: [ |
775 | self.tampnoer(0usize), |
776 | self.tampnoer(1usize), |
777 | self.tampnoer(2usize), |
778 | self.tampnoer(3usize), |
779 | self.tampnoer(4usize), |
780 | self.tampnoer(5usize), |
781 | self.tampnoer(6usize), |
782 | self.tampnoer(7usize), |
783 | ], |
784 | tampmsk: [self.tampmsk(0usize), self.tampmsk(1usize), self.tampmsk(2usize)], |
785 | bkblock: self.bkblock(), |
786 | bkerase: self.bkerase(), |
787 | tamptrg: [ |
788 | self.tamptrg(0usize), |
789 | self.tamptrg(1usize), |
790 | self.tamptrg(2usize), |
791 | self.tamptrg(3usize), |
792 | self.tamptrg(4usize), |
793 | self.tamptrg(5usize), |
794 | self.tamptrg(6usize), |
795 | self.tamptrg(7usize), |
796 | ], |
797 | }; |
798 | defmt::write!(f, "{}" , proxy) |
799 | } |
800 | } |
801 | #[doc = "TAMP control register 3" ] |
802 | #[repr (transparent)] |
803 | #[derive (Copy, Clone, Eq, PartialEq)] |
804 | pub struct Cr3(pub u32); |
805 | impl Cr3 { |
806 | #[doc = "Internal Tamper X no erase" ] |
807 | #[inline (always)] |
808 | pub const fn itampnoer(&self, n: usize) -> bool { |
809 | assert!(n < 13usize); |
810 | let offs = 0usize + n * 1usize; |
811 | let val = (self.0 >> offs) & 0x01; |
812 | val != 0 |
813 | } |
814 | #[doc = "Internal Tamper X no erase" ] |
815 | #[inline (always)] |
816 | pub fn set_itampnoer(&mut self, n: usize, val: bool) { |
817 | assert!(n < 13usize); |
818 | let offs = 0usize + n * 1usize; |
819 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); |
820 | } |
821 | } |
822 | impl Default for Cr3 { |
823 | #[inline (always)] |
824 | fn default() -> Cr3 { |
825 | Cr3(0) |
826 | } |
827 | } |
828 | impl core::fmt::Debug for Cr3 { |
829 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { |
830 | f.debug_struct("Cr3" ) |
831 | .field( |
832 | "itampnoer" , |
833 | &[ |
834 | self.itampnoer(0usize), |
835 | self.itampnoer(1usize), |
836 | self.itampnoer(2usize), |
837 | self.itampnoer(3usize), |
838 | self.itampnoer(4usize), |
839 | self.itampnoer(5usize), |
840 | self.itampnoer(6usize), |
841 | self.itampnoer(7usize), |
842 | self.itampnoer(8usize), |
843 | self.itampnoer(9usize), |
844 | self.itampnoer(10usize), |
845 | self.itampnoer(11usize), |
846 | self.itampnoer(12usize), |
847 | ], |
848 | ) |
849 | .finish() |
850 | } |
851 | } |
852 | #[cfg (feature = "defmt" )] |
853 | impl defmt::Format for Cr3 { |
854 | fn format(&self, f: defmt::Formatter) { |
855 | #[derive (defmt :: Format)] |
856 | struct Cr3 { |
857 | itampnoer: [bool; 13usize], |
858 | } |
859 | let proxy = Cr3 { |
860 | itampnoer: [ |
861 | self.itampnoer(0usize), |
862 | self.itampnoer(1usize), |
863 | self.itampnoer(2usize), |
864 | self.itampnoer(3usize), |
865 | self.itampnoer(4usize), |
866 | self.itampnoer(5usize), |
867 | self.itampnoer(6usize), |
868 | self.itampnoer(7usize), |
869 | self.itampnoer(8usize), |
870 | self.itampnoer(9usize), |
871 | self.itampnoer(10usize), |
872 | self.itampnoer(11usize), |
873 | self.itampnoer(12usize), |
874 | ], |
875 | }; |
876 | defmt::write!(f, "{}" , proxy) |
877 | } |
878 | } |
879 | #[doc = "TAMP erase configuration register" ] |
880 | #[repr (transparent)] |
881 | #[derive (Copy, Clone, Eq, PartialEq)] |
882 | pub struct Ercfgr(pub u32); |
883 | impl Ercfgr { |
884 | #[doc = "Configurable device secrets configuration" ] |
885 | #[inline (always)] |
886 | pub const fn ercfg0(&self) -> bool { |
887 | let val = (self.0 >> 0usize) & 0x01; |
888 | val != 0 |
889 | } |
890 | #[doc = "Configurable device secrets configuration" ] |
891 | #[inline (always)] |
892 | pub fn set_ercfg0(&mut self, val: bool) { |
893 | self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize); |
894 | } |
895 | } |
896 | impl Default for Ercfgr { |
897 | #[inline (always)] |
898 | fn default() -> Ercfgr { |
899 | Ercfgr(0) |
900 | } |
901 | } |
902 | impl core::fmt::Debug for Ercfgr { |
903 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { |
904 | f.debug_struct("Ercfgr" ).field("ercfg0" , &self.ercfg0()).finish() |
905 | } |
906 | } |
907 | #[cfg (feature = "defmt" )] |
908 | impl defmt::Format for Ercfgr { |
909 | fn format(&self, f: defmt::Formatter) { |
910 | #[derive (defmt :: Format)] |
911 | struct Ercfgr { |
912 | ercfg0: bool, |
913 | } |
914 | let proxy = Ercfgr { ercfg0: self.ercfg0() }; |
915 | defmt::write!(f, "{}" , proxy) |
916 | } |
917 | } |
918 | #[doc = "TAMP filter control register" ] |
919 | #[repr (transparent)] |
920 | #[derive (Copy, Clone, Eq, PartialEq)] |
921 | pub struct Fltcr(pub u32); |
922 | impl Fltcr { |
923 | #[doc = "Tamper sampling frequency. Determines the frequency at which each of the INx inputs are sampled." ] |
924 | #[inline (always)] |
925 | pub const fn tampfreq(&self) -> super::vals::Tampfreq { |
926 | let val = (self.0 >> 0usize) & 0x07; |
927 | super::vals::Tampfreq::from_bits(val as u8) |
928 | } |
929 | #[doc = "Tamper sampling frequency. Determines the frequency at which each of the INx inputs are sampled." ] |
930 | #[inline (always)] |
931 | pub fn set_tampfreq(&mut self, val: super::vals::Tampfreq) { |
932 | self.0 = (self.0 & !(0x07 << 0usize)) | (((val.to_bits() as u32) & 0x07) << 0usize); |
933 | } |
934 | #[doc = "INx filter count. These bits determines the number of consecutive samples at the specified level (TAMP*TRG) needed to activate a tamper event. TAMPFLT is valid for each of the INx inputs." ] |
935 | #[inline (always)] |
936 | pub const fn tampflt(&self) -> super::vals::Tampflt { |
937 | let val = (self.0 >> 3usize) & 0x03; |
938 | super::vals::Tampflt::from_bits(val as u8) |
939 | } |
940 | #[doc = "INx filter count. These bits determines the number of consecutive samples at the specified level (TAMP*TRG) needed to activate a tamper event. TAMPFLT is valid for each of the INx inputs." ] |
941 | #[inline (always)] |
942 | pub fn set_tampflt(&mut self, val: super::vals::Tampflt) { |
943 | self.0 = (self.0 & !(0x03 << 3usize)) | (((val.to_bits() as u32) & 0x03) << 3usize); |
944 | } |
945 | #[doc = "INx precharge duration. These bit determines the duration of time during which the pull-up/is activated before each sample. TAMPPRCH is valid for each of the INx inputs." ] |
946 | #[inline (always)] |
947 | pub const fn tampprch(&self) -> super::vals::Tampprch { |
948 | let val = (self.0 >> 5usize) & 0x03; |
949 | super::vals::Tampprch::from_bits(val as u8) |
950 | } |
951 | #[doc = "INx precharge duration. These bit determines the duration of time during which the pull-up/is activated before each sample. TAMPPRCH is valid for each of the INx inputs." ] |
952 | #[inline (always)] |
953 | pub fn set_tampprch(&mut self, val: super::vals::Tampprch) { |
954 | self.0 = (self.0 & !(0x03 << 5usize)) | (((val.to_bits() as u32) & 0x03) << 5usize); |
955 | } |
956 | #[doc = "INx pull-up disable. This bit determines if each of the TAMPx pins are precharged before each sample." ] |
957 | #[inline (always)] |
958 | pub const fn tamppudis(&self) -> bool { |
959 | let val = (self.0 >> 7usize) & 0x01; |
960 | val != 0 |
961 | } |
962 | #[doc = "INx pull-up disable. This bit determines if each of the TAMPx pins are precharged before each sample." ] |
963 | #[inline (always)] |
964 | pub fn set_tamppudis(&mut self, val: bool) { |
965 | self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize); |
966 | } |
967 | } |
968 | impl Default for Fltcr { |
969 | #[inline (always)] |
970 | fn default() -> Fltcr { |
971 | Fltcr(0) |
972 | } |
973 | } |
974 | impl core::fmt::Debug for Fltcr { |
975 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { |
976 | f.debug_struct("Fltcr" ) |
977 | .field("tampfreq" , &self.tampfreq()) |
978 | .field("tampflt" , &self.tampflt()) |
979 | .field("tampprch" , &self.tampprch()) |
980 | .field("tamppudis" , &self.tamppudis()) |
981 | .finish() |
982 | } |
983 | } |
984 | #[cfg (feature = "defmt" )] |
985 | impl defmt::Format for Fltcr { |
986 | fn format(&self, f: defmt::Formatter) { |
987 | #[derive (defmt :: Format)] |
988 | struct Fltcr { |
989 | tampfreq: super::vals::Tampfreq, |
990 | tampflt: super::vals::Tampflt, |
991 | tampprch: super::vals::Tampprch, |
992 | tamppudis: bool, |
993 | } |
994 | let proxy = Fltcr { |
995 | tampfreq: self.tampfreq(), |
996 | tampflt: self.tampflt(), |
997 | tampprch: self.tampprch(), |
998 | tamppudis: self.tamppudis(), |
999 | }; |
1000 | defmt::write!(f, "{}" , proxy) |
1001 | } |
1002 | } |
1003 | #[doc = "TAMP interrupt enable register" ] |
1004 | #[repr (transparent)] |
1005 | #[derive (Copy, Clone, Eq, PartialEq)] |
1006 | pub struct Ier(pub u32); |
1007 | impl Ier { |
1008 | #[doc = "Tamper X interrupt enable" ] |
1009 | #[inline (always)] |
1010 | pub const fn tampie(&self, n: usize) -> bool { |
1011 | assert!(n < 8usize); |
1012 | let offs = 0usize + n * 1usize; |
1013 | let val = (self.0 >> offs) & 0x01; |
1014 | val != 0 |
1015 | } |
1016 | #[doc = "Tamper X interrupt enable" ] |
1017 | #[inline (always)] |
1018 | pub fn set_tampie(&mut self, n: usize, val: bool) { |
1019 | assert!(n < 8usize); |
1020 | let offs = 0usize + n * 1usize; |
1021 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); |
1022 | } |
1023 | #[doc = "Internal tamper X interrupt enable" ] |
1024 | #[inline (always)] |
1025 | pub const fn itampie(&self, n: usize) -> bool { |
1026 | assert!(n < 13usize); |
1027 | let offs = 16usize + n * 1usize; |
1028 | let val = (self.0 >> offs) & 0x01; |
1029 | val != 0 |
1030 | } |
1031 | #[doc = "Internal tamper X interrupt enable" ] |
1032 | #[inline (always)] |
1033 | pub fn set_itampie(&mut self, n: usize, val: bool) { |
1034 | assert!(n < 13usize); |
1035 | let offs = 16usize + n * 1usize; |
1036 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); |
1037 | } |
1038 | } |
1039 | impl Default for Ier { |
1040 | #[inline (always)] |
1041 | fn default() -> Ier { |
1042 | Ier(0) |
1043 | } |
1044 | } |
1045 | impl core::fmt::Debug for Ier { |
1046 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { |
1047 | f.debug_struct("Ier" ) |
1048 | .field( |
1049 | "tampie" , |
1050 | &[ |
1051 | self.tampie(0usize), |
1052 | self.tampie(1usize), |
1053 | self.tampie(2usize), |
1054 | self.tampie(3usize), |
1055 | self.tampie(4usize), |
1056 | self.tampie(5usize), |
1057 | self.tampie(6usize), |
1058 | self.tampie(7usize), |
1059 | ], |
1060 | ) |
1061 | .field( |
1062 | "itampie" , |
1063 | &[ |
1064 | self.itampie(0usize), |
1065 | self.itampie(1usize), |
1066 | self.itampie(2usize), |
1067 | self.itampie(3usize), |
1068 | self.itampie(4usize), |
1069 | self.itampie(5usize), |
1070 | self.itampie(6usize), |
1071 | self.itampie(7usize), |
1072 | self.itampie(8usize), |
1073 | self.itampie(9usize), |
1074 | self.itampie(10usize), |
1075 | self.itampie(11usize), |
1076 | self.itampie(12usize), |
1077 | ], |
1078 | ) |
1079 | .finish() |
1080 | } |
1081 | } |
1082 | #[cfg (feature = "defmt" )] |
1083 | impl defmt::Format for Ier { |
1084 | fn format(&self, f: defmt::Formatter) { |
1085 | #[derive (defmt :: Format)] |
1086 | struct Ier { |
1087 | tampie: [bool; 8usize], |
1088 | itampie: [bool; 13usize], |
1089 | } |
1090 | let proxy = Ier { |
1091 | tampie: [ |
1092 | self.tampie(0usize), |
1093 | self.tampie(1usize), |
1094 | self.tampie(2usize), |
1095 | self.tampie(3usize), |
1096 | self.tampie(4usize), |
1097 | self.tampie(5usize), |
1098 | self.tampie(6usize), |
1099 | self.tampie(7usize), |
1100 | ], |
1101 | itampie: [ |
1102 | self.itampie(0usize), |
1103 | self.itampie(1usize), |
1104 | self.itampie(2usize), |
1105 | self.itampie(3usize), |
1106 | self.itampie(4usize), |
1107 | self.itampie(5usize), |
1108 | self.itampie(6usize), |
1109 | self.itampie(7usize), |
1110 | self.itampie(8usize), |
1111 | self.itampie(9usize), |
1112 | self.itampie(10usize), |
1113 | self.itampie(11usize), |
1114 | self.itampie(12usize), |
1115 | ], |
1116 | }; |
1117 | defmt::write!(f, "{}" , proxy) |
1118 | } |
1119 | } |
1120 | #[doc = "TAMP non-secure masked interrupt status register" ] |
1121 | #[repr (transparent)] |
1122 | #[derive (Copy, Clone, Eq, PartialEq)] |
1123 | pub struct Misr(pub u32); |
1124 | impl Misr { |
1125 | #[doc = "TAMPx non-secure interrupt masked flag. This flag is set by hardware when the tamper X non-secure interrupt is raised." ] |
1126 | #[inline (always)] |
1127 | pub const fn tampmf(&self, n: usize) -> bool { |
1128 | assert!(n < 8usize); |
1129 | let offs = 0usize + n * 1usize; |
1130 | let val = (self.0 >> offs) & 0x01; |
1131 | val != 0 |
1132 | } |
1133 | #[doc = "TAMPx non-secure interrupt masked flag. This flag is set by hardware when the tamper X non-secure interrupt is raised." ] |
1134 | #[inline (always)] |
1135 | pub fn set_tampmf(&mut self, n: usize, val: bool) { |
1136 | assert!(n < 8usize); |
1137 | let offs = 0usize + n * 1usize; |
1138 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); |
1139 | } |
1140 | #[doc = "Internal tamper X non-secure interrupt masked flag. This flag is set by hardware when the internal tamper X non-secure interrupt is raised." ] |
1141 | #[inline (always)] |
1142 | pub const fn itampmf(&self, n: usize) -> bool { |
1143 | assert!(n < 13usize); |
1144 | let offs = 16usize + n * 1usize; |
1145 | let val = (self.0 >> offs) & 0x01; |
1146 | val != 0 |
1147 | } |
1148 | #[doc = "Internal tamper X non-secure interrupt masked flag. This flag is set by hardware when the internal tamper X non-secure interrupt is raised." ] |
1149 | #[inline (always)] |
1150 | pub fn set_itampmf(&mut self, n: usize, val: bool) { |
1151 | assert!(n < 13usize); |
1152 | let offs = 16usize + n * 1usize; |
1153 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); |
1154 | } |
1155 | } |
1156 | impl Default for Misr { |
1157 | #[inline (always)] |
1158 | fn default() -> Misr { |
1159 | Misr(0) |
1160 | } |
1161 | } |
1162 | impl core::fmt::Debug for Misr { |
1163 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { |
1164 | f.debug_struct("Misr" ) |
1165 | .field( |
1166 | "tampmf" , |
1167 | &[ |
1168 | self.tampmf(0usize), |
1169 | self.tampmf(1usize), |
1170 | self.tampmf(2usize), |
1171 | self.tampmf(3usize), |
1172 | self.tampmf(4usize), |
1173 | self.tampmf(5usize), |
1174 | self.tampmf(6usize), |
1175 | self.tampmf(7usize), |
1176 | ], |
1177 | ) |
1178 | .field( |
1179 | "itampmf" , |
1180 | &[ |
1181 | self.itampmf(0usize), |
1182 | self.itampmf(1usize), |
1183 | self.itampmf(2usize), |
1184 | self.itampmf(3usize), |
1185 | self.itampmf(4usize), |
1186 | self.itampmf(5usize), |
1187 | self.itampmf(6usize), |
1188 | self.itampmf(7usize), |
1189 | self.itampmf(8usize), |
1190 | self.itampmf(9usize), |
1191 | self.itampmf(10usize), |
1192 | self.itampmf(11usize), |
1193 | self.itampmf(12usize), |
1194 | ], |
1195 | ) |
1196 | .finish() |
1197 | } |
1198 | } |
1199 | #[cfg (feature = "defmt" )] |
1200 | impl defmt::Format for Misr { |
1201 | fn format(&self, f: defmt::Formatter) { |
1202 | #[derive (defmt :: Format)] |
1203 | struct Misr { |
1204 | tampmf: [bool; 8usize], |
1205 | itampmf: [bool; 13usize], |
1206 | } |
1207 | let proxy = Misr { |
1208 | tampmf: [ |
1209 | self.tampmf(0usize), |
1210 | self.tampmf(1usize), |
1211 | self.tampmf(2usize), |
1212 | self.tampmf(3usize), |
1213 | self.tampmf(4usize), |
1214 | self.tampmf(5usize), |
1215 | self.tampmf(6usize), |
1216 | self.tampmf(7usize), |
1217 | ], |
1218 | itampmf: [ |
1219 | self.itampmf(0usize), |
1220 | self.itampmf(1usize), |
1221 | self.itampmf(2usize), |
1222 | self.itampmf(3usize), |
1223 | self.itampmf(4usize), |
1224 | self.itampmf(5usize), |
1225 | self.itampmf(6usize), |
1226 | self.itampmf(7usize), |
1227 | self.itampmf(8usize), |
1228 | self.itampmf(9usize), |
1229 | self.itampmf(10usize), |
1230 | self.itampmf(11usize), |
1231 | self.itampmf(12usize), |
1232 | ], |
1233 | }; |
1234 | defmt::write!(f, "{}" , proxy) |
1235 | } |
1236 | } |
1237 | #[doc = "TAMP privilege mode control register" ] |
1238 | #[repr (transparent)] |
1239 | #[derive (Copy, Clone, Eq, PartialEq)] |
1240 | pub struct Privcr(pub u32); |
1241 | impl Privcr { |
1242 | #[doc = "Monotonic counter 1 privilege protection" ] |
1243 | #[inline (always)] |
1244 | pub const fn cnt1priv(&self) -> bool { |
1245 | let val = (self.0 >> 15usize) & 0x01; |
1246 | val != 0 |
1247 | } |
1248 | #[doc = "Monotonic counter 1 privilege protection" ] |
1249 | #[inline (always)] |
1250 | pub fn set_cnt1priv(&mut self, val: bool) { |
1251 | self.0 = (self.0 & !(0x01 << 15usize)) | (((val as u32) & 0x01) << 15usize); |
1252 | } |
1253 | #[doc = "Backup registers zone 1 privilege protection" ] |
1254 | #[inline (always)] |
1255 | pub const fn bkprwpriv(&self) -> bool { |
1256 | let val = (self.0 >> 29usize) & 0x01; |
1257 | val != 0 |
1258 | } |
1259 | #[doc = "Backup registers zone 1 privilege protection" ] |
1260 | #[inline (always)] |
1261 | pub fn set_bkprwpriv(&mut self, val: bool) { |
1262 | self.0 = (self.0 & !(0x01 << 29usize)) | (((val as u32) & 0x01) << 29usize); |
1263 | } |
1264 | #[doc = "Backup registers zone 2 privilege protection" ] |
1265 | #[inline (always)] |
1266 | pub const fn bkpwpriv(&self) -> bool { |
1267 | let val = (self.0 >> 30usize) & 0x01; |
1268 | val != 0 |
1269 | } |
1270 | #[doc = "Backup registers zone 2 privilege protection" ] |
1271 | #[inline (always)] |
1272 | pub fn set_bkpwpriv(&mut self, val: bool) { |
1273 | self.0 = (self.0 & !(0x01 << 30usize)) | (((val as u32) & 0x01) << 30usize); |
1274 | } |
1275 | #[doc = "Tamper privilege protection (excluding backup registers). Note: Refer to for details on the read protection." ] |
1276 | #[inline (always)] |
1277 | pub const fn tamppriv(&self) -> bool { |
1278 | let val = (self.0 >> 31usize) & 0x01; |
1279 | val != 0 |
1280 | } |
1281 | #[doc = "Tamper privilege protection (excluding backup registers). Note: Refer to for details on the read protection." ] |
1282 | #[inline (always)] |
1283 | pub fn set_tamppriv(&mut self, val: bool) { |
1284 | self.0 = (self.0 & !(0x01 << 31usize)) | (((val as u32) & 0x01) << 31usize); |
1285 | } |
1286 | } |
1287 | impl Default for Privcr { |
1288 | #[inline (always)] |
1289 | fn default() -> Privcr { |
1290 | Privcr(0) |
1291 | } |
1292 | } |
1293 | impl core::fmt::Debug for Privcr { |
1294 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { |
1295 | f.debug_struct("Privcr" ) |
1296 | .field("cnt1priv" , &self.cnt1priv()) |
1297 | .field("bkprwpriv" , &self.bkprwpriv()) |
1298 | .field("bkpwpriv" , &self.bkpwpriv()) |
1299 | .field("tamppriv" , &self.tamppriv()) |
1300 | .finish() |
1301 | } |
1302 | } |
1303 | #[cfg (feature = "defmt" )] |
1304 | impl defmt::Format for Privcr { |
1305 | fn format(&self, f: defmt::Formatter) { |
1306 | #[derive (defmt :: Format)] |
1307 | struct Privcr { |
1308 | cnt1priv: bool, |
1309 | bkprwpriv: bool, |
1310 | bkpwpriv: bool, |
1311 | tamppriv: bool, |
1312 | } |
1313 | let proxy = Privcr { |
1314 | cnt1priv: self.cnt1priv(), |
1315 | bkprwpriv: self.bkprwpriv(), |
1316 | bkpwpriv: self.bkpwpriv(), |
1317 | tamppriv: self.tamppriv(), |
1318 | }; |
1319 | defmt::write!(f, "{}" , proxy) |
1320 | } |
1321 | } |
1322 | #[doc = "TAMP status clear register" ] |
1323 | #[repr (transparent)] |
1324 | #[derive (Copy, Clone, Eq, PartialEq)] |
1325 | pub struct Scr(pub u32); |
1326 | impl Scr { |
1327 | #[doc = "Clear TAMPx detection flag. Writing 1 in this bit clears the TAMPxF bit in the SR register." ] |
1328 | #[inline (always)] |
1329 | pub const fn ctampf(&self, n: usize) -> bool { |
1330 | assert!(n < 8usize); |
1331 | let offs = 0usize + n * 1usize; |
1332 | let val = (self.0 >> offs) & 0x01; |
1333 | val != 0 |
1334 | } |
1335 | #[doc = "Clear TAMPx detection flag. Writing 1 in this bit clears the TAMPxF bit in the SR register." ] |
1336 | #[inline (always)] |
1337 | pub fn set_ctampf(&mut self, n: usize, val: bool) { |
1338 | assert!(n < 8usize); |
1339 | let offs = 0usize + n * 1usize; |
1340 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); |
1341 | } |
1342 | #[doc = "Clear ITAMPx detection flag. Writing 1 in this bit clears the ITAMPxF bit in the SR register." ] |
1343 | #[inline (always)] |
1344 | pub const fn citampf(&self, n: usize) -> bool { |
1345 | assert!(n < 13usize); |
1346 | let offs = 16usize + n * 1usize; |
1347 | let val = (self.0 >> offs) & 0x01; |
1348 | val != 0 |
1349 | } |
1350 | #[doc = "Clear ITAMPx detection flag. Writing 1 in this bit clears the ITAMPxF bit in the SR register." ] |
1351 | #[inline (always)] |
1352 | pub fn set_citampf(&mut self, n: usize, val: bool) { |
1353 | assert!(n < 13usize); |
1354 | let offs = 16usize + n * 1usize; |
1355 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); |
1356 | } |
1357 | } |
1358 | impl Default for Scr { |
1359 | #[inline (always)] |
1360 | fn default() -> Scr { |
1361 | Scr(0) |
1362 | } |
1363 | } |
1364 | impl core::fmt::Debug for Scr { |
1365 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { |
1366 | f.debug_struct("Scr" ) |
1367 | .field( |
1368 | "ctampf" , |
1369 | &[ |
1370 | self.ctampf(0usize), |
1371 | self.ctampf(1usize), |
1372 | self.ctampf(2usize), |
1373 | self.ctampf(3usize), |
1374 | self.ctampf(4usize), |
1375 | self.ctampf(5usize), |
1376 | self.ctampf(6usize), |
1377 | self.ctampf(7usize), |
1378 | ], |
1379 | ) |
1380 | .field( |
1381 | "citampf" , |
1382 | &[ |
1383 | self.citampf(0usize), |
1384 | self.citampf(1usize), |
1385 | self.citampf(2usize), |
1386 | self.citampf(3usize), |
1387 | self.citampf(4usize), |
1388 | self.citampf(5usize), |
1389 | self.citampf(6usize), |
1390 | self.citampf(7usize), |
1391 | self.citampf(8usize), |
1392 | self.citampf(9usize), |
1393 | self.citampf(10usize), |
1394 | self.citampf(11usize), |
1395 | self.citampf(12usize), |
1396 | ], |
1397 | ) |
1398 | .finish() |
1399 | } |
1400 | } |
1401 | #[cfg (feature = "defmt" )] |
1402 | impl defmt::Format for Scr { |
1403 | fn format(&self, f: defmt::Formatter) { |
1404 | #[derive (defmt :: Format)] |
1405 | struct Scr { |
1406 | ctampf: [bool; 8usize], |
1407 | citampf: [bool; 13usize], |
1408 | } |
1409 | let proxy = Scr { |
1410 | ctampf: [ |
1411 | self.ctampf(0usize), |
1412 | self.ctampf(1usize), |
1413 | self.ctampf(2usize), |
1414 | self.ctampf(3usize), |
1415 | self.ctampf(4usize), |
1416 | self.ctampf(5usize), |
1417 | self.ctampf(6usize), |
1418 | self.ctampf(7usize), |
1419 | ], |
1420 | citampf: [ |
1421 | self.citampf(0usize), |
1422 | self.citampf(1usize), |
1423 | self.citampf(2usize), |
1424 | self.citampf(3usize), |
1425 | self.citampf(4usize), |
1426 | self.citampf(5usize), |
1427 | self.citampf(6usize), |
1428 | self.citampf(7usize), |
1429 | self.citampf(8usize), |
1430 | self.citampf(9usize), |
1431 | self.citampf(10usize), |
1432 | self.citampf(11usize), |
1433 | self.citampf(12usize), |
1434 | ], |
1435 | }; |
1436 | defmt::write!(f, "{}" , proxy) |
1437 | } |
1438 | } |
1439 | #[doc = "TAMP secure mode register" ] |
1440 | #[repr (transparent)] |
1441 | #[derive (Copy, Clone, Eq, PartialEq)] |
1442 | pub struct Seccfgr(pub u32); |
1443 | impl Seccfgr { |
1444 | #[doc = "Backup registers read/write protection offset. Protection zone 1 is defined for backup registers from BKP0R to BKPxR (x = BKPRWSEC-1, from 0 to 128). if TZEN=1, these backup registers can be read and written only with secure access. If TZEN=0: the protection zone 1 can be read and written with non-secure access. If BKPRWSEC = 0: there is no protection zone 1. If BKPRWPRIV is set, BKPRWSEC \\[7:0 \\] |
1445 | can be written only in privileged mode." ] |
1446 | #[inline (always)] |
1447 | pub const fn bkprwsec(&self) -> u8 { |
1448 | let val = (self.0 >> 0usize) & 0xff; |
1449 | val as u8 |
1450 | } |
1451 | #[doc = "Backup registers read/write protection offset. Protection zone 1 is defined for backup registers from BKP0R to BKPxR (x = BKPRWSEC-1, from 0 to 128). if TZEN=1, these backup registers can be read and written only with secure access. If TZEN=0: the protection zone 1 can be read and written with non-secure access. If BKPRWSEC = 0: there is no protection zone 1. If BKPRWPRIV is set, BKPRWSEC \\[7:0 \\] |
1452 | can be written only in privileged mode." ] |
1453 | #[inline (always)] |
1454 | pub fn set_bkprwsec(&mut self, val: u8) { |
1455 | self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize); |
1456 | } |
1457 | #[doc = "Monotonic counter 1 secure protection" ] |
1458 | #[inline (always)] |
1459 | pub const fn cnt1sec(&self) -> bool { |
1460 | let val = (self.0 >> 15usize) & 0x01; |
1461 | val != 0 |
1462 | } |
1463 | #[doc = "Monotonic counter 1 secure protection" ] |
1464 | #[inline (always)] |
1465 | pub fn set_cnt1sec(&mut self, val: bool) { |
1466 | self.0 = (self.0 & !(0x01 << 15usize)) | (((val as u32) & 0x01) << 15usize); |
1467 | } |
1468 | #[doc = "Backup registers write protection offset. Protection zone 2 is defined for backup registers from BKPyR (y = BKPRWSEC, from 0 to 128) to BKPzR (z = BKPWSEC-1, from 0 to 128, BKPWSECBKPRWSEC): if TZEN=1, these backup registers can be written only with secure access. They can be read with secure or non-secure access. Protection zone 3 defined for backup registers from BKPtR (t = BKPWSEC, from 0 to 127). They can be read or written with secure or non-secure access. If TZEN=0: the protection zone 2 can be read and written with non-secure access. If BKPWSEC = 0 or if BKPWSEC BKPRWSEC: there is no protection zone 2. If BKPWPRIV is set, BKPRWSEC \\[7:0 \\] |
1469 | can be written only in privileged mode." ] |
1470 | #[inline (always)] |
1471 | pub const fn bkpwsec(&self) -> u8 { |
1472 | let val = (self.0 >> 16usize) & 0xff; |
1473 | val as u8 |
1474 | } |
1475 | #[doc = "Backup registers write protection offset. Protection zone 2 is defined for backup registers from BKPyR (y = BKPRWSEC, from 0 to 128) to BKPzR (z = BKPWSEC-1, from 0 to 128, BKPWSECBKPRWSEC): if TZEN=1, these backup registers can be written only with secure access. They can be read with secure or non-secure access. Protection zone 3 defined for backup registers from BKPtR (t = BKPWSEC, from 0 to 127). They can be read or written with secure or non-secure access. If TZEN=0: the protection zone 2 can be read and written with non-secure access. If BKPWSEC = 0 or if BKPWSEC BKPRWSEC: there is no protection zone 2. If BKPWPRIV is set, BKPRWSEC \\[7:0 \\] |
1476 | can be written only in privileged mode." ] |
1477 | #[inline (always)] |
1478 | pub fn set_bkpwsec(&mut self, val: u8) { |
1479 | self.0 = (self.0 & !(0xff << 16usize)) | (((val as u32) & 0xff) << 16usize); |
1480 | } |
1481 | #[doc = "Boot hardware key lock. This bit can be read and can only be written to 1 by software. It is cleared by hardware together with the backup registers following a tamper detection event or when the readout protection (RDP) is disabled." ] |
1482 | #[inline (always)] |
1483 | pub const fn bhklock(&self) -> bool { |
1484 | let val = (self.0 >> 30usize) & 0x01; |
1485 | val != 0 |
1486 | } |
1487 | #[doc = "Boot hardware key lock. This bit can be read and can only be written to 1 by software. It is cleared by hardware together with the backup registers following a tamper detection event or when the readout protection (RDP) is disabled." ] |
1488 | #[inline (always)] |
1489 | pub fn set_bhklock(&mut self, val: bool) { |
1490 | self.0 = (self.0 & !(0x01 << 30usize)) | (((val as u32) & 0x01) << 30usize); |
1491 | } |
1492 | #[doc = "Tamper protection (excluding monotonic counters and backup registers). Note: Refer to for details on the read protection." ] |
1493 | #[inline (always)] |
1494 | pub const fn tampsec(&self) -> bool { |
1495 | let val = (self.0 >> 31usize) & 0x01; |
1496 | val != 0 |
1497 | } |
1498 | #[doc = "Tamper protection (excluding monotonic counters and backup registers). Note: Refer to for details on the read protection." ] |
1499 | #[inline (always)] |
1500 | pub fn set_tampsec(&mut self, val: bool) { |
1501 | self.0 = (self.0 & !(0x01 << 31usize)) | (((val as u32) & 0x01) << 31usize); |
1502 | } |
1503 | } |
1504 | impl Default for Seccfgr { |
1505 | #[inline (always)] |
1506 | fn default() -> Seccfgr { |
1507 | Seccfgr(0) |
1508 | } |
1509 | } |
1510 | impl core::fmt::Debug for Seccfgr { |
1511 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { |
1512 | f.debug_struct("Seccfgr" ) |
1513 | .field("bkprwsec" , &self.bkprwsec()) |
1514 | .field("cnt1sec" , &self.cnt1sec()) |
1515 | .field("bkpwsec" , &self.bkpwsec()) |
1516 | .field("bhklock" , &self.bhklock()) |
1517 | .field("tampsec" , &self.tampsec()) |
1518 | .finish() |
1519 | } |
1520 | } |
1521 | #[cfg (feature = "defmt" )] |
1522 | impl defmt::Format for Seccfgr { |
1523 | fn format(&self, f: defmt::Formatter) { |
1524 | #[derive (defmt :: Format)] |
1525 | struct Seccfgr { |
1526 | bkprwsec: u8, |
1527 | cnt1sec: bool, |
1528 | bkpwsec: u8, |
1529 | bhklock: bool, |
1530 | tampsec: bool, |
1531 | } |
1532 | let proxy = Seccfgr { |
1533 | bkprwsec: self.bkprwsec(), |
1534 | cnt1sec: self.cnt1sec(), |
1535 | bkpwsec: self.bkpwsec(), |
1536 | bhklock: self.bhklock(), |
1537 | tampsec: self.tampsec(), |
1538 | }; |
1539 | defmt::write!(f, "{}" , proxy) |
1540 | } |
1541 | } |
1542 | #[doc = "TAMP secure masked interrupt status register" ] |
1543 | #[repr (transparent)] |
1544 | #[derive (Copy, Clone, Eq, PartialEq)] |
1545 | pub struct Smisr(pub u32); |
1546 | impl Smisr { |
1547 | #[doc = "TAMPx secure interrupt masked flag. This flag is set by hardware when the tamper X secure interrupt is raised." ] |
1548 | #[inline (always)] |
1549 | pub const fn tampmf(&self, n: usize) -> bool { |
1550 | assert!(n < 8usize); |
1551 | let offs = 0usize + n * 1usize; |
1552 | let val = (self.0 >> offs) & 0x01; |
1553 | val != 0 |
1554 | } |
1555 | #[doc = "TAMPx secure interrupt masked flag. This flag is set by hardware when the tamper X secure interrupt is raised." ] |
1556 | #[inline (always)] |
1557 | pub fn set_tampmf(&mut self, n: usize, val: bool) { |
1558 | assert!(n < 8usize); |
1559 | let offs = 0usize + n * 1usize; |
1560 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); |
1561 | } |
1562 | #[doc = "Internal tamper X secure interrupt masked flag. This flag is set by hardware when the internal tamper X secure interrupt is raised." ] |
1563 | #[inline (always)] |
1564 | pub const fn itampmf(&self, n: usize) -> bool { |
1565 | assert!(n < 13usize); |
1566 | let offs = 16usize + n * 1usize; |
1567 | let val = (self.0 >> offs) & 0x01; |
1568 | val != 0 |
1569 | } |
1570 | #[doc = "Internal tamper X secure interrupt masked flag. This flag is set by hardware when the internal tamper X secure interrupt is raised." ] |
1571 | #[inline (always)] |
1572 | pub fn set_itampmf(&mut self, n: usize, val: bool) { |
1573 | assert!(n < 13usize); |
1574 | let offs = 16usize + n * 1usize; |
1575 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); |
1576 | } |
1577 | } |
1578 | impl Default for Smisr { |
1579 | #[inline (always)] |
1580 | fn default() -> Smisr { |
1581 | Smisr(0) |
1582 | } |
1583 | } |
1584 | impl core::fmt::Debug for Smisr { |
1585 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { |
1586 | f.debug_struct("Smisr" ) |
1587 | .field( |
1588 | "tampmf" , |
1589 | &[ |
1590 | self.tampmf(0usize), |
1591 | self.tampmf(1usize), |
1592 | self.tampmf(2usize), |
1593 | self.tampmf(3usize), |
1594 | self.tampmf(4usize), |
1595 | self.tampmf(5usize), |
1596 | self.tampmf(6usize), |
1597 | self.tampmf(7usize), |
1598 | ], |
1599 | ) |
1600 | .field( |
1601 | "itampmf" , |
1602 | &[ |
1603 | self.itampmf(0usize), |
1604 | self.itampmf(1usize), |
1605 | self.itampmf(2usize), |
1606 | self.itampmf(3usize), |
1607 | self.itampmf(4usize), |
1608 | self.itampmf(5usize), |
1609 | self.itampmf(6usize), |
1610 | self.itampmf(7usize), |
1611 | self.itampmf(8usize), |
1612 | self.itampmf(9usize), |
1613 | self.itampmf(10usize), |
1614 | self.itampmf(11usize), |
1615 | self.itampmf(12usize), |
1616 | ], |
1617 | ) |
1618 | .finish() |
1619 | } |
1620 | } |
1621 | #[cfg (feature = "defmt" )] |
1622 | impl defmt::Format for Smisr { |
1623 | fn format(&self, f: defmt::Formatter) { |
1624 | #[derive (defmt :: Format)] |
1625 | struct Smisr { |
1626 | tampmf: [bool; 8usize], |
1627 | itampmf: [bool; 13usize], |
1628 | } |
1629 | let proxy = Smisr { |
1630 | tampmf: [ |
1631 | self.tampmf(0usize), |
1632 | self.tampmf(1usize), |
1633 | self.tampmf(2usize), |
1634 | self.tampmf(3usize), |
1635 | self.tampmf(4usize), |
1636 | self.tampmf(5usize), |
1637 | self.tampmf(6usize), |
1638 | self.tampmf(7usize), |
1639 | ], |
1640 | itampmf: [ |
1641 | self.itampmf(0usize), |
1642 | self.itampmf(1usize), |
1643 | self.itampmf(2usize), |
1644 | self.itampmf(3usize), |
1645 | self.itampmf(4usize), |
1646 | self.itampmf(5usize), |
1647 | self.itampmf(6usize), |
1648 | self.itampmf(7usize), |
1649 | self.itampmf(8usize), |
1650 | self.itampmf(9usize), |
1651 | self.itampmf(10usize), |
1652 | self.itampmf(11usize), |
1653 | self.itampmf(12usize), |
1654 | ], |
1655 | }; |
1656 | defmt::write!(f, "{}" , proxy) |
1657 | } |
1658 | } |
1659 | #[doc = "TAMP status register" ] |
1660 | #[repr (transparent)] |
1661 | #[derive (Copy, Clone, Eq, PartialEq)] |
1662 | pub struct Sr(pub u32); |
1663 | impl Sr { |
1664 | #[doc = "TAMPx detection flag. This flag is set by hardware when a tamper detection event is detected on the TAMPx input." ] |
1665 | #[inline (always)] |
1666 | pub const fn tampf(&self, n: usize) -> bool { |
1667 | assert!(n < 8usize); |
1668 | let offs = 0usize + n * 1usize; |
1669 | let val = (self.0 >> offs) & 0x01; |
1670 | val != 0 |
1671 | } |
1672 | #[doc = "TAMPx detection flag. This flag is set by hardware when a tamper detection event is detected on the TAMPx input." ] |
1673 | #[inline (always)] |
1674 | pub fn set_tampf(&mut self, n: usize, val: bool) { |
1675 | assert!(n < 8usize); |
1676 | let offs = 0usize + n * 1usize; |
1677 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); |
1678 | } |
1679 | #[doc = "Internal tamper X flag. This flag is set by hardware when a tamper detection event is detected on the internal tamper X." ] |
1680 | #[inline (always)] |
1681 | pub const fn itampf(&self, n: usize) -> bool { |
1682 | assert!(n < 13usize); |
1683 | let offs = 16usize + n * 1usize; |
1684 | let val = (self.0 >> offs) & 0x01; |
1685 | val != 0 |
1686 | } |
1687 | #[doc = "Internal tamper X flag. This flag is set by hardware when a tamper detection event is detected on the internal tamper X." ] |
1688 | #[inline (always)] |
1689 | pub fn set_itampf(&mut self, n: usize, val: bool) { |
1690 | assert!(n < 13usize); |
1691 | let offs = 16usize + n * 1usize; |
1692 | self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs); |
1693 | } |
1694 | } |
1695 | impl Default for Sr { |
1696 | #[inline (always)] |
1697 | fn default() -> Sr { |
1698 | Sr(0) |
1699 | } |
1700 | } |
1701 | impl core::fmt::Debug for Sr { |
1702 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { |
1703 | f.debug_struct("Sr" ) |
1704 | .field( |
1705 | "tampf" , |
1706 | &[ |
1707 | self.tampf(0usize), |
1708 | self.tampf(1usize), |
1709 | self.tampf(2usize), |
1710 | self.tampf(3usize), |
1711 | self.tampf(4usize), |
1712 | self.tampf(5usize), |
1713 | self.tampf(6usize), |
1714 | self.tampf(7usize), |
1715 | ], |
1716 | ) |
1717 | .field( |
1718 | "itampf" , |
1719 | &[ |
1720 | self.itampf(0usize), |
1721 | self.itampf(1usize), |
1722 | self.itampf(2usize), |
1723 | self.itampf(3usize), |
1724 | self.itampf(4usize), |
1725 | self.itampf(5usize), |
1726 | self.itampf(6usize), |
1727 | self.itampf(7usize), |
1728 | self.itampf(8usize), |
1729 | self.itampf(9usize), |
1730 | self.itampf(10usize), |
1731 | self.itampf(11usize), |
1732 | self.itampf(12usize), |
1733 | ], |
1734 | ) |
1735 | .finish() |
1736 | } |
1737 | } |
1738 | #[cfg (feature = "defmt" )] |
1739 | impl defmt::Format for Sr { |
1740 | fn format(&self, f: defmt::Formatter) { |
1741 | #[derive (defmt :: Format)] |
1742 | struct Sr { |
1743 | tampf: [bool; 8usize], |
1744 | itampf: [bool; 13usize], |
1745 | } |
1746 | let proxy = Sr { |
1747 | tampf: [ |
1748 | self.tampf(0usize), |
1749 | self.tampf(1usize), |
1750 | self.tampf(2usize), |
1751 | self.tampf(3usize), |
1752 | self.tampf(4usize), |
1753 | self.tampf(5usize), |
1754 | self.tampf(6usize), |
1755 | self.tampf(7usize), |
1756 | ], |
1757 | itampf: [ |
1758 | self.itampf(0usize), |
1759 | self.itampf(1usize), |
1760 | self.itampf(2usize), |
1761 | self.itampf(3usize), |
1762 | self.itampf(4usize), |
1763 | self.itampf(5usize), |
1764 | self.itampf(6usize), |
1765 | self.itampf(7usize), |
1766 | self.itampf(8usize), |
1767 | self.itampf(9usize), |
1768 | self.itampf(10usize), |
1769 | self.itampf(11usize), |
1770 | self.itampf(12usize), |
1771 | ], |
1772 | }; |
1773 | defmt::write!(f, "{}" , proxy) |
1774 | } |
1775 | } |
1776 | } |
1777 | pub mod vals { |
1778 | #[repr (u8)] |
1779 | #[derive (Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)] |
1780 | #[cfg_attr (feature = "defmt" , derive(defmt::Format))] |
1781 | pub enum Atcksel { |
1782 | #[doc = "RTCCLK is selected" ] |
1783 | DIV1 = 0x0, |
1784 | #[doc = "RTCCLK/2 is selected when (PREDIV_A+1) = 128 (actually selects 1st flip flop output)" ] |
1785 | DIV2 = 0x01, |
1786 | #[doc = "RTCCLK/4 is selected when (PREDIV_A+1) = 128 (actually selects 2nd flip flop output)" ] |
1787 | DIV4 = 0x02, |
1788 | _RESERVED_3 = 0x03, |
1789 | _RESERVED_4 = 0x04, |
1790 | _RESERVED_5 = 0x05, |
1791 | _RESERVED_6 = 0x06, |
1792 | #[doc = "RTCCLK/128 is selected when (PREDIV_A+1) = 128 (actually selects 7th flip flop output)" ] |
1793 | DIV128 = 0x07, |
1794 | } |
1795 | impl Atcksel { |
1796 | #[inline (always)] |
1797 | pub const fn from_bits(val: u8) -> Atcksel { |
1798 | unsafe { core::mem::transmute(val & 0x07) } |
1799 | } |
1800 | #[inline (always)] |
1801 | pub const fn to_bits(self) -> u8 { |
1802 | unsafe { core::mem::transmute(self) } |
1803 | } |
1804 | } |
1805 | impl From<u8> for Atcksel { |
1806 | #[inline (always)] |
1807 | fn from(val: u8) -> Atcksel { |
1808 | Atcksel::from_bits(val) |
1809 | } |
1810 | } |
1811 | impl From<Atcksel> for u8 { |
1812 | #[inline (always)] |
1813 | fn from(val: Atcksel) -> u8 { |
1814 | Atcksel::to_bits(val) |
1815 | } |
1816 | } |
1817 | #[repr (u8)] |
1818 | #[derive (Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)] |
1819 | #[cfg_attr (feature = "defmt" , derive(defmt::Format))] |
1820 | pub enum Tampflt { |
1821 | #[doc = "Tamper event is activated on edge of INx input transitions to the active level (no internal pull-up on INx input)." ] |
1822 | NO_FILTER = 0x0, |
1823 | #[doc = "Tamper event is activated after 2 consecutive samples at the active level." ] |
1824 | FILTER2 = 0x01, |
1825 | #[doc = "Tamper event is activated after 4 consecutive samples at the active level." ] |
1826 | FILTER4 = 0x02, |
1827 | #[doc = "Tamper event is activated after 8 consecutive samples at the active level." ] |
1828 | FILTER8 = 0x03, |
1829 | } |
1830 | impl Tampflt { |
1831 | #[inline (always)] |
1832 | pub const fn from_bits(val: u8) -> Tampflt { |
1833 | unsafe { core::mem::transmute(val & 0x03) } |
1834 | } |
1835 | #[inline (always)] |
1836 | pub const fn to_bits(self) -> u8 { |
1837 | unsafe { core::mem::transmute(self) } |
1838 | } |
1839 | } |
1840 | impl From<u8> for Tampflt { |
1841 | #[inline (always)] |
1842 | fn from(val: u8) -> Tampflt { |
1843 | Tampflt::from_bits(val) |
1844 | } |
1845 | } |
1846 | impl From<Tampflt> for u8 { |
1847 | #[inline (always)] |
1848 | fn from(val: Tampflt) -> u8 { |
1849 | Tampflt::to_bits(val) |
1850 | } |
1851 | } |
1852 | #[repr (u8)] |
1853 | #[derive (Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)] |
1854 | #[cfg_attr (feature = "defmt" , derive(defmt::Format))] |
1855 | pub enum Tampfreq { |
1856 | #[doc = "RTCCLK / 32768 (1 Hz when RTCCLK = 32768 Hz)" ] |
1857 | HZ_1 = 0x0, |
1858 | #[doc = "RTCCLK / 16384 (2 Hz when RTCCLK = 32768 Hz)" ] |
1859 | HZ_2 = 0x01, |
1860 | #[doc = "RTCCLK / 8192 (4 Hz when RTCCLK = 32768 Hz)" ] |
1861 | HZ_4 = 0x02, |
1862 | #[doc = "RTCCLK / 4096 (8 Hz when RTCCLK = 32768 Hz)" ] |
1863 | HZ_8 = 0x03, |
1864 | #[doc = "RTCCLK / 2048 (16 Hz when RTCCLK = 32768 Hz)" ] |
1865 | HZ_16 = 0x04, |
1866 | #[doc = "RTCCLK / 1024 (32 Hz when RTCCLK = 32768 Hz)" ] |
1867 | HZ_32 = 0x05, |
1868 | #[doc = "RTCCLK / 512 (64 Hz when RTCCLK = 32768 Hz)" ] |
1869 | HZ_64 = 0x06, |
1870 | #[doc = "RTCCLK / 256 (128 Hz when RTCCLK = 32768 Hz)" ] |
1871 | HZ_128 = 0x07, |
1872 | } |
1873 | impl Tampfreq { |
1874 | #[inline (always)] |
1875 | pub const fn from_bits(val: u8) -> Tampfreq { |
1876 | unsafe { core::mem::transmute(val & 0x07) } |
1877 | } |
1878 | #[inline (always)] |
1879 | pub const fn to_bits(self) -> u8 { |
1880 | unsafe { core::mem::transmute(self) } |
1881 | } |
1882 | } |
1883 | impl From<u8> for Tampfreq { |
1884 | #[inline (always)] |
1885 | fn from(val: u8) -> Tampfreq { |
1886 | Tampfreq::from_bits(val) |
1887 | } |
1888 | } |
1889 | impl From<Tampfreq> for u8 { |
1890 | #[inline (always)] |
1891 | fn from(val: Tampfreq) -> u8 { |
1892 | Tampfreq::to_bits(val) |
1893 | } |
1894 | } |
1895 | #[repr (u8)] |
1896 | #[derive (Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)] |
1897 | #[cfg_attr (feature = "defmt" , derive(defmt::Format))] |
1898 | pub enum Tampprch { |
1899 | #[doc = "1 RTCCLK cycle" ] |
1900 | CYCLES1 = 0x0, |
1901 | #[doc = "2 RTCCLK cycles" ] |
1902 | CYCLES2 = 0x01, |
1903 | #[doc = "4 RTCCLK cycles" ] |
1904 | CYCLES4 = 0x02, |
1905 | #[doc = "8 RTCCLK cycles" ] |
1906 | CYCLES8 = 0x03, |
1907 | } |
1908 | impl Tampprch { |
1909 | #[inline (always)] |
1910 | pub const fn from_bits(val: u8) -> Tampprch { |
1911 | unsafe { core::mem::transmute(val & 0x03) } |
1912 | } |
1913 | #[inline (always)] |
1914 | pub const fn to_bits(self) -> u8 { |
1915 | unsafe { core::mem::transmute(self) } |
1916 | } |
1917 | } |
1918 | impl From<u8> for Tampprch { |
1919 | #[inline (always)] |
1920 | fn from(val: u8) -> Tampprch { |
1921 | Tampprch::from_bits(val) |
1922 | } |
1923 | } |
1924 | impl From<Tampprch> for u8 { |
1925 | #[inline (always)] |
1926 | fn from(val: Tampprch) -> u8 { |
1927 | Tampprch::to_bits(val) |
1928 | } |
1929 | } |
1930 | #[repr (u8)] |
1931 | #[derive (Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)] |
1932 | #[cfg_attr (feature = "defmt" , derive(defmt::Format))] |
1933 | pub enum Tamptrg { |
1934 | #[doc = "If TAMPFLT 00 Tamper 2 input staying low triggers a tamper detection event." ] |
1935 | FILTERED_LOW_OR_UNFILTERED_HIGH = 0x0, |
1936 | #[doc = "If TAMPFLT 00 Tamper 2 input staying high triggers a tamper detection event." ] |
1937 | FILTERED_HIGH_OR_UNFILTERED_LOW = 0x01, |
1938 | } |
1939 | impl Tamptrg { |
1940 | #[inline (always)] |
1941 | pub const fn from_bits(val: u8) -> Tamptrg { |
1942 | unsafe { core::mem::transmute(val & 0x01) } |
1943 | } |
1944 | #[inline (always)] |
1945 | pub const fn to_bits(self) -> u8 { |
1946 | unsafe { core::mem::transmute(self) } |
1947 | } |
1948 | } |
1949 | impl From<u8> for Tamptrg { |
1950 | #[inline (always)] |
1951 | fn from(val: u8) -> Tamptrg { |
1952 | Tamptrg::from_bits(val) |
1953 | } |
1954 | } |
1955 | impl From<Tamptrg> for u8 { |
1956 | #[inline (always)] |
1957 | fn from(val: Tamptrg) -> u8 { |
1958 | Tamptrg::to_bits(val) |
1959 | } |
1960 | } |
1961 | } |
1962 | |