diff options
-rw-r--r-- | src/peripheral/itm.rs | 13 | ||||
-rw-r--r-- | src/peripheral/mpu.rs | 37 |
2 files changed, 48 insertions, 2 deletions
diff --git a/src/peripheral/itm.rs b/src/peripheral/itm.rs index 57d2ff8..c0d560f 100644 --- a/src/peripheral/itm.rs +++ b/src/peripheral/itm.rs @@ -53,8 +53,19 @@ impl Stim { } /// Returns `true` if the stimulus port is ready to accept more data + #[cfg(not(armv8m))] #[inline] pub fn is_fifo_ready(&self) -> bool { - unsafe { ptr::read_volatile(self.register.get()) & 1 == 1 } + unsafe { ptr::read_volatile(self.register.get()) & 0b1 == 1 } + } + + /// Returns `true` if the stimulus port is ready to accept more data + #[cfg(armv8m)] + #[inline] + pub fn is_fifo_ready(&self) -> bool { + // ARMv8-M adds a disabled bit; we indicate that we are ready to + // proceed with a stimulus write if the port is either ready (bit 0) or + // disabled (bit 1). + unsafe { ptr::read_volatile(self.register.get()) & 0b11 != 0 } } } diff --git a/src/peripheral/mpu.rs b/src/peripheral/mpu.rs index 09d06f0..4d53eb5 100644 --- a/src/peripheral/mpu.rs +++ b/src/peripheral/mpu.rs @@ -2,7 +2,8 @@ use volatile_register::{RO, RW}; -/// Register block +/// Register block for ARMv7-M +#[cfg(any(armv6m, armv7m, target_arch = "x86_64"))] // x86-64 is for rustdoc #[repr(C)] pub struct RegisterBlock { /// Type @@ -28,3 +29,37 @@ pub struct RegisterBlock { /// Alias 3 of RSAR pub rsar_a3: RW<u32>, } + +/// Register block for ARMv8-M +#[cfg(armv8m)] +#[repr(C)] +pub struct RegisterBlock { + /// Type + pub _type: RO<u32>, + /// Control + pub ctrl: RW<u32>, + /// Region Number + pub rnr: RW<u32>, + /// Region Base Address + pub rbar: RW<u32>, + /// Region Limit Address + pub rlar: RW<u32>, + /// Alias 1 of RBAR + pub rbar_a1: RW<u32>, + /// Alias 1 of RLAR + pub rlar_a1: RW<u32>, + /// Alias 2 of RBAR + pub rbar_a2: RW<u32>, + /// Alias 2 of RLAR + pub rlar_a2: RW<u32>, + /// Alias 3 of RBAR + pub rbar_a3: RW<u32>, + /// Alias 3 of RLAR + pub rlar_a3: RW<u32>, + + // Reserved word at offset 0xBC + _reserved: u32, + + /// Memory Attribute Indirection register 0 and 1 + pub mair: [RW<u32>; 2], +} |