diff options
| author | Dario Nieuwenhuis <[email protected]> | 2023-10-12 14:29:23 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-10-12 14:29:23 +0000 |
| commit | debda2f52c320904755d89ef9c19fa6e54734fe8 (patch) | |
| tree | 20f7a2f1e27e0d30e530047e819b6efeaf2bd9cc /embassy-stm32/src/dma | |
| parent | 66e399b5c61653f1f66cd3fd1592936e4085d6b5 (diff) | |
| parent | 97ca0e77bf6e6f36aae18cb57fbfa8e583597327 (diff) | |
Merge pull request #2045 from embassy-rs/stm32-cs-spam
Avoid creating many tiny critical sections in embassy-stm32::init
Diffstat (limited to 'embassy-stm32/src/dma')
| -rw-r--r-- | embassy-stm32/src/dma/bdma.rs | 4 | ||||
| -rw-r--r-- | embassy-stm32/src/dma/dma.rs | 4 | ||||
| -rw-r--r-- | embassy-stm32/src/dma/dmamux.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32/src/dma/gpdma.rs | 4 | ||||
| -rw-r--r-- | embassy-stm32/src/dma/mod.rs | 9 |
5 files changed, 12 insertions, 11 deletions
diff --git a/embassy-stm32/src/dma/bdma.rs b/embassy-stm32/src/dma/bdma.rs index 62eb65b1c..a7422f66b 100644 --- a/embassy-stm32/src/dma/bdma.rs +++ b/embassy-stm32/src/dma/bdma.rs | |||
| @@ -77,10 +77,10 @@ impl State { | |||
| 77 | static STATE: State = State::new(); | 77 | static STATE: State = State::new(); |
| 78 | 78 | ||
| 79 | /// safety: must be called only once | 79 | /// safety: must be called only once |
| 80 | pub(crate) unsafe fn init(irq_priority: Priority) { | 80 | pub(crate) unsafe fn init(cs: critical_section::CriticalSection, irq_priority: Priority) { |
| 81 | foreach_interrupt! { | 81 | foreach_interrupt! { |
| 82 | ($peri:ident, bdma, $block:ident, $signal_name:ident, $irq:ident) => { | 82 | ($peri:ident, bdma, $block:ident, $signal_name:ident, $irq:ident) => { |
| 83 | crate::interrupt::typelevel::$irq::set_priority(irq_priority); | 83 | crate::interrupt::typelevel::$irq::set_priority_with_cs(cs, irq_priority); |
| 84 | crate::interrupt::typelevel::$irq::enable(); | 84 | crate::interrupt::typelevel::$irq::enable(); |
| 85 | }; | 85 | }; |
| 86 | } | 86 | } |
diff --git a/embassy-stm32/src/dma/dma.rs b/embassy-stm32/src/dma/dma.rs index 5033ae477..cce0407c1 100644 --- a/embassy-stm32/src/dma/dma.rs +++ b/embassy-stm32/src/dma/dma.rs | |||
| @@ -154,10 +154,10 @@ impl State { | |||
| 154 | static STATE: State = State::new(); | 154 | static STATE: State = State::new(); |
| 155 | 155 | ||
| 156 | /// safety: must be called only once | 156 | /// safety: must be called only once |
| 157 | pub(crate) unsafe fn init(irq_priority: Priority) { | 157 | pub(crate) unsafe fn init(cs: critical_section::CriticalSection, irq_priority: Priority) { |
| 158 | foreach_interrupt! { | 158 | foreach_interrupt! { |
| 159 | ($peri:ident, dma, $block:ident, $signal_name:ident, $irq:ident) => { | 159 | ($peri:ident, dma, $block:ident, $signal_name:ident, $irq:ident) => { |
| 160 | interrupt::typelevel::$irq::set_priority(irq_priority); | 160 | interrupt::typelevel::$irq::set_priority_with_cs(cs, irq_priority); |
| 161 | interrupt::typelevel::$irq::enable(); | 161 | interrupt::typelevel::$irq::enable(); |
| 162 | }; | 162 | }; |
| 163 | } | 163 | } |
diff --git a/embassy-stm32/src/dma/dmamux.rs b/embassy-stm32/src/dma/dmamux.rs index 36fc03403..20601dc86 100644 --- a/embassy-stm32/src/dma/dmamux.rs +++ b/embassy-stm32/src/dma/dmamux.rs | |||
| @@ -47,6 +47,6 @@ foreach_dma_channel! { | |||
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | /// safety: must be called only once | 49 | /// safety: must be called only once |
| 50 | pub(crate) unsafe fn init() { | 50 | pub(crate) unsafe fn init(_cs: critical_section::CriticalSection) { |
| 51 | crate::_generated::init_dmamux(); | 51 | crate::_generated::init_dmamux(); |
| 52 | } | 52 | } |
diff --git a/embassy-stm32/src/dma/gpdma.rs b/embassy-stm32/src/dma/gpdma.rs index 97cc200d7..b811da1fb 100644 --- a/embassy-stm32/src/dma/gpdma.rs +++ b/embassy-stm32/src/dma/gpdma.rs | |||
| @@ -53,10 +53,10 @@ impl State { | |||
| 53 | static STATE: State = State::new(); | 53 | static STATE: State = State::new(); |
| 54 | 54 | ||
| 55 | /// safety: must be called only once | 55 | /// safety: must be called only once |
| 56 | pub(crate) unsafe fn init(irq_priority: Priority) { | 56 | pub(crate) unsafe fn init(cs: critical_section::CriticalSection, irq_priority: Priority) { |
| 57 | foreach_interrupt! { | 57 | foreach_interrupt! { |
| 58 | ($peri:ident, gpdma, $block:ident, $signal_name:ident, $irq:ident) => { | 58 | ($peri:ident, gpdma, $block:ident, $signal_name:ident, $irq:ident) => { |
| 59 | crate::interrupt::typelevel::$irq::set_priority(irq_priority); | 59 | crate::interrupt::typelevel::$irq::set_priority_with_cs(cs, irq_priority); |
| 60 | crate::interrupt::typelevel::$irq::enable(); | 60 | crate::interrupt::typelevel::$irq::enable(); |
| 61 | }; | 61 | }; |
| 62 | } | 62 | } |
diff --git a/embassy-stm32/src/dma/mod.rs b/embassy-stm32/src/dma/mod.rs index 4f1a58ae2..29fced8fc 100644 --- a/embassy-stm32/src/dma/mod.rs +++ b/embassy-stm32/src/dma/mod.rs | |||
| @@ -56,16 +56,17 @@ pub(crate) fn slice_ptr_parts_mut<T>(slice: *mut [T]) -> (usize, usize) { | |||
| 56 | 56 | ||
| 57 | // safety: must be called only once at startup | 57 | // safety: must be called only once at startup |
| 58 | pub(crate) unsafe fn init( | 58 | pub(crate) unsafe fn init( |
| 59 | cs: critical_section::CriticalSection, | ||
| 59 | #[cfg(bdma)] bdma_priority: Priority, | 60 | #[cfg(bdma)] bdma_priority: Priority, |
| 60 | #[cfg(dma)] dma_priority: Priority, | 61 | #[cfg(dma)] dma_priority: Priority, |
| 61 | #[cfg(gpdma)] gpdma_priority: Priority, | 62 | #[cfg(gpdma)] gpdma_priority: Priority, |
| 62 | ) { | 63 | ) { |
| 63 | #[cfg(bdma)] | 64 | #[cfg(bdma)] |
| 64 | bdma::init(bdma_priority); | 65 | bdma::init(cs, bdma_priority); |
| 65 | #[cfg(dma)] | 66 | #[cfg(dma)] |
| 66 | dma::init(dma_priority); | 67 | dma::init(cs, dma_priority); |
| 67 | #[cfg(gpdma)] | 68 | #[cfg(gpdma)] |
| 68 | gpdma::init(gpdma_priority); | 69 | gpdma::init(cs, gpdma_priority); |
| 69 | #[cfg(dmamux)] | 70 | #[cfg(dmamux)] |
| 70 | dmamux::init(); | 71 | dmamux::init(cs); |
| 71 | } | 72 | } |
