Commit Graph

89 Commits

Author SHA1 Message Date
Dario Nieuwenhuis
456e04c79f Simplify spim macros 2021-03-18 21:59:35 +01: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
Dario Nieuwenhuis
f248bb17ad Allow unused stuff in fmt.rs 2021-03-18 01:42:28 +01:00
Dario Nieuwenhuis
3de2d5c5bd Implement FullDuplex for nrf spim 2021-03-18 01:27:30 +01:00
Dario Nieuwenhuis
a9076636ac Do not export fmt macros.
This was introduced by accident by me struggling with the weird intra-crate macro importing system...
2021-03-17 22:50:27 +01:00
Dario Nieuwenhuis
6ed1a87138 Update features for latest nightly. 2021-03-17 02:48:16 +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
d4f2c6cf00 Remove cargo namespaced-features 2021-03-02 21:15:12 +01:00
xoviat
9626aee7db Move traits to separate crate. 2021-03-02 00:32:23 +01:00
Dario Nieuwenhuis
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
Dario Nieuwenhuis
45355f184a move most interrupt methods to InterruptExt extension trait. Fixes #35 2021-03-01 00:44:38 +01:00
Dario Nieuwenhuis
a30c705fd7 nrf/spim: support all chips 2021-03-01 00:36:30 +01:00
Dario Nieuwenhuis
255bf1aa6a nrf: add SPIM 2021-03-01 00:24:06 +01:00
Dario Nieuwenhuis
8a641d1312 Fix warnings. 2021-03-01 00:23:54 +01:00
Dario Nieuwenhuis
7433dc1039 Port qspi to PeripheralMutex 2021-02-28 22:05:37 +01:00
Dario Nieuwenhuis
962fb95ff0 Optimize PeripheralMutex code size 2021-02-28 22:03:45 +01:00
Dario Nieuwenhuis
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
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
Dario Nieuwenhuis
90476ef900 Fix some warnings. 2021-02-26 01:06:58 +01:00
fnafnio
f779ec4928 update defmt and defmt-rtt to 0.2.0 2021-02-24 08:44:23 +01:00
Dario Nieuwenhuis
67c03e1a38
Merge pull request #47 from akiles/simpler-rtc
SImplify rtc overflow handling
2021-02-20 01:51:53 +01:00
Dario Nieuwenhuis
91aaea761e Use Relaxed atomics with fence instead of SeqCst 2021-02-20 01:43:10 +01:00
Dario Nieuwenhuis
03ddc949a0 PeripheralMutex should be Unpin 2021-02-20 00:27:24 +01:00
Dario Nieuwenhuis
406f3b7cbf rtc: use SeqCst for periods. 2021-02-15 01:23:15 +01:00
Dario Nieuwenhuis
9d5e2d3881 SImplify rtc overflow handling 2021-02-15 01:01:45 +01:00
Dario Nieuwenhuis
7321ddb0b3 Update to cortex-m 0.7 2021-02-14 23:26:50 +01:00
Thales Fragoso
b69f72e055 Get rid of some warnings 2021-02-13 21:41:36 -03:00
Dario Nieuwenhuis
a7797a918d nrf/gpiote: new api: switch to owned structs, implement WaitForHigh/WaitForLow. 2021-02-04 23:56:17 +01:00
Dario Nieuwenhuis
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
Dario Nieuwenhuis
6963b314a2 nrf/rtc: fix race when setting alarms too close to now. 2021-01-13 03:17:58 +01:00
Dario Nieuwenhuis
5229a1991c nrf/rtc: use interrupt handler context for instance ptr 2021-01-13 03:17:42 +01: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
9bb4c97dc2
Merge pull request #14 from timokroeger/uarte-power-optimization
UARTE power optimization and improvements
2021-01-05 22:10:52 +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
Timo Kröger
0631623b51 uarte: Low power wait for RX drop 2021-01-04 22:55:40 +01:00
Timo Kröger
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
Timo Kröger
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
Timo Kröger
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
Timo Kröger
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
Timo Kröger
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
Timo Kröger
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