aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-stm32/src/flash/asynch.rs12
-rw-r--r--embassy-stm32/src/flash/f4.rs11
-rw-r--r--embassy-stm32/src/flash/mod.rs4
3 files changed, 11 insertions, 16 deletions
diff --git a/embassy-stm32/src/flash/asynch.rs b/embassy-stm32/src/flash/asynch.rs
index 6ad1e90d4..a0d994956 100644
--- a/embassy-stm32/src/flash/asynch.rs
+++ b/embassy-stm32/src/flash/asynch.rs
@@ -9,7 +9,7 @@ use embassy_sync::mutex::Mutex;
9 9
10use super::{ 10use super::{
11 blocking_read, ensure_sector_aligned, family, get_sector, Async, Error, Flash, FlashLayout, FLASH_BASE, FLASH_SIZE, 11 blocking_read, ensure_sector_aligned, family, get_sector, Async, Error, Flash, FlashLayout, FLASH_BASE, FLASH_SIZE,
12 MAX_ERASE_SIZE, READ_SIZE, WRITE_SIZE, 12 WRITE_SIZE,
13}; 13};
14use crate::peripherals::FLASH; 14use crate::peripherals::FLASH;
15use crate::{interrupt, Peripheral}; 15use crate::{interrupt, Peripheral};
@@ -56,8 +56,9 @@ impl interrupt::Handler<crate::interrupt::FLASH> for InterruptHandler {
56 } 56 }
57} 57}
58 58
59#[cfg(feature = "nightly")]
59impl embedded_storage_async::nor_flash::ReadNorFlash for Flash<'_, Async> { 60impl embedded_storage_async::nor_flash::ReadNorFlash for Flash<'_, Async> {
60 const READ_SIZE: usize = READ_SIZE; 61 const READ_SIZE: usize = super::READ_SIZE;
61 62
62 async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> { 63 async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> {
63 self.read(offset, bytes) 64 self.read(offset, bytes)
@@ -68,9 +69,10 @@ impl embedded_storage_async::nor_flash::ReadNorFlash for Flash<'_, Async> {
68 } 69 }
69} 70}
70 71
72#[cfg(feature = "nightly")]
71impl embedded_storage_async::nor_flash::NorFlash for Flash<'_, Async> { 73impl embedded_storage_async::nor_flash::NorFlash for Flash<'_, Async> {
72 const WRITE_SIZE: usize = WRITE_SIZE; 74 const WRITE_SIZE: usize = WRITE_SIZE;
73 const ERASE_SIZE: usize = MAX_ERASE_SIZE; 75 const ERASE_SIZE: usize = super::MAX_ERASE_SIZE;
74 76
75 async fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Self::Error> { 77 async fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Self::Error> {
76 self.write(offset, bytes).await 78 self.write(offset, bytes).await
@@ -157,8 +159,9 @@ foreach_flash_region! {
157 } 159 }
158 } 160 }
159 161
162 #[cfg(feature = "nightly")]
160 impl embedded_storage_async::nor_flash::ReadNorFlash for crate::_generated::flash_regions::$type_name<'_, Async> { 163 impl embedded_storage_async::nor_flash::ReadNorFlash for crate::_generated::flash_regions::$type_name<'_, Async> {
161 const READ_SIZE: usize = READ_SIZE; 164 const READ_SIZE: usize = super::READ_SIZE;
162 165
163 async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> { 166 async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> {
164 self.read(offset, bytes).await 167 self.read(offset, bytes).await
@@ -169,6 +172,7 @@ foreach_flash_region! {
169 } 172 }
170 } 173 }
171 174
175 #[cfg(feature = "nightly")]
172 impl embedded_storage_async::nor_flash::NorFlash for crate::_generated::flash_regions::$type_name<'_, Async> { 176 impl embedded_storage_async::nor_flash::NorFlash for crate::_generated::flash_regions::$type_name<'_, Async> {
173 const WRITE_SIZE: usize = $write_size; 177 const WRITE_SIZE: usize = $write_size;
174 const ERASE_SIZE: usize = $erase_size; 178 const ERASE_SIZE: usize = $erase_size;
diff --git a/embassy-stm32/src/flash/f4.rs b/embassy-stm32/src/flash/f4.rs
index 35548a558..dd7a04aa2 100644
--- a/embassy-stm32/src/flash/f4.rs
+++ b/embassy-stm32/src/flash/f4.rs
@@ -3,7 +3,6 @@ use core::ptr::write_volatile;
3use core::sync::atomic::{fence, Ordering}; 3use core::sync::atomic::{fence, Ordering};
4 4
5use atomic_polyfill::AtomicBool; 5use atomic_polyfill::AtomicBool;
6#[cfg(feature = "nightly")]
7use embassy_sync::waitqueue::AtomicWaker; 6use embassy_sync::waitqueue::AtomicWaker;
8use pac::flash::regs::Sr; 7use pac::flash::regs::Sr;
9use pac::FLASH_SIZE; 8use pac::FLASH_SIZE;
@@ -20,7 +19,7 @@ mod alt_regions {
20 use stm32_metapac::FLASH_SIZE; 19 use stm32_metapac::FLASH_SIZE;
21 20
22 use crate::_generated::flash_regions::{OTPRegion, BANK1_REGION1, BANK1_REGION2, BANK1_REGION3, OTP_REGION}; 21 use crate::_generated::flash_regions::{OTPRegion, BANK1_REGION1, BANK1_REGION2, BANK1_REGION3, OTP_REGION};
23 #[cfg(feature = "nightly")] 22
24 use crate::flash::asynch; 23 use crate::flash::asynch;
25 use crate::flash::{Async, Bank1Region1, Bank1Region2, Blocking, Error, Flash, FlashBank, FlashRegion}; 24 use crate::flash::{Async, Bank1Region1, Bank1Region2, Blocking, Error, Flash, FlashBank, FlashRegion};
26 use crate::peripherals::FLASH; 25 use crate::peripherals::FLASH;
@@ -114,7 +113,6 @@ mod alt_regions {
114 } 113 }
115 } 114 }
116 115
117 #[cfg(feature = "nightly")]
118 impl $type_name<'_, Async> { 116 impl $type_name<'_, Async> {
119 pub async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Error> { 117 pub async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Error> {
120 self.blocking_read(offset, bytes) 118 self.blocking_read(offset, bytes)
@@ -185,7 +183,6 @@ mod alt_regions {
185#[cfg(any(stm32f427, stm32f429, stm32f437, stm32f439, stm32f469, stm32f479))] 183#[cfg(any(stm32f427, stm32f429, stm32f437, stm32f439, stm32f469, stm32f479))]
186pub use alt_regions::*; 184pub use alt_regions::*;
187 185
188#[cfg(feature = "nightly")]
189static WAKER: AtomicWaker = AtomicWaker::new(); 186static WAKER: AtomicWaker = AtomicWaker::new();
190static DATA_CACHE_WAS_ENABLED: AtomicBool = AtomicBool::new(false); 187static DATA_CACHE_WAS_ENABLED: AtomicBool = AtomicBool::new(false);
191 188
@@ -236,7 +233,6 @@ pub const fn get_flash_regions() -> &'static [&'static FlashRegion] {
236 &FLASH_REGIONS 233 &FLASH_REGIONS
237} 234}
238 235
239#[cfg(feature = "nightly")]
240pub(crate) unsafe fn on_interrupt() { 236pub(crate) unsafe fn on_interrupt() {
241 // Clear IRQ flags 237 // Clear IRQ flags
242 pac::FLASH.sr().write(|w| { 238 pac::FLASH.sr().write(|w| {
@@ -256,7 +252,6 @@ pub(crate) unsafe fn unlock() {
256 pac::FLASH.keyr().write(|w| w.set_key(0xCDEF89AB)); 252 pac::FLASH.keyr().write(|w| w.set_key(0xCDEF89AB));
257} 253}
258 254
259#[cfg(feature = "nightly")]
260pub(crate) unsafe fn enable_write() { 255pub(crate) unsafe fn enable_write() {
261 assert_eq!(0, WRITE_SIZE % 4); 256 assert_eq!(0, WRITE_SIZE % 4);
262 save_data_cache_state(); 257 save_data_cache_state();
@@ -269,7 +264,6 @@ pub(crate) unsafe fn enable_write() {
269 }); 264 });
270} 265}
271 266
272#[cfg(feature = "nightly")]
273pub(crate) unsafe fn disable_write() { 267pub(crate) unsafe fn disable_write() {
274 pac::FLASH.cr().write(|w| { 268 pac::FLASH.cr().write(|w| {
275 w.set_pg(false); 269 w.set_pg(false);
@@ -294,7 +288,6 @@ pub(crate) unsafe fn disable_blocking_write() {
294 restore_data_cache_state(); 288 restore_data_cache_state();
295} 289}
296 290
297#[cfg(feature = "nightly")]
298pub(crate) async unsafe fn write(start_address: u32, buf: &[u8; WRITE_SIZE]) -> Result<(), Error> { 291pub(crate) async unsafe fn write(start_address: u32, buf: &[u8; WRITE_SIZE]) -> Result<(), Error> {
299 write_start(start_address, buf); 292 write_start(start_address, buf);
300 wait_ready().await 293 wait_ready().await
@@ -316,7 +309,6 @@ unsafe fn write_start(start_address: u32, buf: &[u8; WRITE_SIZE]) {
316 } 309 }
317} 310}
318 311
319#[cfg(feature = "nightly")]
320pub(crate) async unsafe fn erase_sector(sector: &FlashSector) -> Result<(), Error> { 312pub(crate) async unsafe fn erase_sector(sector: &FlashSector) -> Result<(), Error> {
321 save_data_cache_state(); 313 save_data_cache_state();
322 314
@@ -372,7 +364,6 @@ pub(crate) unsafe fn clear_all_err() {
372 }); 364 });
373} 365}
374 366
375#[cfg(feature = "nightly")]
376pub(crate) async unsafe fn wait_ready() -> Result<(), Error> { 367pub(crate) async unsafe fn wait_ready() -> Result<(), Error> {
377 use core::task::Poll; 368 use core::task::Poll;
378 369
diff --git a/embassy-stm32/src/flash/mod.rs b/embassy-stm32/src/flash/mod.rs
index 2cc92f518..f44ef2c16 100644
--- a/embassy-stm32/src/flash/mod.rs
+++ b/embassy-stm32/src/flash/mod.rs
@@ -1,11 +1,11 @@
1use embedded_storage::nor_flash::{NorFlashError, NorFlashErrorKind}; 1use embedded_storage::nor_flash::{NorFlashError, NorFlashErrorKind};
2 2
3#[cfg(all(feature = "nightly", flash_f4))] 3#[cfg(flash_f4)]
4mod asynch; 4mod asynch;
5#[cfg(flash)] 5#[cfg(flash)]
6mod common; 6mod common;
7 7
8#[cfg(all(feature = "nightly", flash_f4))] 8#[cfg(flash_f4)]
9pub use asynch::InterruptHandler; 9pub use asynch::InterruptHandler;
10#[cfg(flash)] 10#[cfg(flash)]
11pub use common::*; 11pub use common::*;