Commit Graph

232 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
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
Ulf Lilleengen
3c2daf0d32 Remove unused import 2021-10-20 14:36:16 +02:00
Ulf Lilleengen
6c9420978b Prevent overflow in std timer driver
This prevents the std time driver from overflowing when setting the next
wakeup time. If an overflow occurs, default to sleeping up to 1 second.

Fixes #438
2021-10-20 14:36:16 +02:00
bors[bot]
729b17bc25
Merge #428
428: executor: Use critical sections instead of atomic CAS loops r=lulf a=Dirbaio

Optimize executor wakes.

CAS loops (either `fetch_update`, or manual `load + compare_exchange_weak`) generate surprisingly horrible code: https://godbolt.org/z/zhscnM1cb

This switches to using critical sections, which makes it faster. On thumbv6 (Cortex-M0) it should make it even faster, as it is currently using `atomic-polyfill`, which will make many critical sections for each `compare_exchange_weak` anyway.

```
            opt-level=3   opt-level=s
   atmics:  105 cycles    101 cycles
       CS:   76 cycles     72 cycles
CS+inline:   72 cycles     64 cycles
```

Measured in nrf52 with icache disabled, with this code:

```rust


    poll_fn(|cx| {
        let task = unsafe { task_from_waker(cx.waker()) };

        compiler_fence(Ordering::SeqCst);
        let a = cortex_m::peripheral::DWT::get_cycle_count();
        compiler_fence(Ordering::SeqCst);

        unsafe { wake_task(task) }

        compiler_fence(Ordering::SeqCst);
        let b = cortex_m::peripheral::DWT::get_cycle_count();
        compiler_fence(Ordering::SeqCst);

        defmt::info!("cycles: {=u32}", b.wrapping_sub(a));

        Poll::Ready(())
    })
    .await;
````

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2021-10-18 12:05:43 +00:00
Dario Nieuwenhuis
a2e7c24e00 Clippy fixes 2021-10-18 01:05:29 +02:00
Dario Nieuwenhuis
4c0fa03c14 interrupt: transmute instead of steal.
That steal method has a TAKEN=true write [here](6b013138b7/src/peripheral/mod.rs (L180)).
This is not zero cost, we don't want it. Transmute instead, which is zero cost.
2021-10-16 04:11:19 +02:00
Dario Nieuwenhuis
d32477f5a1 executor: Inline enqueue fns 2021-10-16 01:50:10 +02:00
Dario Nieuwenhuis
39e5677621 executor: Use critical sections instead of atomic CAS loops 2021-10-16 01:49:54 +02:00
Daniel Bevenius
a7c37d2ff4 Fix typo in RunQueue documentation 2021-10-11 13:55:05 +02:00
Ulf Lilleengen
99a94f1d50 Update version of critical-section 2021-09-13 17:05:17 +02:00
Ulf Lilleengen
e24528051b Add WASM support for executor
* Adds an executor for WASM runtimes based on wasm_bindgen.
* Add time driver based on JS time handling.
* Add example that can run in browser locally.
* Update to critical-section version that supports 'std' flag
2021-09-13 16:42:39 +02:00
Dario Nieuwenhuis
70e5877d68 embassy/channel: switch to use MutexKind 2021-09-13 00:08:41 +02:00
Dario Nieuwenhuis
5be5bdfd20 embassy/blocking_mutex: add MutexKind to allow writing code generic over mutex kinds. 2021-09-12 23:28:00 +02:00
Dario Nieuwenhuis
e1f9dd1170 embassy/channel: remove unused receiver_consumed 2021-09-11 02:58:41 +02:00
Dario Nieuwenhuis
b78f4695c4 embassy/channel: use heapless::Deque. 2021-09-11 02:49:16 +02:00
Dario Nieuwenhuis
ead987245d embassy: Refactor module structure to remove kitchen-sink util. 2021-09-11 02:35:35 +02:00
Dario Nieuwenhuis
f2623e7e9b Update lots of deps 2021-09-11 01:35:23 +02:00
Dario Nieuwenhuis
11d2b0cdc1 Remove more unused features. 2021-09-03 17:13:54 +02:00
Dario Nieuwenhuis
de016e8456 Remove trait_alias, allow(incomplete_features).
trait_alias seems unused. no idea why it's there.
2021-09-03 17:00:58 +02:00
Ulf Lilleengen
5f04d6e6c5 Fix embassy::main macros for std target 2021-09-02 14:45:54 +02:00
Dario Nieuwenhuis
297de612e5 Improve executor naming. Add docs. 2021-08-31 23:59:28 +02:00
Dario Nieuwenhuis
c4b9c8ac87 std: fold into embassy core, add non-hacky time driver. 2021-08-25 21:06:27 +02:00
Dario Nieuwenhuis
7c0990ad1e time: allow storing state inside the driver struct. 2021-08-25 21:06:27 +02:00
Dario Nieuwenhuis
55b2d7b524 io: move std stuff to own module 2021-08-25 21:06:27 +02:00
Dario Nieuwenhuis
503be49417 Document embassy::time 2021-08-25 21:06:27 +02:00
Dario Nieuwenhuis
ae179d49af executor: improve module structure 2021-08-25 00:20:29 +02:00
Richard Dodd
7ca745a5c0 Refactor to allow defmt to intern strings. 2021-08-22 00:11:19 +01:00
Richard Dodd
4d3c07f71b Fix fmt 2021-08-21 22:38:02 +01:00
Richard Dodd
170121cdf6 Add defmt support for mpsc errors. 2021-08-21 22:36:23 +01:00
Ben Gamari
a3b56a3764 embassy-macros: Use defmt::unwrap! when spawning embassy::main
But only when `defmt` feature is enabled.
2021-08-05 22:40:12 +02:00
Dario Nieuwenhuis
36402b5487
Merge pull request #348 from embassy-rs/remove-portal
Remove Portal. Fixes #32
2021-08-05 22:31:06 +02:00