diff options
| author | Rasmus Melchior Jacobsen <[email protected]> | 2023-05-25 21:40:54 +0200 |
|---|---|---|
| committer | Rasmus Melchior Jacobsen <[email protected]> | 2023-05-25 21:40:54 +0200 |
| commit | 860b519f9993bd8991849c680aae058558aadfbd (patch) | |
| tree | a0f815620d3be788cb69f0c97c6e42480ee24bae | |
| parent | 18d14dff48d1fd49cfd43fb94304bf932a74a6ca (diff) | |
Let Flash<Async/Blocking> be a thing
| -rw-r--r-- | embassy-stm32/src/flash/asynch.rs | 13 | ||||
| -rw-r--r-- | embassy-stm32/src/flash/common.rs | 37 | ||||
| -rw-r--r-- | embassy-stm32/src/flash/f4.rs | 22 | ||||
| -rw-r--r-- | examples/boot/application/rp/src/bin/a.rs | 2 | ||||
| -rw-r--r-- | examples/boot/application/stm32f3/src/bin/a.rs | 2 | ||||
| -rw-r--r-- | examples/boot/application/stm32f7/src/bin/a.rs | 2 | ||||
| -rw-r--r-- | examples/boot/application/stm32h7/src/bin/a.rs | 2 | ||||
| -rw-r--r-- | examples/boot/application/stm32l0/src/bin/a.rs | 2 | ||||
| -rw-r--r-- | examples/boot/application/stm32l1/src/bin/a.rs | 2 | ||||
| -rw-r--r-- | examples/boot/application/stm32l4/src/bin/a.rs | 2 | ||||
| -rw-r--r-- | examples/boot/application/stm32wl/src/bin/a.rs | 2 | ||||
| -rw-r--r-- | examples/boot/bootloader/stm32/src/main.rs | 2 | ||||
| -rw-r--r-- | examples/stm32f3/src/bin/flash.rs | 2 | ||||
| -rw-r--r-- | examples/stm32f4/src/bin/flash.rs | 2 | ||||
| -rw-r--r-- | examples/stm32f7/src/bin/flash.rs | 4 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/flash.rs | 2 | ||||
| -rw-r--r-- | examples/stm32l0/src/bin/flash.rs | 2 | ||||
| -rw-r--r-- | examples/stm32l1/src/bin/flash.rs | 2 | ||||
| -rw-r--r-- | examples/stm32wl/src/bin/flash.rs | 2 |
19 files changed, 63 insertions, 43 deletions
diff --git a/embassy-stm32/src/flash/asynch.rs b/embassy-stm32/src/flash/asynch.rs index 017fb17fa..74c54ff33 100644 --- a/embassy-stm32/src/flash/asynch.rs +++ b/embassy-stm32/src/flash/asynch.rs | |||
| @@ -10,25 +10,22 @@ use super::{ | |||
| 10 | 10 | ||
| 11 | pub(super) static REGION_ACCESS: Mutex<CriticalSectionRawMutex, ()> = Mutex::new(()); | 11 | pub(super) static REGION_ACCESS: Mutex<CriticalSectionRawMutex, ()> = Mutex::new(()); |
| 12 | 12 | ||
| 13 | impl<'d> Flash<'d> { | 13 | impl<'d> Flash<'d, Async> { |
| 14 | pub fn into_regions(self) -> FlashLayout<'d, Async> { | 14 | pub fn into_regions(self) -> FlashLayout<'d, Async> { |
| 15 | assert!(!self.blocking_only); | ||
| 16 | family::set_default_layout(); | 15 | family::set_default_layout(); |
| 17 | FlashLayout::new(self.inner) | 16 | FlashLayout::new(self.inner) |
| 18 | } | 17 | } |
| 19 | 18 | ||
| 20 | pub async fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Error> { | 19 | pub async fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Error> { |
| 21 | assert!(!self.blocking_only); | ||
| 22 | unsafe { write_chunked(FLASH_BASE as u32, FLASH_SIZE as u32, offset, bytes).await } | 20 | unsafe { write_chunked(FLASH_BASE as u32, FLASH_SIZE as u32, offset, bytes).await } |
| 23 | } | 21 | } |
| 24 | 22 | ||
| 25 | pub async fn erase(&mut self, from: u32, to: u32) -> Result<(), Error> { | 23 | pub async fn erase(&mut self, from: u32, to: u32) -> Result<(), Error> { |
| 26 | assert!(!self.blocking_only); | ||
| 27 | unsafe { erase_sectored(FLASH_BASE as u32, from, to).await } | 24 | unsafe { erase_sectored(FLASH_BASE as u32, from, to).await } |
| 28 | } | 25 | } |
| 29 | } | 26 | } |
| 30 | 27 | ||
| 31 | impl embedded_storage_async::nor_flash::ReadNorFlash for Flash<'_> { | 28 | impl embedded_storage_async::nor_flash::ReadNorFlash for Flash<'_, Async> { |
| 32 | const READ_SIZE: usize = READ_SIZE; | 29 | const READ_SIZE: usize = READ_SIZE; |
| 33 | 30 | ||
| 34 | async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> { | 31 | async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> { |
| @@ -40,7 +37,7 @@ impl embedded_storage_async::nor_flash::ReadNorFlash for Flash<'_> { | |||
| 40 | } | 37 | } |
| 41 | } | 38 | } |
| 42 | 39 | ||
| 43 | impl embedded_storage_async::nor_flash::NorFlash for Flash<'_> { | 40 | impl embedded_storage_async::nor_flash::NorFlash for Flash<'_, Async> { |
| 44 | const WRITE_SIZE: usize = WRITE_SIZE; | 41 | const WRITE_SIZE: usize = WRITE_SIZE; |
| 45 | const ERASE_SIZE: usize = MAX_ERASE_SIZE; | 42 | const ERASE_SIZE: usize = MAX_ERASE_SIZE; |
| 46 | 43 | ||
| @@ -114,7 +111,7 @@ pub(super) async unsafe fn erase_sectored(base: u32, from: u32, to: u32) -> Resu | |||
| 114 | foreach_flash_region! { | 111 | foreach_flash_region! { |
| 115 | ($type_name:ident, $write_size:literal, $erase_size:literal) => { | 112 | ($type_name:ident, $write_size:literal, $erase_size:literal) => { |
| 116 | impl crate::_generated::flash_regions::$type_name<'_, Async> { | 113 | impl crate::_generated::flash_regions::$type_name<'_, Async> { |
| 117 | pub fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Error> { | 114 | pub async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Error> { |
| 118 | read_blocking(self.0.base, self.0.size, offset, bytes) | 115 | read_blocking(self.0.base, self.0.size, offset, bytes) |
| 119 | } | 116 | } |
| 120 | 117 | ||
| @@ -133,7 +130,7 @@ foreach_flash_region! { | |||
| 133 | const READ_SIZE: usize = READ_SIZE; | 130 | const READ_SIZE: usize = READ_SIZE; |
| 134 | 131 | ||
| 135 | async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> { | 132 | async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> { |
| 136 | self.read(offset, bytes) | 133 | self.read(offset, bytes).await |
| 137 | } | 134 | } |
| 138 | 135 | ||
| 139 | fn capacity(&self) -> usize { | 136 | fn capacity(&self) -> usize { |
diff --git a/embassy-stm32/src/flash/common.rs b/embassy-stm32/src/flash/common.rs index 3eb4a0f18..8ae72ebcb 100644 --- a/embassy-stm32/src/flash/common.rs +++ b/embassy-stm32/src/flash/common.rs | |||
| @@ -1,3 +1,5 @@ | |||
| 1 | use core::marker::PhantomData; | ||
| 2 | |||
| 1 | use atomic_polyfill::{fence, Ordering}; | 3 | use atomic_polyfill::{fence, Ordering}; |
| 2 | use embassy_cortex_m::interrupt::{Interrupt, InterruptExt}; | 4 | use embassy_cortex_m::interrupt::{Interrupt, InterruptExt}; |
| 3 | use embassy_hal_common::drop::OnDrop; | 5 | use embassy_hal_common::drop::OnDrop; |
| @@ -5,19 +7,18 @@ use embassy_hal_common::{into_ref, PeripheralRef}; | |||
| 5 | use stm32_metapac::FLASH_BASE; | 7 | use stm32_metapac::FLASH_BASE; |
| 6 | 8 | ||
| 7 | use super::{ | 9 | use super::{ |
| 8 | family, Blocking, Error, FlashBank, FlashLayout, FlashRegion, FlashSector, FLASH_SIZE, MAX_ERASE_SIZE, READ_SIZE, | 10 | family, Async, Blocking, Error, FlashBank, FlashLayout, FlashRegion, FlashSector, FLASH_SIZE, MAX_ERASE_SIZE, |
| 9 | WRITE_SIZE, | 11 | READ_SIZE, WRITE_SIZE, |
| 10 | }; | 12 | }; |
| 11 | use crate::peripherals::FLASH; | 13 | use crate::peripherals::FLASH; |
| 12 | use crate::{interrupt, Peripheral}; | 14 | use crate::{interrupt, Peripheral}; |
| 13 | 15 | ||
| 14 | pub struct Flash<'d> { | 16 | pub struct Flash<'d, MODE = Async> { |
| 15 | pub(crate) inner: PeripheralRef<'d, FLASH>, | 17 | pub(crate) inner: PeripheralRef<'d, FLASH>, |
| 16 | #[cfg(all(feature = "nightly", flash_f4))] | 18 | _mode: PhantomData<MODE>, |
| 17 | pub(crate) blocking_only: bool, | ||
| 18 | } | 19 | } |
| 19 | 20 | ||
| 20 | impl<'d> Flash<'d> { | 21 | impl<'d> Flash<'d, Async> { |
| 21 | pub fn new( | 22 | pub fn new( |
| 22 | p: impl Peripheral<P = FLASH> + 'd, | 23 | p: impl Peripheral<P = FLASH> + 'd, |
| 23 | _irq: impl interrupt::Binding<crate::interrupt::FLASH, InterruptHandler> + 'd, | 24 | _irq: impl interrupt::Binding<crate::interrupt::FLASH, InterruptHandler> + 'd, |
| @@ -30,21 +31,23 @@ impl<'d> Flash<'d> { | |||
| 30 | 31 | ||
| 31 | Self { | 32 | Self { |
| 32 | inner: p, | 33 | inner: p, |
| 33 | #[cfg(all(feature = "nightly", flash_f4))] | 34 | _mode: PhantomData, |
| 34 | blocking_only: false, | ||
| 35 | } | 35 | } |
| 36 | } | 36 | } |
| 37 | } | ||
| 37 | 38 | ||
| 38 | pub fn new_blocking_only(p: impl Peripheral<P = FLASH> + 'd) -> Self { | 39 | impl<'d> Flash<'d, Blocking> { |
| 40 | pub fn new_blocking(p: impl Peripheral<P = FLASH> + 'd) -> Self { | ||
| 39 | into_ref!(p); | 41 | into_ref!(p); |
| 40 | 42 | ||
| 41 | Self { | 43 | Self { |
| 42 | inner: p, | 44 | inner: p, |
| 43 | #[cfg(all(feature = "nightly", flash_f4))] | 45 | _mode: PhantomData, |
| 44 | blocking_only: true, | ||
| 45 | } | 46 | } |
| 46 | } | 47 | } |
| 48 | } | ||
| 47 | 49 | ||
| 50 | impl<'d, MODE> Flash<'d, MODE> { | ||
| 48 | pub fn into_blocking_regions(self) -> FlashLayout<'d, Blocking> { | 51 | pub fn into_blocking_regions(self) -> FlashLayout<'d, Blocking> { |
| 49 | family::set_default_layout(); | 52 | family::set_default_layout(); |
| 50 | FlashLayout::new(self.inner) | 53 | FlashLayout::new(self.inner) |
| @@ -222,11 +225,11 @@ pub(super) fn ensure_sector_aligned( | |||
| 222 | Ok(()) | 225 | Ok(()) |
| 223 | } | 226 | } |
| 224 | 227 | ||
| 225 | impl embedded_storage::nor_flash::ErrorType for Flash<'_> { | 228 | impl<MODE> embedded_storage::nor_flash::ErrorType for Flash<'_, MODE> { |
| 226 | type Error = Error; | 229 | type Error = Error; |
| 227 | } | 230 | } |
| 228 | 231 | ||
| 229 | impl embedded_storage::nor_flash::ReadNorFlash for Flash<'_> { | 232 | impl<MODE> embedded_storage::nor_flash::ReadNorFlash for Flash<'_, MODE> { |
| 230 | const READ_SIZE: usize = READ_SIZE; | 233 | const READ_SIZE: usize = READ_SIZE; |
| 231 | 234 | ||
| 232 | fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> { | 235 | fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> { |
| @@ -238,7 +241,7 @@ impl embedded_storage::nor_flash::ReadNorFlash for Flash<'_> { | |||
| 238 | } | 241 | } |
| 239 | } | 242 | } |
| 240 | 243 | ||
| 241 | impl embedded_storage::nor_flash::NorFlash for Flash<'_> { | 244 | impl<MODE> embedded_storage::nor_flash::NorFlash for Flash<'_, MODE> { |
| 242 | const WRITE_SIZE: usize = WRITE_SIZE; | 245 | const WRITE_SIZE: usize = WRITE_SIZE; |
| 243 | const ERASE_SIZE: usize = MAX_ERASE_SIZE; | 246 | const ERASE_SIZE: usize = MAX_ERASE_SIZE; |
| 244 | 247 | ||
| @@ -253,11 +256,13 @@ impl embedded_storage::nor_flash::NorFlash for Flash<'_> { | |||
| 253 | 256 | ||
| 254 | foreach_flash_region! { | 257 | foreach_flash_region! { |
| 255 | ($type_name:ident, $write_size:literal, $erase_size:literal) => { | 258 | ($type_name:ident, $write_size:literal, $erase_size:literal) => { |
| 256 | impl<'d> crate::_generated::flash_regions::$type_name<'d, Blocking> { | 259 | impl<MODE> crate::_generated::flash_regions::$type_name<'_, MODE> { |
| 257 | pub fn read_blocking(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Error> { | 260 | pub fn read_blocking(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Error> { |
| 258 | read_blocking(self.0.base, self.0.size, offset, bytes) | 261 | read_blocking(self.0.base, self.0.size, offset, bytes) |
| 259 | } | 262 | } |
| 263 | } | ||
| 260 | 264 | ||
| 265 | impl crate::_generated::flash_regions::$type_name<'_, Blocking> { | ||
| 261 | pub fn write_blocking(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Error> { | 266 | pub fn write_blocking(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Error> { |
| 262 | unsafe { write_blocking(self.0.base, self.0.size, offset, bytes, write_chunk_with_critical_section) } | 267 | unsafe { write_blocking(self.0.base, self.0.size, offset, bytes, write_chunk_with_critical_section) } |
| 263 | } | 268 | } |
| @@ -271,7 +276,7 @@ foreach_flash_region! { | |||
| 271 | type Error = Error; | 276 | type Error = Error; |
| 272 | } | 277 | } |
| 273 | 278 | ||
| 274 | impl embedded_storage::nor_flash::ReadNorFlash for crate::_generated::flash_regions::$type_name<'_, Blocking> { | 279 | impl<MODE> embedded_storage::nor_flash::ReadNorFlash for crate::_generated::flash_regions::$type_name<'_, MODE> { |
| 275 | const READ_SIZE: usize = READ_SIZE; | 280 | const READ_SIZE: usize = READ_SIZE; |
| 276 | 281 | ||
| 277 | fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> { | 282 | fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> { |
diff --git a/embassy-stm32/src/flash/f4.rs b/embassy-stm32/src/flash/f4.rs index d67e6d0a1..875bb912b 100644 --- a/embassy-stm32/src/flash/f4.rs +++ b/embassy-stm32/src/flash/f4.rs | |||
| @@ -107,10 +107,16 @@ mod alt_regions { | |||
| 107 | 107 | ||
| 108 | macro_rules! foreach_altflash_region { | 108 | macro_rules! foreach_altflash_region { |
| 109 | ($type_name:ident, $region:ident) => { | 109 | ($type_name:ident, $region:ident) => { |
| 110 | impl<MODE> $type_name<'_, MODE> { | ||
| 111 | pub fn read_blocking(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Error> { | ||
| 112 | crate::flash::common::read_blocking(self.0.base, self.0.size, offset, bytes) | ||
| 113 | } | ||
| 114 | } | ||
| 115 | |||
| 110 | #[cfg(feature = "nightly")] | 116 | #[cfg(feature = "nightly")] |
| 111 | impl $type_name<'_, Async> { | 117 | impl $type_name<'_, Async> { |
| 112 | pub async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Error> { | 118 | pub async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Error> { |
| 113 | crate::flash::common::read_blocking(self.0.base, self.0.size, offset, bytes) | 119 | self.read_blocking(offset, bytes) |
| 114 | } | 120 | } |
| 115 | 121 | ||
| 116 | pub async fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Error> { | 122 | pub async fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Error> { |
| @@ -124,10 +130,22 @@ mod alt_regions { | |||
| 124 | } | 130 | } |
| 125 | } | 131 | } |
| 126 | 132 | ||
| 127 | impl embedded_storage::nor_flash::ErrorType for $type_name<'_, Async> { | 133 | impl<MODE> embedded_storage::nor_flash::ErrorType for $type_name<'_, MODE> { |
| 128 | type Error = Error; | 134 | type Error = Error; |
| 129 | } | 135 | } |
| 130 | 136 | ||
| 137 | impl<MODE> embedded_storage::nor_flash::ReadNorFlash for $type_name<'_, MODE> { | ||
| 138 | const READ_SIZE: usize = crate::flash::READ_SIZE; | ||
| 139 | |||
| 140 | fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> { | ||
| 141 | self.read_blocking(offset, bytes) | ||
| 142 | } | ||
| 143 | |||
| 144 | fn capacity(&self) -> usize { | ||
| 145 | self.0.size as usize | ||
| 146 | } | ||
| 147 | } | ||
| 148 | |||
| 131 | #[cfg(feature = "nightly")] | 149 | #[cfg(feature = "nightly")] |
| 132 | impl embedded_storage_async::nor_flash::ReadNorFlash for $type_name<'_, Async> { | 150 | impl embedded_storage_async::nor_flash::ReadNorFlash for $type_name<'_, Async> { |
| 133 | const READ_SIZE: usize = crate::flash::READ_SIZE; | 151 | const READ_SIZE: usize = crate::flash::READ_SIZE; |
diff --git a/examples/boot/application/rp/src/bin/a.rs b/examples/boot/application/rp/src/bin/a.rs index 2b84ec614..47f1d16d8 100644 --- a/examples/boot/application/rp/src/bin/a.rs +++ b/examples/boot/application/rp/src/bin/a.rs | |||
| @@ -26,7 +26,7 @@ async fn main(_s: Spawner) { | |||
| 26 | let mut watchdog = Watchdog::new(p.WATCHDOG); | 26 | let mut watchdog = Watchdog::new(p.WATCHDOG); |
| 27 | watchdog.start(Duration::from_secs(8)); | 27 | watchdog.start(Duration::from_secs(8)); |
| 28 | 28 | ||
| 29 | let mut flash: Flash<_, FLASH_SIZE> = Flash::new_blocking_only(p.FLASH); | 29 | let mut flash: Flash<_, FLASH_SIZE> = Flash::new_blocking(p.FLASH); |
| 30 | 30 | ||
| 31 | let mut updater = FirmwareUpdater::default(); | 31 | let mut updater = FirmwareUpdater::default(); |
| 32 | 32 | ||
diff --git a/examples/boot/application/stm32f3/src/bin/a.rs b/examples/boot/application/stm32f3/src/bin/a.rs index a69b6327f..5db1dbb57 100644 --- a/examples/boot/application/stm32f3/src/bin/a.rs +++ b/examples/boot/application/stm32f3/src/bin/a.rs | |||
| @@ -17,7 +17,7 @@ static APP_B: &[u8] = include_bytes!("../../b.bin"); | |||
| 17 | #[embassy_executor::main] | 17 | #[embassy_executor::main] |
| 18 | async fn main(_spawner: Spawner) { | 18 | async fn main(_spawner: Spawner) { |
| 19 | let p = embassy_stm32::init(Default::default()); | 19 | let p = embassy_stm32::init(Default::default()); |
| 20 | let flash = Flash::new_blocking_only(p.FLASH); | 20 | let flash = Flash::new_blocking(p.FLASH); |
| 21 | let mut flash = BlockingAsync::new(flash); | 21 | let mut flash = BlockingAsync::new(flash); |
| 22 | 22 | ||
| 23 | let button = Input::new(p.PC13, Pull::Up); | 23 | let button = Input::new(p.PC13, Pull::Up); |
diff --git a/examples/boot/application/stm32f7/src/bin/a.rs b/examples/boot/application/stm32f7/src/bin/a.rs index 1f55db932..5d586445c 100644 --- a/examples/boot/application/stm32f7/src/bin/a.rs +++ b/examples/boot/application/stm32f7/src/bin/a.rs | |||
| @@ -16,7 +16,7 @@ static APP_B: &[u8] = include_bytes!("../../b.bin"); | |||
| 16 | #[embassy_executor::main] | 16 | #[embassy_executor::main] |
| 17 | async fn main(_spawner: Spawner) { | 17 | async fn main(_spawner: Spawner) { |
| 18 | let p = embassy_stm32::init(Default::default()); | 18 | let p = embassy_stm32::init(Default::default()); |
| 19 | let mut flash = Flash::new_blocking_only(p.FLASH); | 19 | let mut flash = Flash::new_blocking(p.FLASH); |
| 20 | 20 | ||
| 21 | let button = Input::new(p.PC13, Pull::Down); | 21 | let button = Input::new(p.PC13, Pull::Down); |
| 22 | let mut button = ExtiInput::new(button, p.EXTI13); | 22 | let mut button = ExtiInput::new(button, p.EXTI13); |
diff --git a/examples/boot/application/stm32h7/src/bin/a.rs b/examples/boot/application/stm32h7/src/bin/a.rs index b8617c3bd..202220223 100644 --- a/examples/boot/application/stm32h7/src/bin/a.rs +++ b/examples/boot/application/stm32h7/src/bin/a.rs | |||
| @@ -16,7 +16,7 @@ static APP_B: &[u8] = include_bytes!("../../b.bin"); | |||
| 16 | #[embassy_executor::main] | 16 | #[embassy_executor::main] |
| 17 | async fn main(_spawner: Spawner) { | 17 | async fn main(_spawner: Spawner) { |
| 18 | let p = embassy_stm32::init(Default::default()); | 18 | let p = embassy_stm32::init(Default::default()); |
| 19 | let mut flash = Flash::new_blocking_only(p.FLASH); | 19 | let mut flash = Flash::new_blocking(p.FLASH); |
| 20 | 20 | ||
| 21 | let button = Input::new(p.PC13, Pull::Down); | 21 | let button = Input::new(p.PC13, Pull::Down); |
| 22 | let mut button = ExtiInput::new(button, p.EXTI13); | 22 | let mut button = ExtiInput::new(button, p.EXTI13); |
diff --git a/examples/boot/application/stm32l0/src/bin/a.rs b/examples/boot/application/stm32l0/src/bin/a.rs index c66635639..4033ac590 100644 --- a/examples/boot/application/stm32l0/src/bin/a.rs +++ b/examples/boot/application/stm32l0/src/bin/a.rs | |||
| @@ -18,7 +18,7 @@ static APP_B: &[u8] = include_bytes!("../../b.bin"); | |||
| 18 | #[embassy_executor::main] | 18 | #[embassy_executor::main] |
| 19 | async fn main(_spawner: Spawner) { | 19 | async fn main(_spawner: Spawner) { |
| 20 | let p = embassy_stm32::init(Default::default()); | 20 | let p = embassy_stm32::init(Default::default()); |
| 21 | let flash = Flash::new_blocking_only(p.FLASH); | 21 | let flash = Flash::new_blocking(p.FLASH); |
| 22 | let mut flash = BlockingAsync::new(flash); | 22 | let mut flash = BlockingAsync::new(flash); |
| 23 | 23 | ||
| 24 | let button = Input::new(p.PB2, Pull::Up); | 24 | let button = Input::new(p.PB2, Pull::Up); |
diff --git a/examples/boot/application/stm32l1/src/bin/a.rs b/examples/boot/application/stm32l1/src/bin/a.rs index c66635639..4033ac590 100644 --- a/examples/boot/application/stm32l1/src/bin/a.rs +++ b/examples/boot/application/stm32l1/src/bin/a.rs | |||
| @@ -18,7 +18,7 @@ static APP_B: &[u8] = include_bytes!("../../b.bin"); | |||
| 18 | #[embassy_executor::main] | 18 | #[embassy_executor::main] |
| 19 | async fn main(_spawner: Spawner) { | 19 | async fn main(_spawner: Spawner) { |
| 20 | let p = embassy_stm32::init(Default::default()); | 20 | let p = embassy_stm32::init(Default::default()); |
| 21 | let flash = Flash::new_blocking_only(p.FLASH); | 21 | let flash = Flash::new_blocking(p.FLASH); |
| 22 | let mut flash = BlockingAsync::new(flash); | 22 | let mut flash = BlockingAsync::new(flash); |
| 23 | 23 | ||
| 24 | let button = Input::new(p.PB2, Pull::Up); | 24 | let button = Input::new(p.PB2, Pull::Up); |
diff --git a/examples/boot/application/stm32l4/src/bin/a.rs b/examples/boot/application/stm32l4/src/bin/a.rs index 86936222c..141d82afd 100644 --- a/examples/boot/application/stm32l4/src/bin/a.rs +++ b/examples/boot/application/stm32l4/src/bin/a.rs | |||
| @@ -17,7 +17,7 @@ static APP_B: &[u8] = include_bytes!("../../b.bin"); | |||
| 17 | #[embassy_executor::main] | 17 | #[embassy_executor::main] |
| 18 | async fn main(_spawner: Spawner) { | 18 | async fn main(_spawner: Spawner) { |
| 19 | let p = embassy_stm32::init(Default::default()); | 19 | let p = embassy_stm32::init(Default::default()); |
| 20 | let flash = Flash::new_blocking_only(p.FLASH); | 20 | let flash = Flash::new_blocking(p.FLASH); |
| 21 | let mut flash = BlockingAsync::new(flash); | 21 | let mut flash = BlockingAsync::new(flash); |
| 22 | 22 | ||
| 23 | let button = Input::new(p.PC13, Pull::Up); | 23 | let button = Input::new(p.PC13, Pull::Up); |
diff --git a/examples/boot/application/stm32wl/src/bin/a.rs b/examples/boot/application/stm32wl/src/bin/a.rs index 2982e8df1..5f48dbe51 100644 --- a/examples/boot/application/stm32wl/src/bin/a.rs +++ b/examples/boot/application/stm32wl/src/bin/a.rs | |||
| @@ -17,7 +17,7 @@ static APP_B: &[u8] = include_bytes!("../../b.bin"); | |||
| 17 | #[embassy_executor::main] | 17 | #[embassy_executor::main] |
| 18 | async fn main(_spawner: Spawner) { | 18 | async fn main(_spawner: Spawner) { |
| 19 | let p = embassy_stm32::init(Default::default()); | 19 | let p = embassy_stm32::init(Default::default()); |
| 20 | let flash = Flash::new_blocking_only(p.FLASH); | 20 | let flash = Flash::new_blocking(p.FLASH); |
| 21 | let mut flash = BlockingAsync::new(flash); | 21 | let mut flash = BlockingAsync::new(flash); |
| 22 | 22 | ||
| 23 | let button = Input::new(p.PA0, Pull::Up); | 23 | let button = Input::new(p.PA0, Pull::Up); |
diff --git a/examples/boot/bootloader/stm32/src/main.rs b/examples/boot/bootloader/stm32/src/main.rs index 5e8a4f2b3..f81fdbc5f 100644 --- a/examples/boot/bootloader/stm32/src/main.rs +++ b/examples/boot/bootloader/stm32/src/main.rs | |||
| @@ -20,7 +20,7 @@ fn main() -> ! { | |||
| 20 | */ | 20 | */ |
| 21 | 21 | ||
| 22 | let mut bl: BootLoader<2048> = BootLoader::default(); | 22 | let mut bl: BootLoader<2048> = BootLoader::default(); |
| 23 | let layout = Flash::new_blocking_only(p.FLASH).into_blocking_regions(); | 23 | let layout = Flash::new_blocking(p.FLASH).into_blocking_regions(); |
| 24 | let mut flash = BootFlash::new(layout.bank1_region); | 24 | let mut flash = BootFlash::new(layout.bank1_region); |
| 25 | let start = bl.prepare(&mut SingleFlashConfig::new(&mut flash)); | 25 | let start = bl.prepare(&mut SingleFlashConfig::new(&mut flash)); |
| 26 | core::mem::drop(flash); | 26 | core::mem::drop(flash); |
diff --git a/examples/stm32f3/src/bin/flash.rs b/examples/stm32f3/src/bin/flash.rs index 9a31b548d..2432a29d2 100644 --- a/examples/stm32f3/src/bin/flash.rs +++ b/examples/stm32f3/src/bin/flash.rs | |||
| @@ -14,7 +14,7 @@ async fn main(_spawner: Spawner) { | |||
| 14 | 14 | ||
| 15 | const ADDR: u32 = 0x26000; | 15 | const ADDR: u32 = 0x26000; |
| 16 | 16 | ||
| 17 | let mut f = Flash::new_blocking_only(p.FLASH).into_blocking_regions().bank1_region; | 17 | let mut f = Flash::new_blocking(p.FLASH).into_blocking_regions().bank1_region; |
| 18 | 18 | ||
| 19 | info!("Reading..."); | 19 | info!("Reading..."); |
| 20 | let mut buf = [0u8; 8]; | 20 | let mut buf = [0u8; 8]; |
diff --git a/examples/stm32f4/src/bin/flash.rs b/examples/stm32f4/src/bin/flash.rs index 455af930b..cadb0129d 100644 --- a/examples/stm32f4/src/bin/flash.rs +++ b/examples/stm32f4/src/bin/flash.rs | |||
| @@ -14,7 +14,7 @@ async fn main(_spawner: Spawner) { | |||
| 14 | 14 | ||
| 15 | // Once can also call `into_regions()` to get access to NorFlash implementations | 15 | // Once can also call `into_regions()` to get access to NorFlash implementations |
| 16 | // for each of the unique characteristics. | 16 | // for each of the unique characteristics. |
| 17 | let mut f = Flash::new_blocking_only(p.FLASH); | 17 | let mut f = Flash::new_blocking(p.FLASH); |
| 18 | 18 | ||
| 19 | // Sector 5 | 19 | // Sector 5 |
| 20 | test_flash(&mut f, 128 * 1024, 128 * 1024); | 20 | test_flash(&mut f, 128 * 1024, 128 * 1024); |
diff --git a/examples/stm32f7/src/bin/flash.rs b/examples/stm32f7/src/bin/flash.rs index 5507e7310..f3b667555 100644 --- a/examples/stm32f7/src/bin/flash.rs +++ b/examples/stm32f7/src/bin/flash.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | use defmt::{info, unwrap}; | 5 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::{flash::Flash, interrupt}; | 7 | use embassy_stm32::flash::Flash; |
| 8 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::{Duration, Timer}; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| @@ -18,7 +18,7 @@ async fn main(_spawner: Spawner) { | |||
| 18 | // wait a bit before accessing the flash | 18 | // wait a bit before accessing the flash |
| 19 | Timer::after(Duration::from_millis(300)).await; | 19 | Timer::after(Duration::from_millis(300)).await; |
| 20 | 20 | ||
| 21 | let mut f = Flash::new(p.FLASH, interrupt::take!(FLASH)).into_blocking_regions().bank1_region3; | 21 | let mut f = Flash::new_blocking(p.FLASH).into_blocking_regions().bank1_region3; |
| 22 | 22 | ||
| 23 | info!("Reading..."); | 23 | info!("Reading..."); |
| 24 | let mut buf = [0u8; 32]; | 24 | let mut buf = [0u8; 32]; |
diff --git a/examples/stm32h7/src/bin/flash.rs b/examples/stm32h7/src/bin/flash.rs index c0c332c34..982e24516 100644 --- a/examples/stm32h7/src/bin/flash.rs +++ b/examples/stm32h7/src/bin/flash.rs | |||
| @@ -18,7 +18,7 @@ async fn main(_spawner: Spawner) { | |||
| 18 | // wait a bit before accessing the flash | 18 | // wait a bit before accessing the flash |
| 19 | Timer::after(Duration::from_millis(300)).await; | 19 | Timer::after(Duration::from_millis(300)).await; |
| 20 | 20 | ||
| 21 | let mut f = Flash::new_blocking_only(p.FLASH).into_blocking_regions().bank2_region; | 21 | let mut f = Flash::new_blocking(p.FLASH).into_blocking_regions().bank2_region; |
| 22 | 22 | ||
| 23 | info!("Reading..."); | 23 | info!("Reading..."); |
| 24 | let mut buf = [0u8; 32]; | 24 | let mut buf = [0u8; 32]; |
diff --git a/examples/stm32l0/src/bin/flash.rs b/examples/stm32l0/src/bin/flash.rs index 57ccf7f57..f057421f8 100644 --- a/examples/stm32l0/src/bin/flash.rs +++ b/examples/stm32l0/src/bin/flash.rs | |||
| @@ -14,7 +14,7 @@ async fn main(_spawner: Spawner) { | |||
| 14 | 14 | ||
| 15 | const ADDR: u32 = 0x26000; | 15 | const ADDR: u32 = 0x26000; |
| 16 | 16 | ||
| 17 | let mut f = Flash::new_blocking_only(p.FLASH).into_blocking_regions().bank1_region; | 17 | let mut f = Flash::new_blocking(p.FLASH).into_blocking_regions().bank1_region; |
| 18 | 18 | ||
| 19 | info!("Reading..."); | 19 | info!("Reading..."); |
| 20 | let mut buf = [0u8; 8]; | 20 | let mut buf = [0u8; 8]; |
diff --git a/examples/stm32l1/src/bin/flash.rs b/examples/stm32l1/src/bin/flash.rs index 71174bfbc..8046f16b9 100644 --- a/examples/stm32l1/src/bin/flash.rs +++ b/examples/stm32l1/src/bin/flash.rs | |||
| @@ -14,7 +14,7 @@ async fn main(_spawner: Spawner) { | |||
| 14 | 14 | ||
| 15 | const ADDR: u32 = 0x26000; | 15 | const ADDR: u32 = 0x26000; |
| 16 | 16 | ||
| 17 | let mut f = Flash::new_blocking_only(p.FLASH).into_blocking_regions().bank1_region; | 17 | let mut f = Flash::new_blocking(p.FLASH).into_blocking_regions().bank1_region; |
| 18 | 18 | ||
| 19 | info!("Reading..."); | 19 | info!("Reading..."); |
| 20 | let mut buf = [0u8; 8]; | 20 | let mut buf = [0u8; 8]; |
diff --git a/examples/stm32wl/src/bin/flash.rs b/examples/stm32wl/src/bin/flash.rs index 51bd0db4e..81e365fbe 100644 --- a/examples/stm32wl/src/bin/flash.rs +++ b/examples/stm32wl/src/bin/flash.rs | |||
| @@ -14,7 +14,7 @@ async fn main(_spawner: Spawner) { | |||
| 14 | 14 | ||
| 15 | const ADDR: u32 = 0x36000; | 15 | const ADDR: u32 = 0x36000; |
| 16 | 16 | ||
| 17 | let mut f = Flash::new_blocking_only(p.FLASH).into_blocking_regions().bank1_region; | 17 | let mut f = Flash::new_blocking(p.FLASH).into_blocking_regions().bank1_region; |
| 18 | 18 | ||
| 19 | info!("Reading..."); | 19 | info!("Reading..."); |
| 20 | let mut buf = [0u8; 8]; | 20 | let mut buf = [0u8; 8]; |
