Skip to content

Commit d802c58

Browse files
committed
Use volatile read for ICSR register
This prevents the compiler from optimizing the read
1 parent 02b308c commit d802c58

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) as u8 as i16 - 16 };
231231

232232
#ident(irqn)
233233
}

0 commit comments

Comments
 (0)