Skip to content

Commit 1c198a1

Browse files
committed
Initial ARMv8-M MPU support.
The v8-M MPU is entirely different from, and incompatible with, the earlier PMSA MPU. And so this commit does two things: 1. Makes the old RegisterBlock depend on armv6m (for M0+) and armv7m. 2. Defines a new RegisterBlock containing the right layout for v8m. The hack for documenting fields by opting in x86-64 means the v8m version won't appear in the docs.
1 parent c9c7539 commit 1c198a1

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

Diff for: src/peripheral/mpu.rs

+36-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
33
use volatile_register::{RO, RW};
44

5-
/// Register block
5+
/// Register block for ARMv7-M
6+
#[cfg(any(armv6m, armv7m, target_arch = "x86_64"))] // x86-64 is for rustdoc
67
#[repr(C)]
78
pub struct RegisterBlock {
89
/// Type
@@ -28,3 +29,37 @@ pub struct RegisterBlock {
2829
/// Alias 3 of RSAR
2930
pub rsar_a3: RW<u32>,
3031
}
32+
33+
/// Register block for ARMv8-M
34+
#[cfg(armv8m)]
35+
#[repr(C)]
36+
pub struct RegisterBlock {
37+
/// Type
38+
pub _type: RO<u32>,
39+
/// Control
40+
pub ctrl: RW<u32>,
41+
/// Region Number
42+
pub rnr: RW<u32>,
43+
/// Region Base Address
44+
pub rbar: RW<u32>,
45+
/// Region Limit Address
46+
pub rlar: RW<u32>,
47+
/// Alias 1 of RBAR
48+
pub rbar_a1: RW<u32>,
49+
/// Alias 1 of RLAR
50+
pub rlar_a1: RW<u32>,
51+
/// Alias 2 of RBAR
52+
pub rbar_a2: RW<u32>,
53+
/// Alias 2 of RLAR
54+
pub rlar_a2: RW<u32>,
55+
/// Alias 3 of RBAR
56+
pub rbar_a3: RW<u32>,
57+
/// Alias 3 of RLAR
58+
pub rlar_a3: RW<u32>,
59+
60+
// Reserved word at offset 0xBC
61+
_reserved: u32,
62+
63+
/// Memory Attribute Indirection register 0 and 1
64+
pub mair: [RW<u32>; 2],
65+
}

0 commit comments

Comments
 (0)