Commit Graph

113 Commits

Author SHA1 Message Date
496ad4ed43 Rationale for uarte usage 2021-12-01 09:37:09 +11:00
469852c667 Removed unsafe from uarte
The constructors themselves are not strictly unsafe. Interactions with DMA can be generally unsafe if a future is dropped, but that's a separate issue. It is important that we use the `unsafe` keyword diligently as it can lead to confusion otherwise.
2021-12-01 09:14:24 +11:00
c995a97f20 nrf91: support running in both S and NS mode. 2021-10-26 17:40:07 +02:00
c63d747209 Fewer channel traits, more cfg to make the system work 2021-10-26 14:47:34 +02:00
a6c84cb915 - Interconnect is now PPI again
- Scary pointer math is now contained in the tasks and events
- ppi now sets the tasks and events immediately and the struct is now zero-sized
- StaticToOne is renamed to ZeroToOne
- Used DPPI tasks and events now panic when enabled twice
2021-10-26 14:47:31 +02:00
11655af034 Another redo using the feedback.
PPI is now split up into PPI and DPPI under the name 'interconnect'.
The tasks and events are tracked and reset in the drop function.
2021-10-26 14:47:12 +02:00
e6ec81b999 Fixed examples and added defmt format to the new error types 2021-10-26 14:46:39 +02:00
65628e1f15 - Added _ppi and _dppi to distinguish between the new and the old peripheral.
- Removed ConfigurableChannel and added capacity numbers to the channels
- Replaced the PPI api with a new one using the DPPI terminology (publish & subscribe)
- Updated all tasks and event registers for DPPI
2021-10-26 14:46:39 +02:00
66d70cd146 nrf/uarte: do not use WFE on drop.
- It disturbs other stuff that uses WFE/SEV in the system. I ran into
  issues with this.
- It needs the irq handler to check for RXTO/TXSTOPPED errors, which makes
  it slower.
2021-10-16 03:14:47 +02:00
c1c704bfc8 - Removed the enable assert from UARTE.
- Added nRF9160 to CI.
2021-10-13 15:00:08 +02:00
ddcee446c1 Added anomaly workaround from the HAL to improve the UARTE 2021-10-12 13:35:08 +02:00
2c2c284482 Undoing unnecessary changes 2021-10-12 11:55:38 +02:00
20674f7126 Initial support for nrf9160 2021-10-11 10:39:38 +02:00
ead987245d embassy: Refactor module structure to remove kitchen-sink util. 2021-09-11 02:35:35 +02:00
34c66fa78d removed type aliases
NotAwaitable as default generic param
added awaitable_timer example
2021-09-02 12:02:31 +02:00
a0c40562ea added typestate to nrf-Timer
useful for hooking up the PPI to an Event without needing interrupt
tested with buffered_uart example on nRF52840-DK
2021-09-01 16:16:56 +02:00
7bfb763e09 Rename embassy-extras to embassy-hal-common 2021-07-29 13:44:51 +02:00
1b7ad7080e Add Send/Sync bounds to PeripheralState 2021-07-24 12:53:57 +10:00
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
02781ed744 Add an nRF Timer driver
Resolves #189
2021-06-26 17:58:36 +10:00
e7dc5c0939 fmt: make all macros macro_rules so scoping is consistent. 2021-06-07 00:16:39 +02:00
39c420733f nrf/uarte: deconfigure pins on drop 2021-05-26 20:11:23 +02:00
149ddf2f29 Fix warnings 2021-05-17 19:48:58 +10:00
a5ad79927e nrf: add Unborrow<Target = Self> bound to all instance traits 2021-05-17 01:01:31 +02:00
bd9589d0ce nrf: add support for nrf52805, nrf52811, nrf52820 2021-05-17 00:57:20 +02:00
0a3c236510 Improve comment 2021-05-10 23:06:25 +02:00
e9eb3ce6c1 Disable PPI trigger during normal read 2021-05-10 23:06:25 +02:00
687dda106f Read rx amount outside of poll_fn 2021-05-10 23:06:25 +02:00
5afe01617a Use rxdrdy as trigger for timer 2021-05-10 23:06:25 +02:00
dda338cedb Add implementation of ReadUntilIdle for nRF UART
Add type UarteWithIdle that implements Read, Write and ReadUntilIdle
traits. The type uses a timer + 2 PPI channels internally, triggered on
RTXSTARTED event.
2021-05-10 23:06:25 +02:00
97ca54fa66 Rename PeripheralBorrow to Unborrow 2021-04-14 19:59:52 +02:00
59ccc45f28 Remove pin from Uart 2021-04-14 17:04:40 +02:00
b9e709403d nrf: better macro naming. 2021-03-29 00:58:58 +02:00
aa0341056e nrf/uarte: deal with hwfc correctly 2021-03-29 00:58:58 +02:00
3eccddc44d nrf/uarte: use rxstarted/txstarted events to track whether a wait for stop is necessary on drop. 2021-03-29 00:58:58 +02:00
7a41541ab2 nrf/uarte: use Peripheral, wait for stop on drop. 2021-03-29 00:58:58 +02:00
a0511e6caa nrf/uart: make rts/cts optional. 2021-03-29 00:58:58 +02:00
df42c38492 nrf/uarte: update to new api 2021-03-29 00:58:58 +02:00
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
9626aee7db Move traits to separate crate. 2021-03-02 00:32:23 +01:00
45355f184a move most interrupt methods to InterruptExt extension trait. Fixes #35 2021-03-01 00:44:38 +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
9bb4c97dc2 Merge pull request #14 from timokroeger/uarte-power-optimization
UARTE power optimization and improvements
2021-01-05 22:10:52 +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