Commit Graph

85 Commits

Author SHA1 Message Date
Dario Nieuwenhuis
af87031d62 hal-common: remove Pin in PeripheralMutex 2021-08-02 19:55:04 +02:00
Dario Nieuwenhuis
7bfb763e09 Rename embassy-extras to embassy-hal-common 2021-07-29 13:44:51 +02:00
Liam Murphy
d5ba35424d Replace PeripheralStateUnchecked with register_interrupt_unchecked 2021-07-29 15:11:26 +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
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
Liam Murphy
e7addf094b Fix Cc::wait never resolving and refactor some APIs
I think the interrupt was getting immediately re-triggered as soon as the handler exited, so I disabled the interrupt in the handler.
2021-06-29 10:33:41 +10:00
Liam Murphy
02781ed744 Add an nRF Timer driver
Resolves #189
2021-06-26 17:58:36 +10:00
Dario Nieuwenhuis
d1eeef5864 nrf/buffered_uarte: Fix crash when calling set_baudrate as the very first thing. 2021-06-08 00:32:14 +02:00
Dario Nieuwenhuis
e7dc5c0939 fmt: make all macros macro_rules so scoping is consistent. 2021-06-07 00:16:39 +02:00
Rukai
3e83acc1cb Fix unused field warnings 2021-05-17 20:23:04 +10:00
Dario Nieuwenhuis
97ca54fa66 Rename PeripheralBorrow to Unborrow 2021-04-14 19:59:52 +02:00
Dario Nieuwenhuis
59ccc45f28 Remove pin from Uart 2021-04-14 17:04:40 +02:00
Dario Nieuwenhuis
3a18373828 nrf/uarte: update BufferedUarte to new APi 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
Timo Kröger
28b2365ef3 Update nrf-hal to v0.12.1
Use the `psel_bits()` method to reduce #[cfg] clutter
2021-03-05 09:25:46 +01:00
Dario Nieuwenhuis
45355f184a move most interrupt methods to InterruptExt extension trait. Fixes #35 2021-03-01 00:44:38 +01:00
Dario Nieuwenhuis
11be9170ec Cleanup interrupt package naming. Fixes #40
The `interrupt` package previously tried to be drop-in compatible with the
`interrupt` package from PACs. THis meant that there was both a PAC-style enum
value `UARTE0` and an embassy-style owned `UARTE0Interrupt` type. This made
things VERY confusing.

This drops compatibility with the PAC, improving the names for embassy interrupts.
2021-02-26 01:55:27 +01:00
Thales Fragoso
b69f72e055 Get rid of some warnings 2021-02-13 21:41:36 -03:00
Dario Nieuwenhuis
7b94e06306 nrf/buffered_uarte: fix stop not actually waiting for stop 2021-01-11 11:24:34 +01:00
Dario Nieuwenhuis
41160c0d8d nrf/buffered_uarte: add set_baudrate 2021-01-11 10:40:37 +01:00
Dario Nieuwenhuis
2616467377 nrf/buffered_uarte: stop on drop, add free() 2021-01-11 10:39:59 +01:00
Dario Nieuwenhuis
e18d71dedc Fix build on nrf52832 2021-01-07 00:50:40 +01:00
Dario Nieuwenhuis
5b10ac9cac Add PPI+TIMER to buffered_uarte to prevent IRQ storm 2021-01-06 23:36:46 +01:00
Dario Nieuwenhuis
deb3c93892 Simpliify PeripheralMutex a bit. 2021-01-06 22:48:54 +01:00
Dario Nieuwenhuis
77bdb5428e buffered_uarte naming cleanup 2021-01-06 20:21:03 +01:00
Dario Nieuwenhuis
607e67f51a Cleanup BufferedUarte 2021-01-05 21:14:04 +01:00
Dario Nieuwenhuis
3a4dbfa52e Massicely simplify peripheral abstraction 2021-01-05 01:57:05 +01:00
Dario Nieuwenhuis
39ca8b8ded Fix build on non-nrf52840 2021-01-03 22:30:47 +01:00
Dario Nieuwenhuis
ace4f40f80 Introduce "peripheral" abstraction to share state between main and interrupt. 2021-01-03 01:40:40 +01:00
Dario Nieuwenhuis
4ce51795f2 use hal::Pins for BufferedUarte 2021-01-02 20:31:50 +01:00
Dario Nieuwenhuis
4783222f67 Rename WakerStore -> WakerRegistration. 2021-01-01 22:30:11 +01:00
Dario Nieuwenhuis
af5454fbfe Update drivers to owned irqs. 2020-12-29 01:53:17 +01:00
Dario Nieuwenhuis
267ec334ac Rename Uarte -> BufferedUarte 2020-12-28 23:57:50 +01:00