Commit Graph

10 Commits

Author SHA1 Message Date
Liam Murphy
4d9514cbcb Don't allow disabling interrupts wrapped by PeripheralMutex 2021-07-28 21:39:31 +10:00
Liam Murphy
68c93256bc fix: interrupts with equal priority can't preempt each other 2021-07-28 21:31:31 +10:00
Liam Murphy
079526559f Remove critical sections from PeripheralMutex interrupt handler by checking the interrupt's priority on startup.
Since `PeripheralMutex` is the only way to safely maintain state across interrupts, and it no longer allows setting the interrupt's priority, the priority changing isn't a concern.

This also prevents other causes of UB due to the interrupt being exposed during `with`, and allowing enabling the interrupt and setting its context to a bogus pointer.
2021-07-27 17:28:52 +10:00
Liam Murphy
1b7ad7080e Add Send/Sync bounds to PeripheralState 2021-07-24 12:53:57 +10:00
Liam Murphy
fc1ef4947d Fix stm32 ethernet 2021-07-05 18:18:05 +10:00
Liam Murphy
744e2cbb8a extras: Fix UB in Peripheral
`Peripheral` assumed that interrupts can't be preempted,
when they can be preempted by higher priority interrupts.
So I put the interrupt handler inside a critical section,
and also added checks for whether the state had been dropped
before the critical section was entered.

I also added a `'static` bound to `PeripheralState`,
since `Pin` only guarantees that the memory it directly references
will not be invalidated.
It doesn't guarantee that memory its pointee references also won't be invalidated.

There were already some implementations of `PeripheralState`
that weren't `'static`, though,
so I added an unsafe `PeripheralStateUnchecked` trait
and forwarded the `unsafe` to the constructors of the implementors.
2021-07-05 17:42:43 +10:00
Dario Nieuwenhuis
4ce46df160 Code size optimizations. 2021-03-29 00:58:58 +02:00
Dario Nieuwenhuis
b57489eb5d peripheralmutex: separate interrupt registration to own method. 2021-03-18 18:49:10 +01:00
Dario Nieuwenhuis
0cd19a58c3 Remove free() from PeripheralMutex and all nrf drivers. 2021-03-18 18:49:10 +01:00
Thales Fragoso
15c3e78408 Move nRF's util into a separate crate 2021-03-07 20:15:40 -03:00