diff options
| -rw-r--r-- | embassy-stm32/src/dma/bdma.rs | 7 | ||||
| -rw-r--r-- | embassy-stm32/src/dma/dma.rs | 7 | ||||
| -rw-r--r-- | embassy-stm32/src/dma/mod.rs | 8 | ||||
| -rw-r--r-- | embassy-stm32/src/lib.rs | 17 |
4 files changed, 31 insertions, 8 deletions
diff --git a/embassy-stm32/src/dma/bdma.rs b/embassy-stm32/src/dma/bdma.rs index 674255ddc..e6ce05b7b 100644 --- a/embassy-stm32/src/dma/bdma.rs +++ b/embassy-stm32/src/dma/bdma.rs | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | use core::sync::atomic::{fence, Ordering}; | 3 | use core::sync::atomic::{fence, Ordering}; |
| 4 | use core::task::Waker; | 4 | use core::task::Waker; |
| 5 | 5 | ||
| 6 | use embassy_cortex_m::interrupt::Priority; | ||
| 6 | use embassy_sync::waitqueue::AtomicWaker; | 7 | use embassy_sync::waitqueue::AtomicWaker; |
| 7 | 8 | ||
| 8 | use super::{TransferOptions, Word, WordSize}; | 9 | use super::{TransferOptions, Word, WordSize}; |
| @@ -38,10 +39,12 @@ impl State { | |||
| 38 | static STATE: State = State::new(); | 39 | static STATE: State = State::new(); |
| 39 | 40 | ||
| 40 | /// safety: must be called only once | 41 | /// safety: must be called only once |
| 41 | pub(crate) unsafe fn init() { | 42 | pub(crate) unsafe fn init(irq_priority: Priority) { |
| 42 | foreach_interrupt! { | 43 | foreach_interrupt! { |
| 43 | ($peri:ident, bdma, $block:ident, $signal_name:ident, $irq:ident) => { | 44 | ($peri:ident, bdma, $block:ident, $signal_name:ident, $irq:ident) => { |
| 44 | crate::interrupt::$irq::steal().enable(); | 45 | let irq = crate::interrupt::$irq::steal(); |
| 46 | irq.set_priority(irq_priority); | ||
| 47 | irq.enable(); | ||
| 45 | }; | 48 | }; |
| 46 | } | 49 | } |
| 47 | crate::_generated::init_bdma(); | 50 | crate::_generated::init_bdma(); |
diff --git a/embassy-stm32/src/dma/dma.rs b/embassy-stm32/src/dma/dma.rs index a45b8780b..97a3df088 100644 --- a/embassy-stm32/src/dma/dma.rs +++ b/embassy-stm32/src/dma/dma.rs | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | use core::sync::atomic::{fence, Ordering}; | 1 | use core::sync::atomic::{fence, Ordering}; |
| 2 | use core::task::Waker; | 2 | use core::task::Waker; |
| 3 | 3 | ||
| 4 | use embassy_cortex_m::interrupt::Priority; | ||
| 4 | use embassy_sync::waitqueue::AtomicWaker; | 5 | use embassy_sync::waitqueue::AtomicWaker; |
| 5 | 6 | ||
| 6 | use super::{Burst, FlowControl, Request, TransferOptions, Word, WordSize}; | 7 | use super::{Burst, FlowControl, Request, TransferOptions, Word, WordSize}; |
| @@ -67,10 +68,12 @@ impl State { | |||
| 67 | static STATE: State = State::new(); | 68 | static STATE: State = State::new(); |
| 68 | 69 | ||
| 69 | /// safety: must be called only once | 70 | /// safety: must be called only once |
| 70 | pub(crate) unsafe fn init() { | 71 | pub(crate) unsafe fn init(irq_priority: Priority) { |
| 71 | foreach_interrupt! { | 72 | foreach_interrupt! { |
| 72 | ($peri:ident, dma, $block:ident, $signal_name:ident, $irq:ident) => { | 73 | ($peri:ident, dma, $block:ident, $signal_name:ident, $irq:ident) => { |
| 73 | interrupt::$irq::steal().enable(); | 74 | let irq = interrupt::$irq::steal(); |
| 75 | irq.set_priority(irq_priority); | ||
| 76 | irq.enable(); | ||
| 74 | }; | 77 | }; |
| 75 | } | 78 | } |
| 76 | crate::_generated::init_dma(); | 79 | crate::_generated::init_dma(); |
diff --git a/embassy-stm32/src/dma/mod.rs b/embassy-stm32/src/dma/mod.rs index cc030a93e..74bce6aa9 100644 --- a/embassy-stm32/src/dma/mod.rs +++ b/embassy-stm32/src/dma/mod.rs | |||
| @@ -12,6 +12,8 @@ use core::mem; | |||
| 12 | use core::pin::Pin; | 12 | use core::pin::Pin; |
| 13 | use core::task::{Context, Poll, Waker}; | 13 | use core::task::{Context, Poll, Waker}; |
| 14 | 14 | ||
| 15 | #[cfg(any(dma, bdma))] | ||
| 16 | use embassy_cortex_m::interrupt::Priority; | ||
| 15 | use embassy_hal_common::{impl_peripheral, into_ref}; | 17 | use embassy_hal_common::{impl_peripheral, into_ref}; |
| 16 | 18 | ||
| 17 | #[cfg(dmamux)] | 19 | #[cfg(dmamux)] |
| @@ -294,11 +296,11 @@ pub struct NoDma; | |||
| 294 | impl_peripheral!(NoDma); | 296 | impl_peripheral!(NoDma); |
| 295 | 297 | ||
| 296 | // safety: must be called only once at startup | 298 | // safety: must be called only once at startup |
| 297 | pub(crate) unsafe fn init() { | 299 | pub(crate) unsafe fn init(#[cfg(bdma)] bdma_priority: Priority, #[cfg(dma)] dma_priority: Priority) { |
| 298 | #[cfg(bdma)] | 300 | #[cfg(bdma)] |
| 299 | bdma::init(); | 301 | bdma::init(bdma_priority); |
| 300 | #[cfg(dma)] | 302 | #[cfg(dma)] |
| 301 | dma::init(); | 303 | dma::init(dma_priority); |
| 302 | #[cfg(dmamux)] | 304 | #[cfg(dmamux)] |
| 303 | dmamux::init(); | 305 | dmamux::init(); |
| 304 | #[cfg(gpdma)] | 306 | #[cfg(gpdma)] |
diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs index d7443eace..16c46ca22 100644 --- a/embassy-stm32/src/lib.rs +++ b/embassy-stm32/src/lib.rs | |||
| @@ -79,6 +79,8 @@ pub(crate) mod _generated { | |||
| 79 | // Reexports | 79 | // Reexports |
| 80 | pub use _generated::{peripherals, Peripherals}; | 80 | pub use _generated::{peripherals, Peripherals}; |
| 81 | pub use embassy_cortex_m::executor; | 81 | pub use embassy_cortex_m::executor; |
| 82 | #[cfg(any(dma, bdma))] | ||
| 83 | use embassy_cortex_m::interrupt::Priority; | ||
| 82 | pub use embassy_cortex_m::interrupt::_export::interrupt; | 84 | pub use embassy_cortex_m::interrupt::_export::interrupt; |
| 83 | pub use embassy_hal_common::{into_ref, Peripheral, PeripheralRef}; | 85 | pub use embassy_hal_common::{into_ref, Peripheral, PeripheralRef}; |
| 84 | #[cfg(feature = "unstable-pac")] | 86 | #[cfg(feature = "unstable-pac")] |
| @@ -91,6 +93,10 @@ pub struct Config { | |||
| 91 | pub rcc: rcc::Config, | 93 | pub rcc: rcc::Config, |
| 92 | #[cfg(dbgmcu)] | 94 | #[cfg(dbgmcu)] |
| 93 | pub enable_debug_during_sleep: bool, | 95 | pub enable_debug_during_sleep: bool, |
| 96 | #[cfg(bdma)] | ||
| 97 | pub bdma_interrupt_priority: Priority, | ||
| 98 | #[cfg(dma)] | ||
| 99 | pub dma_interrupt_priority: Priority, | ||
| 94 | } | 100 | } |
| 95 | 101 | ||
| 96 | impl Default for Config { | 102 | impl Default for Config { |
| @@ -99,6 +105,10 @@ impl Default for Config { | |||
| 99 | rcc: Default::default(), | 105 | rcc: Default::default(), |
| 100 | #[cfg(dbgmcu)] | 106 | #[cfg(dbgmcu)] |
| 101 | enable_debug_during_sleep: true, | 107 | enable_debug_during_sleep: true, |
| 108 | #[cfg(bdma)] | ||
| 109 | bdma_interrupt_priority: Priority::P0, | ||
| 110 | #[cfg(dma)] | ||
| 111 | dma_interrupt_priority: Priority::P0, | ||
| 102 | } | 112 | } |
| 103 | } | 113 | } |
| 104 | } | 114 | } |
| @@ -137,7 +147,12 @@ pub fn init(config: Config) -> Peripherals { | |||
| 137 | } | 147 | } |
| 138 | 148 | ||
| 139 | gpio::init(); | 149 | gpio::init(); |
| 140 | dma::init(); | 150 | dma::init( |
| 151 | #[cfg(bdma)] | ||
| 152 | config.bdma_interrupt_priority, | ||
| 153 | #[cfg(dma)] | ||
| 154 | config.dma_interrupt_priority, | ||
| 155 | ); | ||
| 141 | #[cfg(feature = "exti")] | 156 | #[cfg(feature = "exti")] |
| 142 | exti::init(); | 157 | exti::init(); |
| 143 | 158 | ||
