Skip to content

Commit 4573928

Browse files
bors[bot]lulf
andauthored
Merge #315
315: Use volatile read for ICSR register r=adamgreig a=lulf This prevents the compiler from optimizing the read. Edit: I also added a change to include the 9th bit in the IRQ. I can leave that out if it would break anything. #314 Co-authored-by: Ulf Lilleengen <[email protected]>
2 parents 62de02f + 59d30a4 commit 4573928

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

cortex-m-rt/macros/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream {
227227

228228
const SCB_ICSR: *const u32 = 0xE000_ED04 as *const u32;
229229

230-
let irqn = unsafe { core::ptr::read(SCB_ICSR) as u8 as i16 - 16 };
230+
let irqn = unsafe { (core::ptr::read_volatile(SCB_ICSR) & 0x1FF) as i16 - 16 };
231231

232232
#ident(irqn)
233233
}

0 commit comments

Comments
 (0)