Skip to content

Commit 85afc7d

Browse files
committed
Add flash read/write example
1 parent 6a9d68e commit 85afc7d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

examples/flash_read_write.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ fn main() -> ! {
2020
if let Some(mut p) = pac::Peripherals::take() {
2121
let _ = p.RCC.configure().freeze(&mut p.FLASH);
2222

23-
const OFFSET_START: u32 = 32 * 1024;
24-
const OFFSET_END: u32 = 33 * 1024;
23+
// All examples use the first 16K of flash for the program so we use the first page after that
24+
const OFFSET_START: u32 = 16 * 1024;
25+
const OFFSET_END: u32 = OFFSET_START + 1024;
2526
// Unlock flash before writing
2627
let mut unlocked_flash = p.FLASH.unlocked();
2728

28-
// All examples use the first 16K of flash for the program so we use the first page after that
2929
NorFlash::erase(&mut unlocked_flash, OFFSET_START, OFFSET_END).unwrap();
3030

3131
// Write some data to the start of that page

0 commit comments

Comments
 (0)