diff options
| author | xoviat <[email protected]> | 2025-12-16 10:55:54 -0600 |
|---|---|---|
| committer | xoviat <[email protected]> | 2025-12-16 10:55:54 -0600 |
| commit | 8fd8ba633a6d8113e136f2f46b1accfe9fb9f1f0 (patch) | |
| tree | f21ce64335ec1d453ddf57cc47136c9b9b45ce2c /embassy-stm32/src/hsem | |
| parent | cf2bbdd9138430fe401a3bcef1a3c9afef851652 (diff) | |
stm32: fix wb stop entry and hsem logic
Diffstat (limited to 'embassy-stm32/src/hsem')
| -rw-r--r-- | embassy-stm32/src/hsem/mod.rs | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/embassy-stm32/src/hsem/mod.rs b/embassy-stm32/src/hsem/mod.rs index b5fa3c897..e5c68acbd 100644 --- a/embassy-stm32/src/hsem/mod.rs +++ b/embassy-stm32/src/hsem/mod.rs | |||
| @@ -94,17 +94,14 @@ pub struct HardwareSemaphoreInterruptHandler<T: Instance> { | |||
| 94 | impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for HardwareSemaphoreInterruptHandler<T> { | 94 | impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for HardwareSemaphoreInterruptHandler<T> { |
| 95 | unsafe fn on_interrupt() { | 95 | unsafe fn on_interrupt() { |
| 96 | let core_id = CoreId::current(); | 96 | let core_id = CoreId::current(); |
| 97 | let isr = T::regs().isr(core_id.to_index()).read(); | ||
| 97 | 98 | ||
| 98 | for number in 0..5 { | 99 | for number in 0..5 { |
| 99 | if T::regs().isr(core_id.to_index()).read().isf(number as usize) { | 100 | if isr.isf(number as usize) { |
| 100 | T::regs() | 101 | T::regs() |
| 101 | .icr(core_id.to_index()) | 102 | .icr(core_id.to_index()) |
| 102 | .write(|w| w.set_isc(number as usize, true)); | 103 | .write(|w| w.set_isc(number as usize, true)); |
| 103 | 104 | ||
| 104 | T::regs() | ||
| 105 | .ier(core_id.to_index()) | ||
| 106 | .modify(|w| w.set_ise(number as usize, false)); | ||
| 107 | |||
| 108 | T::state().waker_for(number).wake(); | 105 | T::state().waker_for(number).wake(); |
| 109 | } | 106 | } |
| 110 | } | 107 | } |
| @@ -120,6 +117,18 @@ pub struct HardwareSemaphoreMutex<'a, T: Instance> { | |||
| 120 | 117 | ||
| 121 | impl<'a, T: Instance> Drop for HardwareSemaphoreMutex<'a, T> { | 118 | impl<'a, T: Instance> Drop for HardwareSemaphoreMutex<'a, T> { |
| 122 | fn drop(&mut self) { | 119 | fn drop(&mut self) { |
| 120 | let core_id = CoreId::current(); | ||
| 121 | |||
| 122 | T::regs() | ||
| 123 | .icr(core_id.to_index()) | ||
| 124 | .write(|w| w.set_isc(self.index as usize, true)); | ||
| 125 | |||
| 126 | critical_section::with(|_| { | ||
| 127 | T::regs() | ||
| 128 | .ier(core_id.to_index()) | ||
| 129 | .modify(|w| w.set_ise(self.index as usize, false)); | ||
| 130 | }); | ||
| 131 | |||
| 123 | HardwareSemaphoreChannel::<'a, T> { | 132 | HardwareSemaphoreChannel::<'a, T> { |
| 124 | index: self.index, | 133 | index: self.index, |
| 125 | _lifetime: PhantomData, | 134 | _lifetime: PhantomData, |
| @@ -156,9 +165,11 @@ impl<'a, T: Instance> HardwareSemaphoreChannel<'a, T> { | |||
| 156 | 165 | ||
| 157 | compiler_fence(Ordering::SeqCst); | 166 | compiler_fence(Ordering::SeqCst); |
| 158 | 167 | ||
| 159 | T::regs() | 168 | critical_section::with(|_| { |
| 160 | .ier(core_id.to_index()) | 169 | T::regs() |
| 161 | .modify(|w| w.set_ise(self.index as usize, true)); | 170 | .ier(core_id.to_index()) |
| 171 | .modify(|w| w.set_ise(self.index as usize, true)); | ||
| 172 | }); | ||
| 162 | 173 | ||
| 163 | match self.try_lock(process_id) { | 174 | match self.try_lock(process_id) { |
| 164 | Some(mutex) => Poll::Ready(mutex), | 175 | Some(mutex) => Poll::Ready(mutex), |
