Move new async to asynch module to guard for models without flash interrupt
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
use core::marker::PhantomData;
|
||||
|
||||
use atomic_polyfill::{fence, Ordering};
|
||||
use embassy_cortex_m::interrupt::{Interrupt, InterruptExt};
|
||||
use embassy_hal_common::drop::OnDrop;
|
||||
use embassy_hal_common::{into_ref, PeripheralRef};
|
||||
use stm32_metapac::FLASH_BASE;
|
||||
@ -11,29 +10,11 @@ use super::{
|
||||
READ_SIZE, WRITE_SIZE,
|
||||
};
|
||||
use crate::peripherals::FLASH;
|
||||
use crate::{interrupt, Peripheral};
|
||||
use crate::Peripheral;
|
||||
|
||||
pub struct Flash<'d, MODE = Async> {
|
||||
pub(crate) inner: PeripheralRef<'d, FLASH>,
|
||||
_mode: PhantomData<MODE>,
|
||||
}
|
||||
|
||||
impl<'d> Flash<'d, Async> {
|
||||
pub fn new(
|
||||
p: impl Peripheral<P = FLASH> + 'd,
|
||||
_irq: impl interrupt::Binding<crate::interrupt::FLASH, InterruptHandler> + 'd,
|
||||
) -> Self {
|
||||
into_ref!(p);
|
||||
|
||||
let flash_irq = unsafe { crate::interrupt::FLASH::steal() };
|
||||
flash_irq.unpend();
|
||||
flash_irq.enable();
|
||||
|
||||
Self {
|
||||
inner: p,
|
||||
_mode: PhantomData,
|
||||
}
|
||||
}
|
||||
pub(crate) _mode: PhantomData<MODE>,
|
||||
}
|
||||
|
||||
impl<'d> Flash<'d, Blocking> {
|
||||
@ -74,15 +55,6 @@ impl<'d, MODE> Flash<'d, MODE> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Interrupt handler
|
||||
pub struct InterruptHandler;
|
||||
|
||||
impl interrupt::Handler<crate::interrupt::FLASH> for InterruptHandler {
|
||||
unsafe fn on_interrupt() {
|
||||
family::on_interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn blocking_read(base: u32, size: u32, offset: u32, bytes: &mut [u8]) -> Result<(), Error> {
|
||||
if offset + bytes.len() as u32 > size {
|
||||
return Err(Error::Size);
|
||||
|
Reference in New Issue
Block a user