diff options
| author | Dario Nieuwenhuis <[email protected]> | 2023-06-08 16:08:40 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2023-06-08 18:00:48 +0200 |
| commit | 921780e6bfb9bcb2cd087b8aa8b094d792c99fa2 (patch) | |
| tree | bd21fba9800471b860ca44e05567588dcc1afef7 /embassy-stm32/src/flash | |
| parent | 87ad66f2b4a5bfd36dfc8d8aad5492e9e3f915e6 (diff) | |
Make interrupt module more standard.
- Move typelevel interrupts to a special-purpose mod: `embassy_xx::interrupt::typelevel`.
- Reexport the PAC interrupt enum in `embassy_xx::interrupt`.
This has a few advantages:
- The `embassy_xx::interrupt` module is now more "standard".
- It works with `cortex-m` functions for manipulating interrupts, for example.
- It works with RTIC.
- the interrupt enum allows holding value that can be "any interrupt at runtime", this can't be done with typelevel irqs.
- When "const-generics on enums" is stable, we can remove the typelevel interrupts without disruptive changes to `embassy_xx::interrupt`.
Diffstat (limited to 'embassy-stm32/src/flash')
| -rw-r--r-- | embassy-stm32/src/flash/asynch.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/embassy-stm32/src/flash/asynch.rs b/embassy-stm32/src/flash/asynch.rs index 872614d4e..70a5ded62 100644 --- a/embassy-stm32/src/flash/asynch.rs +++ b/embassy-stm32/src/flash/asynch.rs | |||
| @@ -1,7 +1,6 @@ | |||
| 1 | use core::marker::PhantomData; | 1 | use core::marker::PhantomData; |
| 2 | 2 | ||
| 3 | use atomic_polyfill::{fence, Ordering}; | 3 | use atomic_polyfill::{fence, Ordering}; |
| 4 | use embassy_cortex_m::interrupt::Interrupt; | ||
| 5 | use embassy_hal_common::drop::OnDrop; | 4 | use embassy_hal_common::drop::OnDrop; |
| 6 | use embassy_hal_common::into_ref; | 5 | use embassy_hal_common::into_ref; |
| 7 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | 6 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; |
| @@ -11,6 +10,7 @@ use super::{ | |||
| 11 | blocking_read, ensure_sector_aligned, family, get_sector, Async, Error, Flash, FlashLayout, FLASH_BASE, FLASH_SIZE, | 10 | blocking_read, ensure_sector_aligned, family, get_sector, Async, Error, Flash, FlashLayout, FLASH_BASE, FLASH_SIZE, |
| 12 | WRITE_SIZE, | 11 | WRITE_SIZE, |
| 13 | }; | 12 | }; |
| 13 | use crate::interrupt::InterruptExt; | ||
| 14 | use crate::peripherals::FLASH; | 14 | use crate::peripherals::FLASH; |
| 15 | use crate::{interrupt, Peripheral}; | 15 | use crate::{interrupt, Peripheral}; |
| 16 | 16 | ||
| @@ -19,12 +19,12 @@ pub(super) static REGION_ACCESS: Mutex<CriticalSectionRawMutex, ()> = Mutex::new | |||
| 19 | impl<'d> Flash<'d, Async> { | 19 | impl<'d> Flash<'d, Async> { |
| 20 | pub fn new( | 20 | pub fn new( |
| 21 | p: impl Peripheral<P = FLASH> + 'd, | 21 | p: impl Peripheral<P = FLASH> + 'd, |
| 22 | _irq: impl interrupt::Binding<crate::interrupt::FLASH, InterruptHandler> + 'd, | 22 | _irq: impl interrupt::typelevel::Binding<crate::interrupt::typelevel::FLASH, InterruptHandler> + 'd, |
| 23 | ) -> Self { | 23 | ) -> Self { |
| 24 | into_ref!(p); | 24 | into_ref!(p); |
| 25 | 25 | ||
| 26 | crate::interrupt::FLASH::unpend(); | 26 | crate::interrupt::FLASH.unpend(); |
| 27 | unsafe { crate::interrupt::FLASH::enable() }; | 27 | unsafe { crate::interrupt::FLASH.enable() }; |
| 28 | 28 | ||
| 29 | Self { | 29 | Self { |
| 30 | inner: p, | 30 | inner: p, |
| @@ -49,7 +49,7 @@ impl<'d> Flash<'d, Async> { | |||
| 49 | /// Interrupt handler | 49 | /// Interrupt handler |
| 50 | pub struct InterruptHandler; | 50 | pub struct InterruptHandler; |
| 51 | 51 | ||
| 52 | impl interrupt::Handler<crate::interrupt::FLASH> for InterruptHandler { | 52 | impl interrupt::typelevel::Handler<crate::interrupt::typelevel::FLASH> for InterruptHandler { |
| 53 | unsafe fn on_interrupt() { | 53 | unsafe fn on_interrupt() { |
| 54 | family::on_interrupt(); | 54 | family::on_interrupt(); |
| 55 | } | 55 | } |
