Commit Graph

82 Commits

Author SHA1 Message Date
Dario Nieuwenhuis
9bad9365dc Update rust nightly, embedded-hal 1.0, embedded-hal-async. 2022-03-11 00:38:07 +01:00
Til Blechschmidt
63030bf998
Move EasyDMA documentation to module level 2022-03-08 17:49:15 +01:00
Til Blechschmidt
993428e2d4
Refactor _from_ram methods to use more readable copy operation 2022-03-02 22:48:58 +01:00
Til Blechschmidt
2c402ecf16
Change UARTE methods to copy slice if required and add non-copying variants 2022-03-02 22:40:40 +01:00
bors[bot]
e728a32672
Merge #613
613: Rust stable support r=Dirbaio a=Dirbaio

This PR adds (limited) stable Rust support!

The drawbacks are: 

- No `#[embassy::task]`, `#[embassy::main]`. (requires `type_alias_impl_trait`). You have to manually allocate the tasks somewhere they'll live forever. See [example](https://github.com/embassy-rs/embassy/blob/master/examples/nrf/src/bin/raw_spawn.rs)
- No async trait impls (requires GATs). Note that the full API surface of HALs is still available through inherent methods: #552 #581 
- Some stuff is not constructible in const (requires `const_fn_trait_bound`), although there's an (ugly) workaround for the generic `Mutex`.

So it's not that bad in the end, it's fully usable for shipping production-ready firmwares. We'll still recommend nightly as the default, until GATs and `type_alias_impl_trait` are stable.

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2022-02-12 00:30:47 +00:00
Dario Nieuwenhuis
20e14b8edb embassy, embassy-nrf: add nightly Cargo feature to gate nightly-only features. 2022-02-12 01:16:31 +01:00
Dario Nieuwenhuis
6de02bb23e nrf: remove OptionalPin 2022-02-12 01:07:02 +01:00
Dario Nieuwenhuis
7997687f3b nrf: impl embedded-hal 1.0 and embedded-hal-async traits. 2022-01-13 23:56:39 +01:00
Dario Nieuwenhuis
3e503e7335 nrf/uarte: expose all functionality as inherent methods. 2022-01-13 23:56:39 +01:00
huntc
c54303be75 Makes the uarte endtx event available
This commit allows event_endtx to be used outside of the Uarte itself. As a consequence, PPI can be used to drive tasks given the end of transmission on the Uarte. This is particularly useful for situations like RS485 where a GPIO must be set to high when transmitting then cleared when done. A non-ppi approach can cause a delay in the clearing of this GPIO as other Embassy tasks might become scheduled.
2022-01-10 19:14:02 +11:00
huntc
3d8eecff89 Set Uarte log levels to trace
I noticed lots of logging which really slows things down and is not useful outside of a debugging context, hence set to trace.
2021-12-17 17:06:46 +11:00
Ulf Lilleengen
2bbd1ddb8a Remove unneeded rustfmt::skip 2021-12-16 11:37:53 +01:00
huntc
0642eec01e Properly initialise refcount 2021-12-16 18:15:28 +11:00
huntc
bb03b5cc02 Too much copy/pasta
The tx permitted reads and the rx permitted writes!
2021-12-16 07:16:38 +11:00
huntc
2493699fb3 Ref count the peripheral drop 2021-12-16 07:09:33 +11:00
huntc
1374ad2ab6 Introduces split on the nRF Uarte
A new `split` method is introduced such that the Uarte tx and rx can be used from separate tasks. An MPSC is used to illustrate how data may be passed between these tasks.
2021-12-15 18:31:52 +11:00
huntc
dc3469b297 Documents the nRF BufferedUarte problem
Please see https://github.com/embassy-rs/embassy/issues/536 for the rationale.
2021-12-12 17:52:17 +11:00
huntc
090a7adf78 Keep Clippy happy 2021-12-08 12:13:49 +11:00
huntc
4e7fa52288 Applies the Uarte patch
Applies the Nordic workaround found in the `Uarte` for the nRF9160 and nRF5340 to the `BufferedUarte`.
2021-12-08 12:02:30 +11:00
huntc
496ad4ed43 Rationale for uarte usage 2021-12-01 09:37:09 +11:00
huntc
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
Dario Nieuwenhuis
c995a97f20 nrf91: support running in both S and NS mode. 2021-10-26 17:40:07 +02:00
Dion Dokter
c63d747209 Fewer channel traits, more cfg to make the system work 2021-10-26 14:47:34 +02:00
Dion Dokter
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
Dion Dokter
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
Dion Dokter
e6ec81b999 Fixed examples and added defmt format to the new error types 2021-10-26 14:46:39 +02:00
Dion Dokter
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
Dario Nieuwenhuis
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
Dion Dokter
c1c704bfc8 - Removed the enable assert from UARTE.
- Added nRF9160 to CI.
2021-10-13 15:00:08 +02:00
Dion Dokter
ddcee446c1 Added anomaly workaround from the HAL to improve the UARTE 2021-10-12 13:35:08 +02:00
Dion Dokter
2c2c284482 Undoing unnecessary changes 2021-10-12 11:55:38 +02:00
Dion Dokter
20674f7126 Initial support for nrf9160 2021-10-11 10:39:38 +02:00
Dario Nieuwenhuis
ead987245d embassy: Refactor module structure to remove kitchen-sink util. 2021-09-11 02:35:35 +02:00
f_punk
34c66fa78d removed type aliases
NotAwaitable as default generic param
added awaitable_timer example
2021-09-02 12:02:31 +02:00
f_punk
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
Dario Nieuwenhuis
7bfb763e09 Rename embassy-extras to embassy-hal-common 2021-07-29 13:44:51 +02:00
Liam Murphy
1b7ad7080e Add Send/Sync bounds to PeripheralState 2021-07-24 12:53:57 +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
e7dc5c0939 fmt: make all macros macro_rules so scoping is consistent. 2021-06-07 00:16:39 +02:00
Dario Nieuwenhuis
39c420733f nrf/uarte: deconfigure pins on drop 2021-05-26 20:11:23 +02:00
Rukai
149ddf2f29 Fix warnings 2021-05-17 19:48:58 +10:00
Dario Nieuwenhuis
a5ad79927e nrf: add Unborrow<Target = Self> bound to all instance traits 2021-05-17 01:01:31 +02:00
Dario Nieuwenhuis
bd9589d0ce nrf: add support for nrf52805, nrf52811, nrf52820 2021-05-17 00:57:20 +02:00
Ulf Lilleengen
0a3c236510 Improve comment 2021-05-10 23:06:25 +02:00
Ulf Lilleengen
e9eb3ce6c1 Disable PPI trigger during normal read 2021-05-10 23:06:25 +02:00
Ulf Lilleengen
687dda106f Read rx amount outside of poll_fn 2021-05-10 23:06:25 +02:00
Ulf Lilleengen
5afe01617a Use rxdrdy as trigger for timer 2021-05-10 23:06:25 +02:00
Ulf Lilleengen
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
Dario Nieuwenhuis
97ca54fa66 Rename PeripheralBorrow to Unborrow 2021-04-14 19:59:52 +02:00