1
0
Fork 0

main: Add demo fns to use on-board flash

This commit is contained in:
linuswck 2024-01-15 17:13:05 +08:00
parent d190b8b192
commit 42cd55645c
1 changed files with 25 additions and 1 deletions

View File

@ -37,7 +37,31 @@ fn main() -> ! {
let core_perif = CorePeripherals::take().unwrap(); let core_perif = CorePeripherals::take().unwrap();
let perif = Peripherals::take().unwrap(); let perif = Peripherals::take().unwrap();
let (mut wd, _flash_store, mut laser, mut thermostat,) = bootup(core_perif, perif); let (mut wd, mut flash_store, mut laser, mut thermostat,) = bootup(core_perif, perif);
let key = "test";
info!("Read the Flash Content Stored");
match flash_store.read(key).unwrap() {
Some(val) => {info!("Flash Valued Read: {:?}", val)}
_ => {info!("Key does not match")}
}
info!("Erasing Flash");
flash_store.erase().unwrap();
match flash_store.read(key).unwrap() {
Some(val) => {info!("Flash Valued Read: {:?}", val)}
_ => {info!("Key does not match")}
}
info!("Writing Flash");
let buf = [1, 2, 3, 4];
flash_store.write(key, &buf).unwrap();
info!("Reading Flash");
match flash_store.read(key).unwrap() {
Some(val) => {info!("Val: {:?}", val)}
_ => {info!("Key does not match")}
};
// https://github.com/iliekturtles/uom/blob/master/examples/si.rs // https://github.com/iliekturtles/uom/blob/master/examples/si.rs
let volt_fmt = ElectricPotential::format_args(volt, Abbreviation); let volt_fmt = ElectricPotential::format_args(volt, Abbreviation);