diff options
| author | Dario Nieuwenhuis <[email protected]> | 2025-03-26 16:01:37 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2025-03-27 15:18:06 +0100 |
| commit | d41eeeae79388f219bf6a84e2f7bde9f6b532516 (patch) | |
| tree | 678b6fc732216e529dc38e6f65b72a309917ac32 /embassy-stm32/src/flash | |
| parent | 9edf5b7f049f95742b60b041e4443967d8a6b708 (diff) | |
Remove Peripheral trait, rename PeripheralRef->Peri.
Diffstat (limited to 'embassy-stm32/src/flash')
| -rw-r--r-- | embassy-stm32/src/flash/asynch.rs | 7 | ||||
| -rw-r--r-- | embassy-stm32/src/flash/common.rs | 9 | ||||
| -rw-r--r-- | embassy-stm32/src/flash/f4.rs | 11 |
3 files changed, 10 insertions, 17 deletions
diff --git a/embassy-stm32/src/flash/asynch.rs b/embassy-stm32/src/flash/asynch.rs index 9468ac632..599b7bb4e 100644 --- a/embassy-stm32/src/flash/asynch.rs +++ b/embassy-stm32/src/flash/asynch.rs | |||
| @@ -2,7 +2,6 @@ use core::marker::PhantomData; | |||
| 2 | use core::sync::atomic::{fence, Ordering}; | 2 | use core::sync::atomic::{fence, Ordering}; |
| 3 | 3 | ||
| 4 | use embassy_hal_internal::drop::OnDrop; | 4 | use embassy_hal_internal::drop::OnDrop; |
| 5 | use embassy_hal_internal::into_ref; | ||
| 6 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | 5 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; |
| 7 | use embassy_sync::mutex::Mutex; | 6 | use embassy_sync::mutex::Mutex; |
| 8 | 7 | ||
| @@ -12,18 +11,16 @@ use super::{ | |||
| 12 | }; | 11 | }; |
| 13 | use crate::interrupt::InterruptExt; | 12 | use crate::interrupt::InterruptExt; |
| 14 | use crate::peripherals::FLASH; | 13 | use crate::peripherals::FLASH; |
| 15 | use crate::{interrupt, Peripheral}; | 14 | use crate::{interrupt, Peri}; |
| 16 | 15 | ||
| 17 | pub(super) static REGION_ACCESS: Mutex<CriticalSectionRawMutex, ()> = Mutex::new(()); | 16 | pub(super) static REGION_ACCESS: Mutex<CriticalSectionRawMutex, ()> = Mutex::new(()); |
| 18 | 17 | ||
| 19 | impl<'d> Flash<'d, Async> { | 18 | impl<'d> Flash<'d, Async> { |
| 20 | /// Create a new flash driver with async capabilities. | 19 | /// Create a new flash driver with async capabilities. |
| 21 | pub fn new( | 20 | pub fn new( |
| 22 | p: impl Peripheral<P = FLASH> + 'd, | 21 | p: Peri<'d, FLASH>, |
| 23 | _irq: impl interrupt::typelevel::Binding<crate::interrupt::typelevel::FLASH, InterruptHandler> + 'd, | 22 | _irq: impl interrupt::typelevel::Binding<crate::interrupt::typelevel::FLASH, InterruptHandler> + 'd, |
| 24 | ) -> Self { | 23 | ) -> Self { |
| 25 | into_ref!(p); | ||
| 26 | |||
| 27 | crate::interrupt::FLASH.unpend(); | 24 | crate::interrupt::FLASH.unpend(); |
| 28 | unsafe { crate::interrupt::FLASH.enable() }; | 25 | unsafe { crate::interrupt::FLASH.enable() }; |
| 29 | 26 | ||
diff --git a/embassy-stm32/src/flash/common.rs b/embassy-stm32/src/flash/common.rs index 0004a7488..1376ca4b4 100644 --- a/embassy-stm32/src/flash/common.rs +++ b/embassy-stm32/src/flash/common.rs | |||
| @@ -2,27 +2,24 @@ use core::marker::PhantomData; | |||
| 2 | use core::sync::atomic::{fence, Ordering}; | 2 | use core::sync::atomic::{fence, Ordering}; |
| 3 | 3 | ||
| 4 | use embassy_hal_internal::drop::OnDrop; | 4 | use embassy_hal_internal::drop::OnDrop; |
| 5 | use embassy_hal_internal::{into_ref, PeripheralRef}; | ||
| 6 | 5 | ||
| 7 | use super::{ | 6 | use super::{ |
| 8 | family, Async, Blocking, Error, FlashBank, FlashLayout, FlashRegion, FlashSector, FLASH_SIZE, MAX_ERASE_SIZE, | 7 | family, Async, Blocking, Error, FlashBank, FlashLayout, FlashRegion, FlashSector, FLASH_SIZE, MAX_ERASE_SIZE, |
| 9 | READ_SIZE, WRITE_SIZE, | 8 | READ_SIZE, WRITE_SIZE, |
| 10 | }; | 9 | }; |
| 10 | use crate::Peri; | ||
| 11 | use crate::_generated::FLASH_BASE; | 11 | use crate::_generated::FLASH_BASE; |
| 12 | use crate::peripherals::FLASH; | 12 | use crate::peripherals::FLASH; |
| 13 | use crate::Peripheral; | ||
| 14 | 13 | ||
| 15 | /// Internal flash memory driver. | 14 | /// Internal flash memory driver. |
| 16 | pub struct Flash<'d, MODE = Async> { | 15 | pub struct Flash<'d, MODE = Async> { |
| 17 | pub(crate) inner: PeripheralRef<'d, FLASH>, | 16 | pub(crate) inner: Peri<'d, FLASH>, |
| 18 | pub(crate) _mode: PhantomData<MODE>, | 17 | pub(crate) _mode: PhantomData<MODE>, |
| 19 | } | 18 | } |
| 20 | 19 | ||
| 21 | impl<'d> Flash<'d, Blocking> { | 20 | impl<'d> Flash<'d, Blocking> { |
| 22 | /// Create a new flash driver, usable in blocking mode. | 21 | /// Create a new flash driver, usable in blocking mode. |
| 23 | pub fn new_blocking(p: impl Peripheral<P = FLASH> + 'd) -> Self { | 22 | pub fn new_blocking(p: Peri<'d, FLASH>) -> Self { |
| 24 | into_ref!(p); | ||
| 25 | |||
| 26 | Self { | 23 | Self { |
| 27 | inner: p, | 24 | inner: p, |
| 28 | _mode: PhantomData, | 25 | _mode: PhantomData, |
diff --git a/embassy-stm32/src/flash/f4.rs b/embassy-stm32/src/flash/f4.rs index 86afdce8a..687eabaeb 100644 --- a/embassy-stm32/src/flash/f4.rs +++ b/embassy-stm32/src/flash/f4.rs | |||
| @@ -13,8 +13,7 @@ use crate::pac; | |||
| 13 | mod alt_regions { | 13 | mod alt_regions { |
| 14 | use core::marker::PhantomData; | 14 | use core::marker::PhantomData; |
| 15 | 15 | ||
| 16 | use embassy_hal_internal::PeripheralRef; | 16 | use crate::Peri; |
| 17 | |||
| 18 | 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}; |
| 19 | use crate::_generated::FLASH_SIZE; | 18 | use crate::_generated::FLASH_SIZE; |
| 20 | use crate::flash::{asynch, Async, Bank1Region1, Bank1Region2, Blocking, Error, Flash, FlashBank, FlashRegion}; | 19 | use crate::flash::{asynch, Async, Bank1Region1, Bank1Region2, Blocking, Error, Flash, FlashBank, FlashRegion}; |
| @@ -50,10 +49,10 @@ mod alt_regions { | |||
| 50 | &ALT_BANK2_REGION3, | 49 | &ALT_BANK2_REGION3, |
| 51 | ]; | 50 | ]; |
| 52 | 51 | ||
| 53 | pub struct AltBank1Region3<'d, MODE = Async>(pub &'static FlashRegion, PeripheralRef<'d, FLASH>, PhantomData<MODE>); | 52 | pub struct AltBank1Region3<'d, MODE = Async>(pub &'static FlashRegion, Peri<'d, FLASH>, PhantomData<MODE>); |
| 54 | pub struct AltBank2Region1<'d, MODE = Async>(pub &'static FlashRegion, PeripheralRef<'d, FLASH>, PhantomData<MODE>); | 53 | pub struct AltBank2Region1<'d, MODE = Async>(pub &'static FlashRegion, Peri<'d, FLASH>, PhantomData<MODE>); |
| 55 | pub struct AltBank2Region2<'d, MODE = Async>(pub &'static FlashRegion, PeripheralRef<'d, FLASH>, PhantomData<MODE>); | 54 | pub struct AltBank2Region2<'d, MODE = Async>(pub &'static FlashRegion, Peri<'d, FLASH>, PhantomData<MODE>); |
| 56 | pub struct AltBank2Region3<'d, MODE = Async>(pub &'static FlashRegion, PeripheralRef<'d, FLASH>, PhantomData<MODE>); | 55 | pub struct AltBank2Region3<'d, MODE = Async>(pub &'static FlashRegion, Peri<'d, FLASH>, PhantomData<MODE>); |
| 57 | 56 | ||
| 58 | pub struct AltFlashLayout<'d, MODE = Async> { | 57 | pub struct AltFlashLayout<'d, MODE = Async> { |
| 59 | pub bank1_region1: Bank1Region1<'d, MODE>, | 58 | pub bank1_region1: Bank1Region1<'d, MODE>, |
