Skip to content

Commit b725dfb

Browse files
bors[bot]cbiffle
andauthored
Merge #227
227: ITM: don't test reserved bits in is_fifo_ready r=adamgreig a=bcantrill This is a follow up to the discussion in #219, capturing the conclusion by @cbiffle and @adamgreig there: to indicate that the ITM FIFO is ready on FIFOREADY (only) on ARMv7-M (only) and to indicate the FIFI is ready on *either* FIFOREADY *or* DISABLED on ARMv8-M. ITM has been tested and verified on an ARMv7-M CPU (an STM32F407, a Cortex-M4) and an ARMv8-M CPU (an LPC55S69, a Cortex-M33). Without this fix, any use of ITM will hang on ARMv8-M -- which may in fact be the root cause of #74... Co-authored-by: Cliff L. Biffle <[email protected]>
2 parents c9c7539 + 705812c commit b725dfb

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/peripheral/itm.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,19 @@ impl Stim {
5353
}
5454

5555
/// Returns `true` if the stimulus port is ready to accept more data
56+
#[cfg(not(armv8m))]
5657
#[inline]
5758
pub fn is_fifo_ready(&self) -> bool {
58-
unsafe { ptr::read_volatile(self.register.get()) & 1 == 1 }
59+
unsafe { ptr::read_volatile(self.register.get()) & 0b1 == 1 }
60+
}
61+
62+
/// Returns `true` if the stimulus port is ready to accept more data
63+
#[cfg(armv8m)]
64+
#[inline]
65+
pub fn is_fifo_ready(&self) -> bool {
66+
// ARMv8-M adds a disabled bit; we indicate that we are ready to
67+
// proceed with a stimulus write if the port is either ready (bit 0) or
68+
// disabled (bit 1).
69+
unsafe { ptr::read_volatile(self.register.get()) & 0b11 != 0 }
5970
}
6071
}

0 commit comments

Comments
 (0)