Skip to content
Snippets Groups Projects
Commit 1f563c4e authored by Henrik Theolin's avatar Henrik Theolin
Browse files

bare4_3

parent 8a1f801e
Branches
No related tags found
No related merge requests found
......@@ -39,8 +39,8 @@ use address::*;
#[inline(always)]
fn read_u32(addr: u32) -> u32 {
//unsafe { core::ptr::read_volatile(addr as *const _) }
core::ptr::read_volatile(addr as *const _)
unsafe { core::ptr::read_volatile(addr as *const _) }
//core::ptr::read_volatile(addr as *const _)
}
#[inline(always)]
......@@ -128,16 +128,20 @@ fn main() -> ! {
//
// Why is it important that ordering of volatile operations are ensured by the compiler?
//
// ** your answer here **
// ** Variable used by volatile operations may change between accesses,
// reordering might introduce undefined or unexpected behaviour,
// if a read is ordered before a write the value would alter and not return the expected,
// or if reading from a register is performed before that register is set as read. **
//
// Give an example in the above code, where reordering might make things go horribly wrong
// (hint, accessing a peripheral not being powered...)
//
// ** your answer here **
// ** Read or write to GPIOA_BSRR before GPIOA_MODER is set to output,
// doing anything before setting RCC_AHB1ENR would be bad **
//
// Without the non-reording proprety of `write_volatile/read_volatile` could that happen in theory
// (argue from the point of data dependencies).
//
// ** your answer here **
// ** Writing/Reading in wrong order would result in unexpexed results. **
//
// Commit your answers (bare4_3)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment