Commit Graph

63 Commits

Author SHA1 Message Date
Dario Nieuwenhuis
f02ba35482 Remove PeripheralRef::into_inner() 2022-07-23 14:27:45 +02:00
Dario Nieuwenhuis
4901c34d9c Rename Unborrowed -> PeripheralRef, Unborrow -> Peripheral 2022-07-23 14:00:19 +02:00
Grant Miller
65a82d02d1 WIP: Make unborrow safe to use 2022-07-23 01:33:22 +02:00
Ulf Lilleengen
ca59c1ff35 Add more API docs for embassy-cortex-m and embassy-nrf 2022-06-23 13:17:56 +02:00
Dario Nieuwenhuis
a8703b7598 Run rustfmt. 2022-06-12 22:22:31 +02:00
Dario Nieuwenhuis
5085100df2 Add embassy-cortex-m crate.
- Move Interrupt and InterruptExecutor from `embassy` to `embassy-cortex-m`.
- Move Unborrow from `embassy` to `embassy-hal-common` (nothing in `embassy` requires it anymore)
- Move PeripheralMutex from `embassy-hal-common` to `embassy-cortex-m`.
2022-06-12 21:45:38 +02:00
Dario Nieuwenhuis
db344c2bda
common/PeripheralMutex: remove unsafe API. (#802)
Following the project's decision that "leak unsafe" APIs are not marked as "unsafe",
update PeripheralMutex to accept non-'static state without unsafe.

Fixes #801
2022-06-09 21:28:13 +02:00
chemicstry
9772645718 Revert "Fix irq pend behavior"
This reverts commit 9a447f1359.
2022-05-26 23:36:25 +03:00
chemicstry
9a447f1359 Fix irq pend behavior 2022-05-26 23:24:02 +03:00
chemicstry
c3b899c470 Implement BufRead for nrf BufferedUarte 2022-05-26 23:15:06 +03:00
Dario Nieuwenhuis
833b3a370a nrf/buffered_uarte: fix out of bounds on read. 2022-05-14 02:20:40 +02:00
Dario Nieuwenhuis
931a137f8c Replace embassy::io with embedded_io. 2022-05-07 01:45:54 +02: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
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
7256ff3e71 Provides AsyncWrite with flush
As per Tokio and others, this commit provides a `poll_flush` method on `AsyncWrite` so that a best-effort attempt at wakening once all bytes are flushed can be made.
2021-12-10 12:16:08 +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
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
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
3f28bb6c77 common: Initialize PeripheralMutex state with closure to ensure it's done in-place. 2021-08-02 20:13:41 +02:00
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