Commit Graph

262 Commits

Author SHA1 Message Date
bors[bot]
a4bf190f2f
Merge #752
752: Replace embassy::io with embedded_io. r=Dirbaio a=Dirbaio

TODO:

- [x] Release embedded-io on crates.io
- [x] Remove git dep

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2022-05-06 23:54:07 +00:00
Dario Nieuwenhuis
931a137f8c Replace embassy::io with embedded_io. 2022-05-07 01:45:54 +02:00
Daniel Bevenius
0ce29ca84c fixup! Use explicit return statement TaskStorage::spawn 2022-05-04 16:31:52 +02:00
Daniel Bevenius
34493c7ed6 Use explicit return statement TaskStorage::spawn
This commit removes the else branch in TaskStorage::spawn, and returns
explicitly from the if statement's branch, similar to what
TaskPool::spawn does.
2022-05-04 16:11:55 +02:00
Daniel Bevenius
c223fa3791 Rename spawn_allocate to spawn_mark_used
This commit contains a suggestion to rename TaskStorage::spawn_allocate.

The motivation for this is when reading through the code I was
expecting something else to happen in this method, due to 'allocate' in
the method name.
2022-05-03 16:52:16 +02:00
Dario Nieuwenhuis
a465615196 embassy/time: derives for TimeoutError. 2022-05-03 01:08:34 +02:00
Daniel Bevenius
7b04c78388 Fix typo in waker.rs 2022-05-01 19:25:45 +02:00
Dario Nieuwenhuis
1599009a4f executor: "send-spawn is OK if the args are Send" only holds for async fn futures.
The normal `spawn()` methods can be called directly by the user, with arbitrary hand-implemented futures.
We can't enforce they're only called with `async fn` futures. Therefore, make these
require `F: Send`, and add a "private" one only for use in the macro, which can enforce it.
2022-04-27 04:56:41 +02:00
Dario Nieuwenhuis
6f6c16f449 executor: make send-spawning only require the task args to be Send, not the whole future. 2022-04-27 04:56:41 +02:00
Dario Nieuwenhuis
293f54d134 executor: add raw::TaskPool.
This simplifies the macro code a bit.
2022-04-27 04:56:41 +02:00
Dario Nieuwenhuis
9e897cbea9 executor: Add Spawner::for_current_executor. 2022-04-26 19:08:18 +02:00
Dario Nieuwenhuis
b27feb0619 executor: fix unsoundness in InterruptExecutor::start.
The initial closure is not actually called in the interrupt, so this is
illegally sending non-Send futures to the interrupt.

Remove the closure, and return a SendSpawner instead.
2022-04-25 22:09:04 +02:00
Dario Nieuwenhuis
52ed08cf95 executor: remove useless not_send in SendSpwaner. 2022-04-25 16:38:56 +02:00
Dario Nieuwenhuis
3251a21fb7 Switch to crates.io embedded-hal, embedded-hal-async.
This temporarily removes support for the async UART trait, since it's
not yet in embedded-hal-async.
2022-04-22 19:58:24 +02:00
Daniel Bevenius
db862a60ee Fix typo in driver.rs 2022-04-21 18:27:00 +02:00
Dario Nieuwenhuis
19fa882d99 New README. 2022-04-19 01:31:20 +02:00
bors[bot]
5d48153bd7
Merge #694
694: Add select, select3, select4. r=Dirbaio a=Dirbaio

The difference with those from the `futures` crate is they don't return the other partially-run futures, so they can work with `!Unpin` futures which makes them much easier to use.

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2022-04-12 21:27:13 +00:00
Ulf Lilleengen
cdf30e68eb Erase mutex type as well 2022-04-11 13:33:48 +02:00
Ulf Lilleengen
bc1dff34c0 Add types for channel dynamic dispatch
* Add internal DynamicChannel trait implemented by Channel that allows
  polling for internal state in a lock safe manner and does not require
  knowing the channel size.
* Existing usage of Sender and Receiver is preserved and does not use
  dynamic dispatch.
* Add DynamicSender and DynamicReceiver types that references the
  channel using the DynamicChannel trait and does not require the const
  generic channel size parameter.
2022-04-11 08:57:15 +02:00
Ulf Lilleengen
9206584aa9 Add back support for cloning sender/receiver
* Remove level of import indirection for Channel and Signal.
2022-04-07 15:15:44 +02:00
bors[bot]
fee0aef076
Merge #696
696: Add async Mutex. r=Dirbaio a=Dirbaio

What it says on the tin :) 

It allows sharing data between tasks when you want to `.await` stuff while holding it locked.

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2022-04-06 10:20:43 +00:00
Dario Nieuwenhuis
6731948056 Add async Mutex. 2022-04-06 01:39:58 +02:00
Dario Nieuwenhuis
27a1b0ea73 Simpler Channel.
- Allow initializing in a static, without Forever.
- Remove ability to close, since in embedded enviromnents channels usually live forever and don't get closed.
- Remove MPSC restriction, it's MPMC now. Rename "mpsc" to "channel".
- `Sender` and `Receiver` are still available if you want to enforce a piece of code only has send/receive access, but are optional: you can send/receive directly into the Channel if you want.
2022-04-06 01:34:08 +02:00
Dario Nieuwenhuis
f32fa1d33a Add select, select3, select4. 2022-04-05 21:51:43 +02:00
Dario Nieuwenhuis
b5c479fdad Remove impl Unpin for SelectAll, as it's automatically inferred. 2022-04-05 21:22:02 +02:00
Dario Nieuwenhuis
59ec634246 Remove SelectAll::into_inner.
Due to not requiring Unpin, it's not really possible to call it
after having polled it, you can only call it right after constructing it,
so in practice it's not very useful.
2022-04-05 21:20:44 +02:00
Dario Nieuwenhuis
c8bd792b7a reorganize util mod. 2022-04-05 21:17:29 +02:00
Dario Nieuwenhuis
aee19185b7 Add more docserver metadata. 2022-04-05 21:05:09 +02:00
alexmoon
e42295c4c5 Remove Unpin bound from SelectAll 2022-04-04 21:24:10 -04:00
alexmoon
04a263c700 no_std version of futures::future::select_all 2022-04-04 19:30:16 -04:00
Dario Nieuwenhuis
9bad9365dc Update rust nightly, embedded-hal 1.0, embedded-hal-async. 2022-03-11 00:38:07 +01:00
Dario Nieuwenhuis
44096358a2 docs: add metadata.embassy_docs to cargo tomls. 2022-03-04 18:03:41 +01:00
Dario Nieuwenhuis
fdb6e66b4b time: better docs explaining overflow handling. 2022-02-23 05:16:30 +01:00
Dario Nieuwenhuis
640ddc9481 time: optimize math by reducing fractions at compile time.
For example, `as_micros`, `from_micros` now are noops if tick rate is 1MHz.
2022-02-13 21:28:03 +01:00
Daniel Franklin
04ac488319 Add {from_as}_micros to Instant 2022-02-11 19:01:43 -07:00
Daniel Franklin
4c5f5f7169 Add feature defmt-timestamp-uptime
Enabling it adds a timestamp of the number of seconds since startup next
to defmt log messages using `Instant::now`.
2022-02-11 18:45:23 -07: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
6c925b2342 blocking_mutex: refactor to work on stable. No GATs, and can be constructed in const. 2022-02-12 01:16:31 +01:00
Dario Nieuwenhuis
0719b05d63 traits: migrate Delay to embedded-hal 1.0+async, remove Rng and Flash. 2022-01-27 00:08:02 +01:00
Dario Nieuwenhuis
ab24e5db59 embassy/util: Add yield_now() 2022-01-12 16:30:37 +01:00
Dario Nieuwenhuis
7926957067 Use cortex-m only on cortex-m archs.
Without this, build fails for iOS.
2021-12-23 13:53:26 +01:00
huntc
45ef944457 Stm flush required implementing also, along with std alloc split 2021-12-10 15:11:41 +11:00
huntc
29fee65616 std also required an implementation 2021-12-10 14:18:22 +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
d4179ee2e4 Some documentation corrections and expansion 2021-11-22 12:26:11 +11:00
Bob McWhirter
c2da498263 Update to defmt 3.0ish.
Lots of gitrevs deps.
2021-11-15 11:09:08 -05:00
bors[bot]
569ecd699d
Merge #467
467: docs: fix some `cargo doc` warnings r=lulf a=numero-744

There are still 3 warnings (below)

```
 Documenting embassy v0.1.0 (embassy)
warning: unresolved link to `channel`
   --> src/channel/mpsc.rs:241:22
    |
241 |     /// [`channel`]: channel
    |                      ^^^^^^^ no item named `channel` in scope
    |
    = note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default
    = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

warning: unresolved link to `Task::spawn`
   --> src/executor/raw/mod.rs:105:12
    |
105 | /// with [`Task::spawn()`], which will fail if it is already spawned.
    |            ^^^^^^^^^^^^^ no item named `Task` in scope

warning: public documentation for `spawn` links to private item `Executor::spawn`
   --> src/executor/raw/mod.rs:156:17
    |
156 |     /// cause [`Executor::spawn()`] to return the error.
    |                 ^^^^^^^^^^^^^^^^^ this item is private
    |
    = note: `#[warn(rustdoc::private_intra_doc_links)]` on by default
    = note: this link will resolve properly if you pass `--document-private-items`

warning: `embassy` (lib doc) generated 3 warnings
```

Co-authored-by: Côme ALLART <come.allart@etu.emse.fr>
2021-11-02 19:31:15 +00:00
Ulf Lilleengen
205a223af3 Update versions of critical-section and atomic-polyfill 2021-11-02 18:52:03 +01:00
Côme ALLART
3dd39e3d46 docs: fix some cargo doc warnings 2021-11-02 18:49:01 +01:00
Ulf Lilleengen
5e6ee59ecd Fix time calculation
Use unwrap_or_get to avoid checking time when not necessary
2021-10-20 14:36:16 +02:00