diff options
| author | Dario Nieuwenhuis <[email protected]> | 2025-08-08 23:18:00 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-08-08 23:18:00 +0200 |
| commit | 3a6d927ed5a85fd2381d7896455265b5cd24c42d (patch) | |
| tree | 6e3669596380599c38535a3da7a403b178028abb /examples/nrf54l15 | |
| parent | 1d08cde6e45c900fad970d07529296f9850c3dff (diff) | |
| parent | 68b2c1fb4b39115800e82c0b26d736e13c8711dc (diff) | |
Merge branch 'main' into nrf54l15-wdt
Diffstat (limited to 'examples/nrf54l15')
| -rw-r--r-- | examples/nrf54l15/Cargo.toml | 2 | ||||
| -rw-r--r-- | examples/nrf54l15/src/bin/nvmc.rs | 44 |
2 files changed, 46 insertions, 0 deletions
diff --git a/examples/nrf54l15/Cargo.toml b/examples/nrf54l15/Cargo.toml index faa3a4abe..5f1ee50a0 100644 --- a/examples/nrf54l15/Cargo.toml +++ b/examples/nrf54l15/Cargo.toml | |||
| @@ -16,5 +16,7 @@ panic-probe = { version = "1.0.0", features = ["print-defmt"] } | |||
| 16 | cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } | 16 | cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } |
| 17 | cortex-m-rt = "0.7.0" | 17 | cortex-m-rt = "0.7.0" |
| 18 | 18 | ||
| 19 | embedded-storage = "0.3.1" | ||
| 20 | |||
| 19 | [profile.release] | 21 | [profile.release] |
| 20 | debug = 2 | 22 | debug = 2 |
diff --git a/examples/nrf54l15/src/bin/nvmc.rs b/examples/nrf54l15/src/bin/nvmc.rs new file mode 100644 index 000000000..f990604cd --- /dev/null +++ b/examples/nrf54l15/src/bin/nvmc.rs | |||
| @@ -0,0 +1,44 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | |||
| 4 | use defmt::{info, unwrap}; | ||
| 5 | use embassy_executor::Spawner; | ||
| 6 | use embassy_nrf::nvmc::{Nvmc, PAGE_SIZE}; | ||
| 7 | use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; | ||
| 8 | use {defmt_rtt as _, panic_probe as _}; | ||
| 9 | |||
| 10 | #[embassy_executor::main] | ||
| 11 | async fn main(_spawner: Spawner) { | ||
| 12 | let p = embassy_nrf::init(Default::default()); | ||
| 13 | info!("Hello RRAMC NVMC!"); | ||
| 14 | |||
| 15 | let mut f = Nvmc::new(p.RRAMC); | ||
| 16 | |||
| 17 | const ADDR: u32 = 0x80000; | ||
| 18 | let mut buf = [0u8; 4]; | ||
| 19 | |||
| 20 | info!("Reading..."); | ||
| 21 | unwrap!(f.read(ADDR, &mut buf)); | ||
| 22 | info!("Read: {=[u8]:x}", buf); | ||
| 23 | |||
| 24 | info!("Erasing..."); | ||
| 25 | unwrap!(f.erase(ADDR, ADDR + PAGE_SIZE as u32)); | ||
| 26 | |||
| 27 | info!("Reading..."); | ||
| 28 | unwrap!(f.read(ADDR, &mut buf)); | ||
| 29 | info!("Read: {=[u8]:x}", buf); | ||
| 30 | |||
| 31 | info!("Writing..."); | ||
| 32 | // 16 B (128-bit) write minimum | ||
| 33 | let out: [u8; 16] = [ | ||
| 34 | 0xaa, 0xaa, 0xaa, 0xaa, 0xbb, 0xbb, 0xbb, 0xbb, 0xcc, 0xcc, 0xcc, 0xcc, 0xdd, 0xdd, 0xdd, 0xdd, | ||
| 35 | ]; | ||
| 36 | unwrap!(f.write(ADDR, &out)); | ||
| 37 | |||
| 38 | info!("Reading..."); | ||
| 39 | // Can read arbitrary sizes | ||
| 40 | for addr in (ADDR..ADDR + 16).step_by(4) { | ||
| 41 | unwrap!(f.read(addr, &mut buf)); | ||
| 42 | info!("Read: {=[u8]:x}", buf); | ||
| 43 | } | ||
| 44 | } | ||
