aboutsummaryrefslogtreecommitdiff
path: root/imxrt1040evk/examples
diff options
context:
space:
mode:
Diffstat (limited to 'imxrt1040evk/examples')
-rw-r--r--imxrt1040evk/examples/smoke.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/imxrt1040evk/examples/smoke.rs b/imxrt1040evk/examples/smoke.rs
new file mode 100644
index 0000000..3730125
--- /dev/null
+++ b/imxrt1040evk/examples/smoke.rs
@@ -0,0 +1,36 @@
+#![no_main]
+#![no_std]
+
+use defmt_rtt as _;
+use imxrt1040evk::{self, Algorithm};
+use panic_probe as _;
+
+const LAST_SECTOR: usize = Algorithm::flash_size_bytes() - Algorithm::sector_size_bytes();
+
+#[imxrt_rt::entry]
+fn main() -> ! {
+ for _ in 0..5 {
+ let mut w25q64 = Algorithm::initialize();
+
+ let mut sector = [0_u8; Algorithm::sector_size_bytes()];
+ w25q64.flash_read(0, &mut sector[..4]);
+ let tag = u32::from_le_bytes(sector[..4].try_into().unwrap());
+ defmt::assert!(0x42464346 == tag, "{=u32:#010X}", tag);
+
+ w25q64.flash_erase_sector(LAST_SECTOR + 256);
+
+ sector.fill(0);
+ w25q64.flash_write(LAST_SECTOR, &sector);
+
+ sector.fill(u8::MAX);
+ w25q64.flash_read(LAST_SECTOR, &mut sector);
+ defmt::assert!(sector.iter().all(|byte| *byte == 0));
+
+ w25q64.flash_erase_sector(LAST_SECTOR + 123);
+
+ w25q64.flash_read(LAST_SECTOR, &mut sector);
+ defmt::assert!(sector.iter().all(|byte| *byte == u8::MAX));
+ }
+ defmt::println!("Pass");
+ loop {}
+}