diff options
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/boot/application/rp/src/bin/a.rs | 4 | ||||
| -rw-r--r-- | examples/rp/src/bin/flash.rs | 34 |
2 files changed, 19 insertions, 19 deletions
diff --git a/examples/boot/application/rp/src/bin/a.rs b/examples/boot/application/rp/src/bin/a.rs index f0dda39d0..15fdaca82 100644 --- a/examples/boot/application/rp/src/bin/a.rs +++ b/examples/boot/application/rp/src/bin/a.rs | |||
| @@ -7,7 +7,7 @@ use core::cell::RefCell; | |||
| 7 | use defmt_rtt as _; | 7 | use defmt_rtt as _; |
| 8 | use embassy_boot_rp::*; | 8 | use embassy_boot_rp::*; |
| 9 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
| 10 | use embassy_rp::flash::{self, Flash}; | 10 | use embassy_rp::flash::Flash; |
| 11 | use embassy_rp::gpio::{Level, Output}; | 11 | use embassy_rp::gpio::{Level, Output}; |
| 12 | use embassy_rp::watchdog::Watchdog; | 12 | use embassy_rp::watchdog::Watchdog; |
| 13 | use embassy_sync::blocking_mutex::Mutex; | 13 | use embassy_sync::blocking_mutex::Mutex; |
| @@ -34,7 +34,7 @@ async fn main(_s: Spawner) { | |||
| 34 | let mut watchdog = Watchdog::new(p.WATCHDOG); | 34 | let mut watchdog = Watchdog::new(p.WATCHDOG); |
| 35 | watchdog.start(Duration::from_secs(8)); | 35 | watchdog.start(Duration::from_secs(8)); |
| 36 | 36 | ||
| 37 | let flash = Flash::<_, flash::Blocking, FLASH_SIZE>::new(p.FLASH); | 37 | let flash = Flash::<_, _, FLASH_SIZE>::new_blocking(p.FLASH); |
| 38 | let flash = Mutex::new(RefCell::new(flash)); | 38 | let flash = Mutex::new(RefCell::new(flash)); |
| 39 | 39 | ||
| 40 | let config = FirmwareUpdaterConfig::from_linkerfile_blocking(&flash); | 40 | let config = FirmwareUpdaterConfig::from_linkerfile_blocking(&flash); |
diff --git a/examples/rp/src/bin/flash.rs b/examples/rp/src/bin/flash.rs index 88bb931d2..911a657eb 100644 --- a/examples/rp/src/bin/flash.rs +++ b/examples/rp/src/bin/flash.rs | |||
| @@ -28,12 +28,12 @@ async fn main(_spawner: Spawner) { | |||
| 28 | let mut flash = embassy_rp::flash::Flash::<_, Async, FLASH_SIZE>::new(p.FLASH, p.DMA_CH0); | 28 | let mut flash = embassy_rp::flash::Flash::<_, Async, FLASH_SIZE>::new(p.FLASH, p.DMA_CH0); |
| 29 | 29 | ||
| 30 | // Get JEDEC id | 30 | // Get JEDEC id |
| 31 | let jedec = flash.jedec_id().unwrap(); | 31 | let jedec = flash.blocking_jedec_id().unwrap(); |
| 32 | info!("jedec id: 0x{:x}", jedec); | 32 | info!("jedec id: 0x{:x}", jedec); |
| 33 | 33 | ||
| 34 | // Get unique id | 34 | // Get unique id |
| 35 | let mut uid = [0; 8]; | 35 | let mut uid = [0; 8]; |
| 36 | flash.unique_id(&mut uid).unwrap(); | 36 | flash.blocking_unique_id(&mut uid).unwrap(); |
| 37 | info!("unique id: {:?}", uid); | 37 | info!("unique id: {:?}", uid); |
| 38 | 38 | ||
| 39 | erase_write_sector(&mut flash, 0x00); | 39 | erase_write_sector(&mut flash, 0x00); |
| @@ -48,25 +48,25 @@ async fn main(_spawner: Spawner) { | |||
| 48 | fn multiwrite_bytes(flash: &mut embassy_rp::flash::Flash<'_, FLASH, Async, FLASH_SIZE>, offset: u32) { | 48 | fn multiwrite_bytes(flash: &mut embassy_rp::flash::Flash<'_, FLASH, Async, FLASH_SIZE>, offset: u32) { |
| 49 | info!(">>>> [multiwrite_bytes]"); | 49 | info!(">>>> [multiwrite_bytes]"); |
| 50 | let mut read_buf = [0u8; ERASE_SIZE]; | 50 | let mut read_buf = [0u8; ERASE_SIZE]; |
| 51 | defmt::unwrap!(flash.read(ADDR_OFFSET + offset, &mut read_buf)); | 51 | defmt::unwrap!(flash.blocking_read(ADDR_OFFSET + offset, &mut read_buf)); |
| 52 | 52 | ||
| 53 | info!("Addr of flash block is {:x}", ADDR_OFFSET + offset + FLASH_BASE as u32); | 53 | info!("Addr of flash block is {:x}", ADDR_OFFSET + offset + FLASH_BASE as u32); |
| 54 | info!("Contents start with {=[u8]}", read_buf[0..4]); | 54 | info!("Contents start with {=[u8]}", read_buf[0..4]); |
| 55 | 55 | ||
| 56 | defmt::unwrap!(flash.erase(ADDR_OFFSET + offset, ADDR_OFFSET + offset + ERASE_SIZE as u32)); | 56 | defmt::unwrap!(flash.blocking_erase(ADDR_OFFSET + offset, ADDR_OFFSET + offset + ERASE_SIZE as u32)); |
| 57 | 57 | ||
| 58 | defmt::unwrap!(flash.read(ADDR_OFFSET + offset, &mut read_buf)); | 58 | defmt::unwrap!(flash.blocking_read(ADDR_OFFSET + offset, &mut read_buf)); |
| 59 | info!("Contents after erase starts with {=[u8]}", read_buf[0..4]); | 59 | info!("Contents after erase starts with {=[u8]}", read_buf[0..4]); |
| 60 | if read_buf.iter().any(|x| *x != 0xFF) { | 60 | if read_buf.iter().any(|x| *x != 0xFF) { |
| 61 | defmt::panic!("unexpected"); | 61 | defmt::panic!("unexpected"); |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | defmt::unwrap!(flash.write(ADDR_OFFSET + offset, &[0x01])); | 64 | defmt::unwrap!(flash.blocking_write(ADDR_OFFSET + offset, &[0x01])); |
| 65 | defmt::unwrap!(flash.write(ADDR_OFFSET + offset + 1, &[0x02])); | 65 | defmt::unwrap!(flash.blocking_write(ADDR_OFFSET + offset + 1, &[0x02])); |
| 66 | defmt::unwrap!(flash.write(ADDR_OFFSET + offset + 2, &[0x03])); | 66 | defmt::unwrap!(flash.blocking_write(ADDR_OFFSET + offset + 2, &[0x03])); |
| 67 | defmt::unwrap!(flash.write(ADDR_OFFSET + offset + 3, &[0x04])); | 67 | defmt::unwrap!(flash.blocking_write(ADDR_OFFSET + offset + 3, &[0x04])); |
| 68 | 68 | ||
| 69 | defmt::unwrap!(flash.read(ADDR_OFFSET + offset, &mut read_buf)); | 69 | defmt::unwrap!(flash.blocking_read(ADDR_OFFSET + offset, &mut read_buf)); |
| 70 | info!("Contents after write starts with {=[u8]}", read_buf[0..4]); | 70 | info!("Contents after write starts with {=[u8]}", read_buf[0..4]); |
| 71 | if &read_buf[0..4] != &[0x01, 0x02, 0x03, 0x04] { | 71 | if &read_buf[0..4] != &[0x01, 0x02, 0x03, 0x04] { |
| 72 | defmt::panic!("unexpected"); | 72 | defmt::panic!("unexpected"); |
| @@ -76,14 +76,14 @@ fn multiwrite_bytes(flash: &mut embassy_rp::flash::Flash<'_, FLASH, Async, FLASH | |||
| 76 | fn erase_write_sector(flash: &mut embassy_rp::flash::Flash<'_, FLASH, Async, FLASH_SIZE>, offset: u32) { | 76 | fn erase_write_sector(flash: &mut embassy_rp::flash::Flash<'_, FLASH, Async, FLASH_SIZE>, offset: u32) { |
| 77 | info!(">>>> [erase_write_sector]"); | 77 | info!(">>>> [erase_write_sector]"); |
| 78 | let mut buf = [0u8; ERASE_SIZE]; | 78 | let mut buf = [0u8; ERASE_SIZE]; |
| 79 | defmt::unwrap!(flash.read(ADDR_OFFSET + offset, &mut buf)); | 79 | defmt::unwrap!(flash.blocking_read(ADDR_OFFSET + offset, &mut buf)); |
| 80 | 80 | ||
| 81 | info!("Addr of flash block is {:x}", ADDR_OFFSET + offset + FLASH_BASE as u32); | 81 | info!("Addr of flash block is {:x}", ADDR_OFFSET + offset + FLASH_BASE as u32); |
| 82 | info!("Contents start with {=[u8]}", buf[0..4]); | 82 | info!("Contents start with {=[u8]}", buf[0..4]); |
| 83 | 83 | ||
| 84 | defmt::unwrap!(flash.erase(ADDR_OFFSET + offset, ADDR_OFFSET + offset + ERASE_SIZE as u32)); | 84 | defmt::unwrap!(flash.blocking_erase(ADDR_OFFSET + offset, ADDR_OFFSET + offset + ERASE_SIZE as u32)); |
| 85 | 85 | ||
| 86 | defmt::unwrap!(flash.read(ADDR_OFFSET + offset, &mut buf)); | 86 | defmt::unwrap!(flash.blocking_read(ADDR_OFFSET + offset, &mut buf)); |
| 87 | info!("Contents after erase starts with {=[u8]}", buf[0..4]); | 87 | info!("Contents after erase starts with {=[u8]}", buf[0..4]); |
| 88 | if buf.iter().any(|x| *x != 0xFF) { | 88 | if buf.iter().any(|x| *x != 0xFF) { |
| 89 | defmt::panic!("unexpected"); | 89 | defmt::panic!("unexpected"); |
| @@ -93,9 +93,9 @@ fn erase_write_sector(flash: &mut embassy_rp::flash::Flash<'_, FLASH, Async, FLA | |||
| 93 | *b = 0xDA; | 93 | *b = 0xDA; |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | defmt::unwrap!(flash.write(ADDR_OFFSET + offset, &buf)); | 96 | defmt::unwrap!(flash.blocking_write(ADDR_OFFSET + offset, &buf)); |
| 97 | 97 | ||
| 98 | defmt::unwrap!(flash.read(ADDR_OFFSET + offset, &mut buf)); | 98 | defmt::unwrap!(flash.blocking_read(ADDR_OFFSET + offset, &mut buf)); |
| 99 | info!("Contents after write starts with {=[u8]}", buf[0..4]); | 99 | info!("Contents after write starts with {=[u8]}", buf[0..4]); |
| 100 | if buf.iter().any(|x| *x != 0xDA) { | 100 | if buf.iter().any(|x| *x != 0xDA) { |
| 101 | defmt::panic!("unexpected"); | 101 | defmt::panic!("unexpected"); |
| @@ -111,7 +111,7 @@ async fn background_read(flash: &mut embassy_rp::flash::Flash<'_, FLASH, Async, | |||
| 111 | info!("Addr of flash block is {:x}", ADDR_OFFSET + offset + FLASH_BASE as u32); | 111 | info!("Addr of flash block is {:x}", ADDR_OFFSET + offset + FLASH_BASE as u32); |
| 112 | info!("Contents start with {=u32:x}", buf[0]); | 112 | info!("Contents start with {=u32:x}", buf[0]); |
| 113 | 113 | ||
| 114 | defmt::unwrap!(flash.erase(ADDR_OFFSET + offset, ADDR_OFFSET + offset + ERASE_SIZE as u32)); | 114 | defmt::unwrap!(flash.blocking_erase(ADDR_OFFSET + offset, ADDR_OFFSET + offset + ERASE_SIZE as u32)); |
| 115 | 115 | ||
| 116 | defmt::unwrap!(flash.background_read(ADDR_OFFSET + offset, &mut buf)).await; | 116 | defmt::unwrap!(flash.background_read(ADDR_OFFSET + offset, &mut buf)).await; |
| 117 | info!("Contents after erase starts with {=u32:x}", buf[0]); | 117 | info!("Contents after erase starts with {=u32:x}", buf[0]); |
| @@ -123,7 +123,7 @@ async fn background_read(flash: &mut embassy_rp::flash::Flash<'_, FLASH, Async, | |||
| 123 | *b = 0xDABA1234; | 123 | *b = 0xDABA1234; |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | defmt::unwrap!(flash.write(ADDR_OFFSET + offset, unsafe { | 126 | defmt::unwrap!(flash.blocking_write(ADDR_OFFSET + offset, unsafe { |
| 127 | core::slice::from_raw_parts(buf.as_ptr() as *const u8, buf.len() * 4) | 127 | core::slice::from_raw_parts(buf.as_ptr() as *const u8, buf.len() * 4) |
| 128 | })); | 128 | })); |
| 129 | 129 | ||
