diff options
| author | Rasmus Melchior Jacobsen <[email protected]> | 2023-05-24 12:55:17 +0200 |
|---|---|---|
| committer | Rasmus Melchior Jacobsen <[email protected]> | 2023-05-25 13:04:47 +0200 |
| commit | 1329a387e060d60ee2833d2eed6393f5dfc84d1a (patch) | |
| tree | 451140a1cdbb26b886bf145c3769a861e6aad751 | |
| parent | 6804b6c0b49777489b132639290b5e977ec8ffd9 (diff) | |
Add more missing nightly guards
| -rw-r--r-- | embassy-stm32/src/flash/f4.rs | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/embassy-stm32/src/flash/f4.rs b/embassy-stm32/src/flash/f4.rs index 9698bcd58..0c008fd0d 100644 --- a/embassy-stm32/src/flash/f4.rs +++ b/embassy-stm32/src/flash/f4.rs | |||
| @@ -2,12 +2,13 @@ use core::convert::TryInto; | |||
| 2 | use core::ptr::write_volatile; | 2 | use core::ptr::write_volatile; |
| 3 | use core::sync::atomic::{fence, Ordering}; | 3 | use core::sync::atomic::{fence, Ordering}; |
| 4 | 4 | ||
| 5 | use embassy_sync::waitqueue::AtomicWaker; | ||
| 6 | |||
| 7 | use super::{FlashRegion, FlashSector, FLASH_REGIONS, WRITE_SIZE}; | 5 | use super::{FlashRegion, FlashSector, FLASH_REGIONS, WRITE_SIZE}; |
| 8 | use crate::flash::Error; | 6 | use crate::flash::Error; |
| 9 | use crate::pac; | 7 | use crate::pac; |
| 10 | 8 | ||
| 9 | #[cfg(feature = "nightly")] | ||
| 10 | use embassy_sync::waitqueue::AtomicWaker; | ||
| 11 | |||
| 11 | #[cfg(any(stm32f427, stm32f429, stm32f437, stm32f439, stm32f469, stm32f479))] | 12 | #[cfg(any(stm32f427, stm32f429, stm32f437, stm32f439, stm32f469, stm32f479))] |
| 12 | mod alt_regions { | 13 | mod alt_regions { |
| 13 | use embassy_hal_common::PeripheralRef; | 14 | use embassy_hal_common::PeripheralRef; |
| @@ -15,10 +16,12 @@ mod alt_regions { | |||
| 15 | 16 | ||
| 16 | use crate::_generated::flash_regions::{OTPRegion, BANK1_REGION1, BANK1_REGION2, BANK1_REGION3, OTP_REGION}; | 17 | use crate::_generated::flash_regions::{OTPRegion, BANK1_REGION1, BANK1_REGION2, BANK1_REGION3, OTP_REGION}; |
| 17 | use crate::flash::{ | 18 | use crate::flash::{ |
| 18 | asynch, common, Bank1Region1, Bank1Region2, BlockingFlashRegion, Error, Flash, FlashBank, FlashRegion, | 19 | common, Bank1Region1, Bank1Region2, BlockingFlashRegion, Error, Flash, FlashBank, FlashRegion, |
| 19 | READ_SIZE, REGION_ACCESS, | 20 | READ_SIZE, REGION_ACCESS, |
| 20 | }; | 21 | }; |
| 21 | use crate::peripherals::FLASH; | 22 | use crate::peripherals::FLASH; |
| 23 | #[cfg(feature = "nightly")] | ||
| 24 | use crate::flash::asynch; | ||
| 22 | 25 | ||
| 23 | pub const ALT_BANK1_REGION3: FlashRegion = FlashRegion { | 26 | pub const ALT_BANK1_REGION3: FlashRegion = FlashRegion { |
| 24 | size: 3 * BANK1_REGION3.erase_size, | 27 | size: 3 * BANK1_REGION3.erase_size, |
| @@ -100,13 +103,13 @@ mod alt_regions { | |||
| 100 | common::read_blocking(self.0.base, self.0.size, offset, bytes) | 103 | common::read_blocking(self.0.base, self.0.size, offset, bytes) |
| 101 | } | 104 | } |
| 102 | 105 | ||
| 103 | #[cfg(all(feature = "nightly"))] | 106 | #[cfg(feature = "nightly")] |
| 104 | pub async fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Error> { | 107 | pub async fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Error> { |
| 105 | let _guard = REGION_ACCESS.lock().await; | 108 | let _guard = REGION_ACCESS.lock().await; |
| 106 | unsafe { asynch::write_chunked(self.0.base, self.0.size, offset, bytes).await } | 109 | unsafe { asynch::write_chunked(self.0.base, self.0.size, offset, bytes).await } |
| 107 | } | 110 | } |
| 108 | 111 | ||
| 109 | #[cfg(all(feature = "nightly"))] | 112 | #[cfg(feature = "nightly")] |
| 110 | pub async fn erase(&mut self, from: u32, to: u32) -> Result<(), Error> { | 113 | pub async fn erase(&mut self, from: u32, to: u32) -> Result<(), Error> { |
| 111 | let _guard = REGION_ACCESS.lock().await; | 114 | let _guard = REGION_ACCESS.lock().await; |
| 112 | unsafe { asynch::erase_sectored(self.0.base, from, to).await } | 115 | unsafe { asynch::erase_sectored(self.0.base, from, to).await } |
| @@ -139,7 +142,7 @@ mod alt_regions { | |||
| 139 | } | 142 | } |
| 140 | } | 143 | } |
| 141 | 144 | ||
| 142 | #[cfg(all(feature = "nightly"))] | 145 | #[cfg(feature = "nightly")] |
| 143 | impl embedded_storage_async::nor_flash::ReadNorFlash for $type_name<'_> { | 146 | impl embedded_storage_async::nor_flash::ReadNorFlash for $type_name<'_> { |
| 144 | const READ_SIZE: usize = READ_SIZE; | 147 | const READ_SIZE: usize = READ_SIZE; |
| 145 | 148 | ||
| @@ -152,7 +155,7 @@ mod alt_regions { | |||
| 152 | } | 155 | } |
| 153 | } | 156 | } |
| 154 | 157 | ||
| 155 | #[cfg(all(feature = "nightly"))] | 158 | #[cfg(feature = "nightly")] |
| 156 | impl embedded_storage_async::nor_flash::NorFlash for $type_name<'_> { | 159 | impl embedded_storage_async::nor_flash::NorFlash for $type_name<'_> { |
| 157 | const WRITE_SIZE: usize = $region.write_size as usize; | 160 | const WRITE_SIZE: usize = $region.write_size as usize; |
| 158 | const ERASE_SIZE: usize = $region.erase_size as usize; | 161 | const ERASE_SIZE: usize = $region.erase_size as usize; |
| @@ -209,6 +212,7 @@ pub(crate) unsafe fn on_interrupt(_: *mut ()) { | |||
| 209 | w.set_eop(true); | 212 | w.set_eop(true); |
| 210 | }); | 213 | }); |
| 211 | 214 | ||
| 215 | #[cfg(feature = "nightly")] | ||
| 212 | WAKER.wake(); | 216 | WAKER.wake(); |
| 213 | } | 217 | } |
| 214 | 218 | ||
| @@ -277,6 +281,7 @@ unsafe fn write_start(start_address: u32, buf: &[u8; WRITE_SIZE]) { | |||
| 277 | } | 281 | } |
| 278 | } | 282 | } |
| 279 | 283 | ||
| 284 | #[cfg(feature = "nightly")] | ||
| 280 | pub(crate) async unsafe fn erase_sector(sector: &FlashSector) -> Result<(), Error> { | 285 | pub(crate) async unsafe fn erase_sector(sector: &FlashSector) -> Result<(), Error> { |
| 281 | let snb = ((sector.bank as u8) << 4) + sector.index_in_bank; | 286 | let snb = ((sector.bank as u8) << 4) + sector.index_in_bank; |
| 282 | 287 | ||
