1#[doc = r" Value read from the register"]
2pub struct R {
3 bits: u32,
4}
5#[doc = r" Value to write to the register"]
6pub struct W {
7 bits: u32,
8}
9impl super::PERM {
10 #[doc = r" Modifies the contents of the register"]
11 #[inline]
12 pub fn modify<F>(&self, f: F)
13 where
14 for<'w> F: FnOnce(&R, &'w mut W) -> &'w mut W,
15 {
16 let bits = self.register.get();
17 let r = R { bits: bits };
18 let mut w = W { bits: bits };
19 f(&r, &mut w);
20 self.register.set(w.bits);
21 }
22 #[doc = r" Reads the contents of the register"]
23 #[inline]
24 pub fn read(&self) -> R {
25 R {
26 bits: self.register.get(),
27 }
28 }
29 #[doc = r" Writes to the register"]
30 #[inline]
31 pub fn write<F>(&self, f: F)
32 where
33 F: FnOnce(&mut W) -> &mut W,
34 {
35 let mut w = W::reset_value();
36 f(&mut w);
37 self.register.set(w.bits);
38 }
39 #[doc = r" Writes the reset value to the register"]
40 #[inline]
41 pub fn reset(&self) {
42 self.write(|w| w)
43 }
44}
45#[doc = "Possible values of the field `SECUREMAPPING`"]
46#[derive(Clone, Copy, Debug, PartialEq)]
47pub enum SECUREMAPPINGR {
48 #[doc = "This peripheral is always accessible as a non-secure peripheral"]
49 NONSECURE,
50 #[doc = "This peripheral is always accessible as a secure peripheral"]
51 SECURE,
52 #[doc = "Non-secure or secure attribute for this peripheral is defined by the PERIPHID\\[n\\].PERM register"]
53 USERSELECTABLE,
54 #[doc = "This peripheral implements the split security mechanism. Non-secure or secure attribute for this peripheral is defined by the PERIPHID\\[n\\].PERM register."]
55 SPLIT,
56}
57impl SECUREMAPPINGR {
58 #[doc = r" Value of the field as raw bits"]
59 #[inline]
60 pub fn bits(&self) -> u8 {
61 match *self {
62 SECUREMAPPINGR::NONSECURE => 0,
63 SECUREMAPPINGR::SECURE => 1,
64 SECUREMAPPINGR::USERSELECTABLE => 2,
65 SECUREMAPPINGR::SPLIT => 3,
66 }
67 }
68 #[allow(missing_docs)]
69 #[doc(hidden)]
70 #[inline]
71 pub fn _from(value: u8) -> SECUREMAPPINGR {
72 match value {
73 0 => SECUREMAPPINGR::NONSECURE,
74 1 => SECUREMAPPINGR::SECURE,
75 2 => SECUREMAPPINGR::USERSELECTABLE,
76 3 => SECUREMAPPINGR::SPLIT,
77 _ => unreachable!(),
78 }
79 }
80 #[doc = "Checks if the value of the field is `NONSECURE`"]
81 #[inline]
82 pub fn is_non_secure(&self) -> bool {
83 *self == SECUREMAPPINGR::NONSECURE
84 }
85 #[doc = "Checks if the value of the field is `SECURE`"]
86 #[inline]
87 pub fn is_secure(&self) -> bool {
88 *self == SECUREMAPPINGR::SECURE
89 }
90 #[doc = "Checks if the value of the field is `USERSELECTABLE`"]
91 #[inline]
92 pub fn is_user_selectable(&self) -> bool {
93 *self == SECUREMAPPINGR::USERSELECTABLE
94 }
95 #[doc = "Checks if the value of the field is `SPLIT`"]
96 #[inline]
97 pub fn is_split(&self) -> bool {
98 *self == SECUREMAPPINGR::SPLIT
99 }
100}
101#[doc = "Possible values of the field `DMA`"]
102#[derive(Clone, Copy, Debug, PartialEq)]
103pub enum DMAR {
104 #[doc = "Peripheral has no DMA capability"]
105 NODMA,
106 #[doc = "Peripheral has DMA and DMA transfers always have the same security attribute as assigned to the peripheral"]
107 NOSEPARATEATTRIBUTE,
108 #[doc = "Peripheral has DMA and DMA transfers can have a different security attribute than the one assigned to the peripheral"]
109 SEPARATEATTRIBUTE,
110 #[doc = r" Reserved"]
111 _Reserved(u8),
112}
113impl DMAR {
114 #[doc = r" Value of the field as raw bits"]
115 #[inline]
116 pub fn bits(&self) -> u8 {
117 match *self {
118 DMAR::NODMA => 0,
119 DMAR::NOSEPARATEATTRIBUTE => 1,
120 DMAR::SEPARATEATTRIBUTE => 2,
121 DMAR::_Reserved(bits) => bits,
122 }
123 }
124 #[allow(missing_docs)]
125 #[doc(hidden)]
126 #[inline]
127 pub fn _from(value: u8) -> DMAR {
128 match value {
129 0 => DMAR::NODMA,
130 1 => DMAR::NOSEPARATEATTRIBUTE,
131 2 => DMAR::SEPARATEATTRIBUTE,
132 i => DMAR::_Reserved(i),
133 }
134 }
135 #[doc = "Checks if the value of the field is `NODMA`"]
136 #[inline]
137 pub fn is_no_dma(&self) -> bool {
138 *self == DMAR::NODMA
139 }
140 #[doc = "Checks if the value of the field is `NOSEPARATEATTRIBUTE`"]
141 #[inline]
142 pub fn is_no_separate_attribute(&self) -> bool {
143 *self == DMAR::NOSEPARATEATTRIBUTE
144 }
145 #[doc = "Checks if the value of the field is `SEPARATEATTRIBUTE`"]
146 #[inline]
147 pub fn is_separate_attribute(&self) -> bool {
148 *self == DMAR::SEPARATEATTRIBUTE
149 }
150}
151#[doc = "Possible values of the field `SECATTR`"]
152#[derive(Clone, Copy, Debug, PartialEq)]
153pub enum SECATTRR {
154 #[doc = "Peripheral is mapped in secure peripheral address space"]
155 SECURE,
156 #[doc = "If SECUREMAPPING == UserSelectable: Peripheral is mapped in non-secure peripheral address space. If SECUREMAPPING == Split: Peripheral is mapped in non-secure and secure peripheral address space."]
157 NONSECURE,
158}
159impl SECATTRR {
160 #[doc = r" Returns `true` if the bit is clear (0)"]
161 #[inline]
162 pub fn bit_is_clear(&self) -> bool {
163 !self.bit()
164 }
165 #[doc = r" Returns `true` if the bit is set (1)"]
166 #[inline]
167 pub fn bit_is_set(&self) -> bool {
168 self.bit()
169 }
170 #[doc = r" Value of the field as raw bits"]
171 #[inline]
172 pub fn bit(&self) -> bool {
173 match *self {
174 SECATTRR::SECURE => true,
175 SECATTRR::NONSECURE => false,
176 }
177 }
178 #[allow(missing_docs)]
179 #[doc(hidden)]
180 #[inline]
181 pub fn _from(value: bool) -> SECATTRR {
182 match value {
183 true => SECATTRR::SECURE,
184 false => SECATTRR::NONSECURE,
185 }
186 }
187 #[doc = "Checks if the value of the field is `SECURE`"]
188 #[inline]
189 pub fn is_secure(&self) -> bool {
190 *self == SECATTRR::SECURE
191 }
192 #[doc = "Checks if the value of the field is `NONSECURE`"]
193 #[inline]
194 pub fn is_non_secure(&self) -> bool {
195 *self == SECATTRR::NONSECURE
196 }
197}
198#[doc = "Possible values of the field `DMASEC`"]
199#[derive(Clone, Copy, Debug, PartialEq)]
200pub enum DMASECR {
201 #[doc = "DMA transfers initiated by this peripheral have the secure attribute set"]
202 SECURE,
203 #[doc = "DMA transfers initiated by this peripheral have the non-secure attribute set"]
204 NONSECURE,
205}
206impl DMASECR {
207 #[doc = r" Returns `true` if the bit is clear (0)"]
208 #[inline]
209 pub fn bit_is_clear(&self) -> bool {
210 !self.bit()
211 }
212 #[doc = r" Returns `true` if the bit is set (1)"]
213 #[inline]
214 pub fn bit_is_set(&self) -> bool {
215 self.bit()
216 }
217 #[doc = r" Value of the field as raw bits"]
218 #[inline]
219 pub fn bit(&self) -> bool {
220 match *self {
221 DMASECR::SECURE => true,
222 DMASECR::NONSECURE => false,
223 }
224 }
225 #[allow(missing_docs)]
226 #[doc(hidden)]
227 #[inline]
228 pub fn _from(value: bool) -> DMASECR {
229 match value {
230 true => DMASECR::SECURE,
231 false => DMASECR::NONSECURE,
232 }
233 }
234 #[doc = "Checks if the value of the field is `SECURE`"]
235 #[inline]
236 pub fn is_secure(&self) -> bool {
237 *self == DMASECR::SECURE
238 }
239 #[doc = "Checks if the value of the field is `NONSECURE`"]
240 #[inline]
241 pub fn is_non_secure(&self) -> bool {
242 *self == DMASECR::NONSECURE
243 }
244}
245#[doc = "Possible values of the field `LOCK`"]
246#[derive(Clone, Copy, Debug, PartialEq)]
247pub enum LOCKR {
248 #[doc = "This register can be updated"]
249 UNLOCKED,
250 #[doc = "The content of this register can't be changed until the next reset"]
251 LOCKED,
252}
253impl LOCKR {
254 #[doc = r" Returns `true` if the bit is clear (0)"]
255 #[inline]
256 pub fn bit_is_clear(&self) -> bool {
257 !self.bit()
258 }
259 #[doc = r" Returns `true` if the bit is set (1)"]
260 #[inline]
261 pub fn bit_is_set(&self) -> bool {
262 self.bit()
263 }
264 #[doc = r" Value of the field as raw bits"]
265 #[inline]
266 pub fn bit(&self) -> bool {
267 match *self {
268 LOCKR::UNLOCKED => false,
269 LOCKR::LOCKED => true,
270 }
271 }
272 #[allow(missing_docs)]
273 #[doc(hidden)]
274 #[inline]
275 pub fn _from(value: bool) -> LOCKR {
276 match value {
277 false => LOCKR::UNLOCKED,
278 true => LOCKR::LOCKED,
279 }
280 }
281 #[doc = "Checks if the value of the field is `UNLOCKED`"]
282 #[inline]
283 pub fn is_unlocked(&self) -> bool {
284 *self == LOCKR::UNLOCKED
285 }
286 #[doc = "Checks if the value of the field is `LOCKED`"]
287 #[inline]
288 pub fn is_locked(&self) -> bool {
289 *self == LOCKR::LOCKED
290 }
291}
292#[doc = "Possible values of the field `PRESENT`"]
293#[derive(Clone, Copy, Debug, PartialEq)]
294pub enum PRESENTR {
295 #[doc = "Peripheral is not present"]
296 NOTPRESENT,
297 #[doc = "Peripheral is present"]
298 ISPRESENT,
299}
300impl PRESENTR {
301 #[doc = r" Returns `true` if the bit is clear (0)"]
302 #[inline]
303 pub fn bit_is_clear(&self) -> bool {
304 !self.bit()
305 }
306 #[doc = r" Returns `true` if the bit is set (1)"]
307 #[inline]
308 pub fn bit_is_set(&self) -> bool {
309 self.bit()
310 }
311 #[doc = r" Value of the field as raw bits"]
312 #[inline]
313 pub fn bit(&self) -> bool {
314 match *self {
315 PRESENTR::NOTPRESENT => false,
316 PRESENTR::ISPRESENT => true,
317 }
318 }
319 #[allow(missing_docs)]
320 #[doc(hidden)]
321 #[inline]
322 pub fn _from(value: bool) -> PRESENTR {
323 match value {
324 false => PRESENTR::NOTPRESENT,
325 true => PRESENTR::ISPRESENT,
326 }
327 }
328 #[doc = "Checks if the value of the field is `NOTPRESENT`"]
329 #[inline]
330 pub fn is_not_present(&self) -> bool {
331 *self == PRESENTR::NOTPRESENT
332 }
333 #[doc = "Checks if the value of the field is `ISPRESENT`"]
334 #[inline]
335 pub fn is_is_present(&self) -> bool {
336 *self == PRESENTR::ISPRESENT
337 }
338}
339#[doc = "Values that can be written to the field `SECATTR`"]
340pub enum SECATTRW {
341 #[doc = "Peripheral is mapped in secure peripheral address space"]
342 SECURE,
343 #[doc = "If SECUREMAPPING == UserSelectable: Peripheral is mapped in non-secure peripheral address space. If SECUREMAPPING == Split: Peripheral is mapped in non-secure and secure peripheral address space."]
344 NONSECURE,
345}
346impl SECATTRW {
347 #[allow(missing_docs)]
348 #[doc(hidden)]
349 #[inline]
350 pub fn _bits(&self) -> bool {
351 match *self {
352 SECATTRW::SECURE => true,
353 SECATTRW::NONSECURE => false,
354 }
355 }
356}
357#[doc = r" Proxy"]
358pub struct _SECATTRW<'a> {
359 w: &'a mut W,
360}
361impl<'a> _SECATTRW<'a> {
362 #[doc = r" Writes `variant` to the field"]
363 #[inline]
364 pub fn variant(self, variant: SECATTRW) -> &'a mut W {
365 {
366 self.bit(variant._bits())
367 }
368 }
369 #[doc = "Peripheral is mapped in secure peripheral address space"]
370 #[inline]
371 pub fn secure(self) -> &'a mut W {
372 self.variant(SECATTRW::SECURE)
373 }
374 #[doc = "If SECUREMAPPING == UserSelectable: Peripheral is mapped in non-secure peripheral address space. If SECUREMAPPING == Split: Peripheral is mapped in non-secure and secure peripheral address space."]
375 #[inline]
376 pub fn non_secure(self) -> &'a mut W {
377 self.variant(SECATTRW::NONSECURE)
378 }
379 #[doc = r" Sets the field bit"]
380 pub fn set_bit(self) -> &'a mut W {
381 self.bit(true)
382 }
383 #[doc = r" Clears the field bit"]
384 pub fn clear_bit(self) -> &'a mut W {
385 self.bit(false)
386 }
387 #[doc = r" Writes raw bits to the field"]
388 #[inline]
389 pub fn bit(self, value: bool) -> &'a mut W {
390 const MASK: bool = true;
391 const OFFSET: u8 = 4;
392 self.w.bits &= !((MASK as u32) << OFFSET);
393 self.w.bits |= ((value & MASK) as u32) << OFFSET;
394 self.w
395 }
396}
397#[doc = "Values that can be written to the field `DMASEC`"]
398pub enum DMASECW {
399 #[doc = "DMA transfers initiated by this peripheral have the secure attribute set"]
400 SECURE,
401 #[doc = "DMA transfers initiated by this peripheral have the non-secure attribute set"]
402 NONSECURE,
403}
404impl DMASECW {
405 #[allow(missing_docs)]
406 #[doc(hidden)]
407 #[inline]
408 pub fn _bits(&self) -> bool {
409 match *self {
410 DMASECW::SECURE => true,
411 DMASECW::NONSECURE => false,
412 }
413 }
414}
415#[doc = r" Proxy"]
416pub struct _DMASECW<'a> {
417 w: &'a mut W,
418}
419impl<'a> _DMASECW<'a> {
420 #[doc = r" Writes `variant` to the field"]
421 #[inline]
422 pub fn variant(self, variant: DMASECW) -> &'a mut W {
423 {
424 self.bit(variant._bits())
425 }
426 }
427 #[doc = "DMA transfers initiated by this peripheral have the secure attribute set"]
428 #[inline]
429 pub fn secure(self) -> &'a mut W {
430 self.variant(DMASECW::SECURE)
431 }
432 #[doc = "DMA transfers initiated by this peripheral have the non-secure attribute set"]
433 #[inline]
434 pub fn non_secure(self) -> &'a mut W {
435 self.variant(DMASECW::NONSECURE)
436 }
437 #[doc = r" Sets the field bit"]
438 pub fn set_bit(self) -> &'a mut W {
439 self.bit(true)
440 }
441 #[doc = r" Clears the field bit"]
442 pub fn clear_bit(self) -> &'a mut W {
443 self.bit(false)
444 }
445 #[doc = r" Writes raw bits to the field"]
446 #[inline]
447 pub fn bit(self, value: bool) -> &'a mut W {
448 const MASK: bool = true;
449 const OFFSET: u8 = 5;
450 self.w.bits &= !((MASK as u32) << OFFSET);
451 self.w.bits |= ((value & MASK) as u32) << OFFSET;
452 self.w
453 }
454}
455#[doc = "Values that can be written to the field `LOCK`"]
456pub enum LOCKW {
457 #[doc = "This register can be updated"]
458 UNLOCKED,
459 #[doc = "The content of this register can't be changed until the next reset"]
460 LOCKED,
461}
462impl LOCKW {
463 #[allow(missing_docs)]
464 #[doc(hidden)]
465 #[inline]
466 pub fn _bits(&self) -> bool {
467 match *self {
468 LOCKW::UNLOCKED => false,
469 LOCKW::LOCKED => true,
470 }
471 }
472}
473#[doc = r" Proxy"]
474pub struct _LOCKW<'a> {
475 w: &'a mut W,
476}
477impl<'a> _LOCKW<'a> {
478 #[doc = r" Writes `variant` to the field"]
479 #[inline]
480 pub fn variant(self, variant: LOCKW) -> &'a mut W {
481 {
482 self.bit(variant._bits())
483 }
484 }
485 #[doc = "This register can be updated"]
486 #[inline]
487 pub fn unlocked(self) -> &'a mut W {
488 self.variant(LOCKW::UNLOCKED)
489 }
490 #[doc = "The content of this register can't be changed until the next reset"]
491 #[inline]
492 pub fn locked(self) -> &'a mut W {
493 self.variant(LOCKW::LOCKED)
494 }
495 #[doc = r" Sets the field bit"]
496 pub fn set_bit(self) -> &'a mut W {
497 self.bit(true)
498 }
499 #[doc = r" Clears the field bit"]
500 pub fn clear_bit(self) -> &'a mut W {
501 self.bit(false)
502 }
503 #[doc = r" Writes raw bits to the field"]
504 #[inline]
505 pub fn bit(self, value: bool) -> &'a mut W {
506 const MASK: bool = true;
507 const OFFSET: u8 = 8;
508 self.w.bits &= !((MASK as u32) << OFFSET);
509 self.w.bits |= ((value & MASK) as u32) << OFFSET;
510 self.w
511 }
512}
513impl R {
514 #[doc = r" Value of the register as raw bits"]
515 #[inline]
516 pub fn bits(&self) -> u32 {
517 self.bits
518 }
519 #[doc = "Bits 0:1 - Define configuration capabilities for TrustZone Cortex-M secure attribute"]
520 #[inline]
521 pub fn securemapping(&self) -> SECUREMAPPINGR {
522 SECUREMAPPINGR::_from({
523 const MASK: u8 = 3;
524 const OFFSET: u8 = 0;
525 ((self.bits >> OFFSET) & MASK as u32) as u8
526 })
527 }
528 #[doc = "Bits 2:3 - Indicate if the peripheral has DMA capabilities and if DMA transfer can be assigned to a different security attribute than the peripheral itself"]
529 #[inline]
530 pub fn dma(&self) -> DMAR {
531 DMAR::_from({
532 const MASK: u8 = 3;
533 const OFFSET: u8 = 2;
534 ((self.bits >> OFFSET) & MASK as u32) as u8
535 })
536 }
537 #[doc = "Bit 4 - Peripheral security mapping"]
538 #[inline]
539 pub fn secattr(&self) -> SECATTRR {
540 SECATTRR::_from({
541 const MASK: bool = true;
542 const OFFSET: u8 = 4;
543 ((self.bits >> OFFSET) & MASK as u32) != 0
544 })
545 }
546 #[doc = "Bit 5 - Security attribution for the DMA transfer"]
547 #[inline]
548 pub fn dmasec(&self) -> DMASECR {
549 DMASECR::_from({
550 const MASK: bool = true;
551 const OFFSET: u8 = 5;
552 ((self.bits >> OFFSET) & MASK as u32) != 0
553 })
554 }
555 #[doc = "Bit 8"]
556 #[inline]
557 pub fn lock(&self) -> LOCKR {
558 LOCKR::_from({
559 const MASK: bool = true;
560 const OFFSET: u8 = 8;
561 ((self.bits >> OFFSET) & MASK as u32) != 0
562 })
563 }
564 #[doc = "Bit 31 - Indicate if a peripheral is present with ID n"]
565 #[inline]
566 pub fn present(&self) -> PRESENTR {
567 PRESENTR::_from({
568 const MASK: bool = true;
569 const OFFSET: u8 = 31;
570 ((self.bits >> OFFSET) & MASK as u32) != 0
571 })
572 }
573}
574impl W {
575 #[doc = r" Reset value of the register"]
576 #[inline]
577 pub fn reset_value() -> W {
578 W { bits: 18 }
579 }
580 #[doc = r" Writes raw bits to the register"]
581 #[inline]
582 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
583 self.bits = bits;
584 self
585 }
586 #[doc = "Bit 4 - Peripheral security mapping"]
587 #[inline]
588 pub fn secattr(&mut self) -> _SECATTRW {
589 _SECATTRW { w: self }
590 }
591 #[doc = "Bit 5 - Security attribution for the DMA transfer"]
592 #[inline]
593 pub fn dmasec(&mut self) -> _DMASECW {
594 _DMASECW { w: self }
595 }
596 #[doc = "Bit 8"]
597 #[inline]
598 pub fn lock(&mut self) -> _LOCKW {
599 _LOCKW { w: self }
600 }
601}