aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/src/flash/f4.rs
diff options
context:
space:
mode:
authorRasmus Melchior Jacobsen <[email protected]>2023-05-26 00:31:41 +0200
committerRasmus Melchior Jacobsen <[email protected]>2023-05-26 00:31:41 +0200
commit35d8edbc4104be16d1b1437b32a135a411b2d0e1 (patch)
tree92572d5c2ac5bdab5d0452991a6c8cd5c22edc1c /embassy-stm32/src/flash/f4.rs
parent9115431d358628f2d0ff9f9b5d017e2f3b23472b (diff)
nightly guard async traits only
Diffstat (limited to 'embassy-stm32/src/flash/f4.rs')
-rw-r--r--embassy-stm32/src/flash/f4.rs11
1 files changed, 1 insertions, 10 deletions
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