nightly guard async traits only
This commit is contained in:
		
							parent
							
								
									9115431d35
								
							
						
					
					
						commit
						35d8edbc41
					
				@ -9,7 +9,7 @@ use embassy_sync::mutex::Mutex;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
use super::{
 | 
					use super::{
 | 
				
			||||||
    blocking_read, ensure_sector_aligned, family, get_sector, Async, Error, Flash, FlashLayout, FLASH_BASE, FLASH_SIZE,
 | 
					    blocking_read, ensure_sector_aligned, family, get_sector, Async, Error, Flash, FlashLayout, FLASH_BASE, FLASH_SIZE,
 | 
				
			||||||
    MAX_ERASE_SIZE, READ_SIZE, WRITE_SIZE,
 | 
					    WRITE_SIZE,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
use crate::peripherals::FLASH;
 | 
					use crate::peripherals::FLASH;
 | 
				
			||||||
use crate::{interrupt, Peripheral};
 | 
					use crate::{interrupt, Peripheral};
 | 
				
			||||||
@ -56,8 +56,9 @@ impl interrupt::Handler<crate::interrupt::FLASH> for InterruptHandler {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[cfg(feature = "nightly")]
 | 
				
			||||||
impl embedded_storage_async::nor_flash::ReadNorFlash for Flash<'_, Async> {
 | 
					impl embedded_storage_async::nor_flash::ReadNorFlash for Flash<'_, Async> {
 | 
				
			||||||
    const READ_SIZE: usize = READ_SIZE;
 | 
					    const READ_SIZE: usize = super::READ_SIZE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> {
 | 
					    async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> {
 | 
				
			||||||
        self.read(offset, bytes)
 | 
					        self.read(offset, bytes)
 | 
				
			||||||
@ -68,9 +69,10 @@ impl embedded_storage_async::nor_flash::ReadNorFlash for Flash<'_, Async> {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[cfg(feature = "nightly")]
 | 
				
			||||||
impl embedded_storage_async::nor_flash::NorFlash for Flash<'_, Async> {
 | 
					impl embedded_storage_async::nor_flash::NorFlash for Flash<'_, Async> {
 | 
				
			||||||
    const WRITE_SIZE: usize = WRITE_SIZE;
 | 
					    const WRITE_SIZE: usize = WRITE_SIZE;
 | 
				
			||||||
    const ERASE_SIZE: usize = MAX_ERASE_SIZE;
 | 
					    const ERASE_SIZE: usize = super::MAX_ERASE_SIZE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    async fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Self::Error> {
 | 
					    async fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Self::Error> {
 | 
				
			||||||
        self.write(offset, bytes).await
 | 
					        self.write(offset, bytes).await
 | 
				
			||||||
@ -157,8 +159,9 @@ foreach_flash_region! {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        #[cfg(feature = "nightly")]
 | 
				
			||||||
        impl embedded_storage_async::nor_flash::ReadNorFlash for crate::_generated::flash_regions::$type_name<'_, Async> {
 | 
					        impl embedded_storage_async::nor_flash::ReadNorFlash for crate::_generated::flash_regions::$type_name<'_, Async> {
 | 
				
			||||||
            const READ_SIZE: usize = READ_SIZE;
 | 
					            const READ_SIZE: usize = super::READ_SIZE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> {
 | 
					            async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> {
 | 
				
			||||||
                self.read(offset, bytes).await
 | 
					                self.read(offset, bytes).await
 | 
				
			||||||
@ -169,6 +172,7 @@ foreach_flash_region! {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        #[cfg(feature = "nightly")]
 | 
				
			||||||
        impl embedded_storage_async::nor_flash::NorFlash for crate::_generated::flash_regions::$type_name<'_, Async> {
 | 
					        impl embedded_storage_async::nor_flash::NorFlash for crate::_generated::flash_regions::$type_name<'_, Async> {
 | 
				
			||||||
            const WRITE_SIZE: usize = $write_size;
 | 
					            const WRITE_SIZE: usize = $write_size;
 | 
				
			||||||
            const ERASE_SIZE: usize = $erase_size;
 | 
					            const ERASE_SIZE: usize = $erase_size;
 | 
				
			||||||
 | 
				
			|||||||
@ -3,7 +3,6 @@ use core::ptr::write_volatile;
 | 
				
			|||||||
use core::sync::atomic::{fence, Ordering};
 | 
					use core::sync::atomic::{fence, Ordering};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use atomic_polyfill::AtomicBool;
 | 
					use atomic_polyfill::AtomicBool;
 | 
				
			||||||
#[cfg(feature = "nightly")]
 | 
					 | 
				
			||||||
use embassy_sync::waitqueue::AtomicWaker;
 | 
					use embassy_sync::waitqueue::AtomicWaker;
 | 
				
			||||||
use pac::flash::regs::Sr;
 | 
					use pac::flash::regs::Sr;
 | 
				
			||||||
use pac::FLASH_SIZE;
 | 
					use pac::FLASH_SIZE;
 | 
				
			||||||
@ -20,7 +19,7 @@ mod alt_regions {
 | 
				
			|||||||
    use stm32_metapac::FLASH_SIZE;
 | 
					    use stm32_metapac::FLASH_SIZE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    use crate::_generated::flash_regions::{OTPRegion, BANK1_REGION1, BANK1_REGION2, BANK1_REGION3, OTP_REGION};
 | 
					    use crate::_generated::flash_regions::{OTPRegion, BANK1_REGION1, BANK1_REGION2, BANK1_REGION3, OTP_REGION};
 | 
				
			||||||
    #[cfg(feature = "nightly")]
 | 
					
 | 
				
			||||||
    use crate::flash::asynch;
 | 
					    use crate::flash::asynch;
 | 
				
			||||||
    use crate::flash::{Async, Bank1Region1, Bank1Region2, Blocking, Error, Flash, FlashBank, FlashRegion};
 | 
					    use crate::flash::{Async, Bank1Region1, Bank1Region2, Blocking, Error, Flash, FlashBank, FlashRegion};
 | 
				
			||||||
    use crate::peripherals::FLASH;
 | 
					    use crate::peripherals::FLASH;
 | 
				
			||||||
@ -114,7 +113,6 @@ mod alt_regions {
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            #[cfg(feature = "nightly")]
 | 
					 | 
				
			||||||
            impl $type_name<'_, Async> {
 | 
					            impl $type_name<'_, Async> {
 | 
				
			||||||
                pub async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Error> {
 | 
					                pub async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Error> {
 | 
				
			||||||
                    self.blocking_read(offset, bytes)
 | 
					                    self.blocking_read(offset, bytes)
 | 
				
			||||||
@ -185,7 +183,6 @@ mod alt_regions {
 | 
				
			|||||||
#[cfg(any(stm32f427, stm32f429, stm32f437, stm32f439, stm32f469, stm32f479))]
 | 
					#[cfg(any(stm32f427, stm32f429, stm32f437, stm32f439, stm32f469, stm32f479))]
 | 
				
			||||||
pub use alt_regions::*;
 | 
					pub use alt_regions::*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[cfg(feature = "nightly")]
 | 
					 | 
				
			||||||
static WAKER: AtomicWaker = AtomicWaker::new();
 | 
					static WAKER: AtomicWaker = AtomicWaker::new();
 | 
				
			||||||
static DATA_CACHE_WAS_ENABLED: AtomicBool = AtomicBool::new(false);
 | 
					static DATA_CACHE_WAS_ENABLED: AtomicBool = AtomicBool::new(false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -236,7 +233,6 @@ pub const fn get_flash_regions() -> &'static [&'static FlashRegion] {
 | 
				
			|||||||
    &FLASH_REGIONS
 | 
					    &FLASH_REGIONS
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[cfg(feature = "nightly")]
 | 
					 | 
				
			||||||
pub(crate) unsafe fn on_interrupt() {
 | 
					pub(crate) unsafe fn on_interrupt() {
 | 
				
			||||||
    // Clear IRQ flags
 | 
					    // Clear IRQ flags
 | 
				
			||||||
    pac::FLASH.sr().write(|w| {
 | 
					    pac::FLASH.sr().write(|w| {
 | 
				
			||||||
@ -256,7 +252,6 @@ pub(crate) unsafe fn unlock() {
 | 
				
			|||||||
    pac::FLASH.keyr().write(|w| w.set_key(0xCDEF89AB));
 | 
					    pac::FLASH.keyr().write(|w| w.set_key(0xCDEF89AB));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[cfg(feature = "nightly")]
 | 
					 | 
				
			||||||
pub(crate) unsafe fn enable_write() {
 | 
					pub(crate) unsafe fn enable_write() {
 | 
				
			||||||
    assert_eq!(0, WRITE_SIZE % 4);
 | 
					    assert_eq!(0, WRITE_SIZE % 4);
 | 
				
			||||||
    save_data_cache_state();
 | 
					    save_data_cache_state();
 | 
				
			||||||
@ -269,7 +264,6 @@ pub(crate) unsafe fn enable_write() {
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[cfg(feature = "nightly")]
 | 
					 | 
				
			||||||
pub(crate) unsafe fn disable_write() {
 | 
					pub(crate) unsafe fn disable_write() {
 | 
				
			||||||
    pac::FLASH.cr().write(|w| {
 | 
					    pac::FLASH.cr().write(|w| {
 | 
				
			||||||
        w.set_pg(false);
 | 
					        w.set_pg(false);
 | 
				
			||||||
@ -294,7 +288,6 @@ pub(crate) unsafe fn disable_blocking_write() {
 | 
				
			|||||||
    restore_data_cache_state();
 | 
					    restore_data_cache_state();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[cfg(feature = "nightly")]
 | 
					 | 
				
			||||||
pub(crate) async unsafe fn write(start_address: u32, buf: &[u8; WRITE_SIZE]) -> Result<(), Error> {
 | 
					pub(crate) async unsafe fn write(start_address: u32, buf: &[u8; WRITE_SIZE]) -> Result<(), Error> {
 | 
				
			||||||
    write_start(start_address, buf);
 | 
					    write_start(start_address, buf);
 | 
				
			||||||
    wait_ready().await
 | 
					    wait_ready().await
 | 
				
			||||||
@ -316,7 +309,6 @@ unsafe fn write_start(start_address: u32, buf: &[u8; WRITE_SIZE]) {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[cfg(feature = "nightly")]
 | 
					 | 
				
			||||||
pub(crate) async unsafe fn erase_sector(sector: &FlashSector) -> Result<(), Error> {
 | 
					pub(crate) async unsafe fn erase_sector(sector: &FlashSector) -> Result<(), Error> {
 | 
				
			||||||
    save_data_cache_state();
 | 
					    save_data_cache_state();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -372,7 +364,6 @@ pub(crate) unsafe fn clear_all_err() {
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[cfg(feature = "nightly")]
 | 
					 | 
				
			||||||
pub(crate) async unsafe fn wait_ready() -> Result<(), Error> {
 | 
					pub(crate) async unsafe fn wait_ready() -> Result<(), Error> {
 | 
				
			||||||
    use core::task::Poll;
 | 
					    use core::task::Poll;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,11 +1,11 @@
 | 
				
			|||||||
use embedded_storage::nor_flash::{NorFlashError, NorFlashErrorKind};
 | 
					use embedded_storage::nor_flash::{NorFlashError, NorFlashErrorKind};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[cfg(all(feature = "nightly", flash_f4))]
 | 
					#[cfg(flash_f4)]
 | 
				
			||||||
mod asynch;
 | 
					mod asynch;
 | 
				
			||||||
#[cfg(flash)]
 | 
					#[cfg(flash)]
 | 
				
			||||||
mod common;
 | 
					mod common;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[cfg(all(feature = "nightly", flash_f4))]
 | 
					#[cfg(flash_f4)]
 | 
				
			||||||
pub use asynch::InterruptHandler;
 | 
					pub use asynch::InterruptHandler;
 | 
				
			||||||
#[cfg(flash)]
 | 
					#[cfg(flash)]
 | 
				
			||||||
pub use common::*;
 | 
					pub use common::*;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user