Commit Graph

682 Commits

Author SHA1 Message Date
15c3e78408 Move nRF's util into a separate crate 2021-03-07 20:15:40 -03:00
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
d4f2c6cf00 Remove cargo namespaced-features 2021-03-02 21:15:12 +01:00
9626aee7db Move traits to separate crate. 2021-03-02 00:32:23 +01:00
67a6c4f469 Merge pull request #59 from akiles/interrupt_ext
move most interrupt methods to InterruptExt extension trait. Fixes #35
2021-03-01 00:56:20 +01:00
45355f184a move most interrupt methods to InterruptExt extension trait. Fixes #35 2021-03-01 00:44:38 +01:00
a30c705fd7 nrf/spim: support all chips 2021-03-01 00:36:30 +01:00
255bf1aa6a nrf: add SPIM 2021-03-01 00:24:06 +01:00
8a641d1312 Fix warnings. 2021-03-01 00:23:54 +01:00
7433dc1039 Port qspi to PeripheralMutex 2021-02-28 22:05:37 +01:00
962fb95ff0 Optimize PeripheralMutex code size 2021-02-28 22:03:45 +01:00
da91779117 interrupt: Split set_handler context.
Since introducing the ctx pointer, the handler is now two words, so setting it can
race with the interrupt firing. On race it's possible for the new handler to be
alled with the old ctx pointer or viceversa.

Rather than documenting this, it's better to split the function in two to make it
obvious to the user that it's not atomic. The user can use a critical section, or
disable/enable the interrupt to avoid races if this is a concern.
2021-02-26 02:04:48 +01:00
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
90476ef900 Fix some warnings. 2021-02-26 01:06:58 +01:00
f779ec4928 update defmt and defmt-rtt to 0.2.0 2021-02-24 08:44:23 +01:00
67c03e1a38 Merge pull request #47 from akiles/simpler-rtc
SImplify rtc overflow handling
2021-02-20 01:51:53 +01:00
91aaea761e Use Relaxed atomics with fence instead of SeqCst 2021-02-20 01:43:10 +01:00
03ddc949a0 PeripheralMutex should be Unpin 2021-02-20 00:27:24 +01:00
406f3b7cbf rtc: use SeqCst for periods. 2021-02-15 01:23:15 +01:00
9d5e2d3881 SImplify rtc overflow handling 2021-02-15 01:01:45 +01:00
7321ddb0b3 Update to cortex-m 0.7 2021-02-14 23:26:50 +01:00
b69f72e055 Get rid of some warnings 2021-02-13 21:41:36 -03:00
a7797a918d nrf/gpiote: new api: switch to owned structs, implement WaitForHigh/WaitForLow. 2021-02-04 23:56:17 +01:00
aeaa34d7a1 Executor API V2.
- It's no longer possible to call run() reentrantly from within a task (soundness issue)
- it's now possible to spawn Send tasks across threads (SendSpawner, #37)
2021-02-02 05:20:41 +01:00
6963b314a2 nrf/rtc: fix race when setting alarms too close to now. 2021-01-13 03:17:58 +01:00
5229a1991c nrf/rtc: use interrupt handler context for instance ptr 2021-01-13 03:17:42 +01:00
7b94e06306 nrf/buffered_uarte: fix stop not actually waiting for stop 2021-01-11 11:24:34 +01:00
41160c0d8d nrf/buffered_uarte: add set_baudrate 2021-01-11 10:40:37 +01:00
2616467377 nrf/buffered_uarte: stop on drop, add free() 2021-01-11 10:39:59 +01:00
e18d71dedc Fix build on nrf52832 2021-01-07 00:50:40 +01:00
5b10ac9cac Add PPI+TIMER to buffered_uarte to prevent IRQ storm 2021-01-06 23:36:46 +01:00
deb3c93892 Simpliify PeripheralMutex a bit. 2021-01-06 22:48:54 +01:00
77bdb5428e buffered_uarte naming cleanup 2021-01-06 20:21:03 +01:00
9bb4c97dc2 Merge pull request #14 from timokroeger/uarte-power-optimization
UARTE power optimization and improvements
2021-01-05 22:10:52 +01:00
607e67f51a Cleanup BufferedUarte 2021-01-05 21:14:04 +01:00
3a4dbfa52e Massicely simplify peripheral abstraction 2021-01-05 01:57:05 +01:00
0631623b51 uarte: Low power wait for RX drop 2021-01-04 22:55:40 +01:00
93780fa31d uarte: Wait for the peripheral to be disabled
Prevents a panic in the case of:
1. Abort a receive future
2. Free Uarte::free()
3. Uarte::new()
->  panicked at 'assertion failed: uarte.enable.read().enable().is_disabled()'
2021-01-04 22:55:40 +01:00
9b1f7b8a17 uarte: Enable peripheral with first poll
This fixes a lockup when a future is dropped before it was polled.
2021-01-04 22:55:40 +01:00
85ec9dd16f uarte: Be on safe side with potentially racy code
The PS does not specify how many cycles it takes for a STARTXX task to
generate a XXSTARTED event. I think it is instantaneous but let’s be on
the safe side for the following sequence:
1. poll() starttx
2. drop() txstarted not yet set, but future gets dropped
3. txstarted set by hardware, peripheral enabled after it was dropped
2021-01-04 22:55:40 +01:00
a3b3305b8e uarte: Only stop TX forcefully when a transmissions is running
This comes with insignificant power consumption improvements but makes
the code of the RX and TX case symmetric.
2021-01-04 22:55:40 +01:00
a7c03e4cb6 uarte: Only stop RX forcefully when a reception is running
The STOPRX task always triggers a timeout of ~55bit times until the
RXTO event is generated. Before we disabled the receiver only after
the timeout.
With this change the receiver is stopped right after reception has ended
because the DMA buffer is full.
For forced RX aborts like `stop()` or on drop still need to wait for the
RXTO event before disabling the receiver.
2021-01-04 22:55:40 +01:00
9f28c7ab8d uarte: Do not spin when stopping a receive future
Spinning on drop() is still required when the future has not been
stopped so that DMA finishes before the buffer is released.
2021-01-04 22:55:40 +01:00
9e88718fbd Add "context" pointer to owned interrupt handlers. 2021-01-04 22:25:39 +01:00
39ca8b8ded Fix build on non-nrf52840 2021-01-03 22:30:47 +01:00
ace4f40f80 Introduce "peripheral" abstraction to share state between main and interrupt. 2021-01-03 01:40:40 +01:00
4ce51795f2 use hal::Pins for BufferedUarte 2021-01-02 20:31:50 +01:00
0ab88ea279 Add Uart trait, implement it for nrf. 2021-01-02 19:59:37 +01:00
3c7e7220b3 Don't use embedded_dma in nrf uarte. 2021-01-02 19:14:54 +01:00
4783222f67 Rename WakerStore -> WakerRegistration. 2021-01-01 22:30:11 +01:00