diff options
| -rw-r--r-- | embassy-futures/README.md | 9 | ||||
| -rw-r--r-- | embassy-futures/src/lib.rs | 2 | ||||
| -rw-r--r-- | embassy-sync/README.md | 12 | ||||
| -rw-r--r-- | embassy-sync/src/lib.rs | 2 | ||||
| -rw-r--r-- | embassy-sync/src/signal.rs | 4 | ||||
| -rw-r--r-- | embassy-time/README.md | 43 | ||||
| -rw-r--r-- | embassy-time/src/lib.rs | 43 |
7 files changed, 69 insertions, 46 deletions
diff --git a/embassy-futures/README.md b/embassy-futures/README.md new file mode 100644 index 000000000..971f4c835 --- /dev/null +++ b/embassy-futures/README.md | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | # embassy-futures | ||
| 2 | |||
| 3 | Utilities for working with futures: | ||
| 4 | |||
| 5 | - [`select`](select::select) - waiting for one out of two futures to complete. | ||
| 6 | - [`select3`](select::select3) - waiting for one out of three futures to complete. | ||
| 7 | - [`select4`](select::select4) - waiting for one out of four futures to complete. | ||
| 8 | - [`select_all`](select::select_all) - waiting for one future in a list of futures to complete. | ||
| 9 | - [`yield_now`](yield_now::yield_now) - yielding the current task. | ||
diff --git a/embassy-futures/src/lib.rs b/embassy-futures/src/lib.rs index 48c9c8574..45bea2529 100644 --- a/embassy-futures/src/lib.rs +++ b/embassy-futures/src/lib.rs | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![doc = include_str!("../../README.md")] | 2 | #![doc = include_str!("../README.md")] |
| 3 | #![warn(missing_docs)] | 3 | #![warn(missing_docs)] |
| 4 | 4 | ||
| 5 | // This mod MUST go first, so that the others see its macros. | 5 | // This mod MUST go first, so that the others see its macros. |
diff --git a/embassy-sync/README.md b/embassy-sync/README.md new file mode 100644 index 000000000..106295c0d --- /dev/null +++ b/embassy-sync/README.md | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | # embassy-sync | ||
| 2 | |||
| 3 | Synchronization primitives and data structures with an async API: | ||
| 4 | |||
| 5 | - [`Channel`](channel::Channel) - A Multiple Producer Multiple Consumer (MPMC) channel. Each message is only received by a single consumer. | ||
| 6 | - [`PubSubChannel`](pubsub::PubSubChannel) - A broadcast channel (publish-subscribe) channel. Each message is received by all consumers. | ||
| 7 | - [`Signal`](signal::Signal) - Signalling latest value to a single consumer. | ||
| 8 | - [`Mutex`](mutex::Mutex) - A Mutex for synchronizing state between asynchronous tasks. | ||
| 9 | - [`Pipe`](pipe::Pipe) - Byte stream implementing `embedded_io` traits. | ||
| 10 | - [`WakerRegistration`](waitqueue::WakerRegistration) - Utility to register and wake a `Waker`. | ||
| 11 | - [`AtomicWaker`](waitqueue::AtomicWaker) - A variant of `WakerRegistration` accessible using a non-mut API. | ||
| 12 | - [`MultiWakerRegistration`](waitqueue::MultiWakerRegistration) - Utility registering and waking multiple `Waker`'s. | ||
diff --git a/embassy-sync/src/lib.rs b/embassy-sync/src/lib.rs index 8e81e5cbe..25150e8aa 100644 --- a/embassy-sync/src/lib.rs +++ b/embassy-sync/src/lib.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | #![cfg_attr(not(any(feature = "std", feature = "wasm")), no_std)] | 1 | #![cfg_attr(not(any(feature = "std", feature = "wasm")), no_std)] |
| 2 | #![cfg_attr(feature = "nightly", feature(generic_associated_types, type_alias_impl_trait))] | 2 | #![cfg_attr(feature = "nightly", feature(generic_associated_types, type_alias_impl_trait))] |
| 3 | #![allow(clippy::new_without_default)] | 3 | #![allow(clippy::new_without_default)] |
| 4 | #![doc = include_str!("../../README.md")] | 4 | #![doc = include_str!("../README.md")] |
| 5 | #![warn(missing_docs)] | 5 | #![warn(missing_docs)] |
| 6 | 6 | ||
| 7 | // This mod MUST go first, so that the others see its macros. | 7 | // This mod MUST go first, so that the others see its macros. |
diff --git a/embassy-sync/src/signal.rs b/embassy-sync/src/signal.rs index 3f665e388..f6ebeb9b9 100644 --- a/embassy-sync/src/signal.rs +++ b/embassy-sync/src/signal.rs | |||
| @@ -6,7 +6,7 @@ use core::task::{Context, Poll, Waker}; | |||
| 6 | 6 | ||
| 7 | /// Single-slot signaling primitive. | 7 | /// Single-slot signaling primitive. |
| 8 | /// | 8 | /// |
| 9 | /// This is similar to a [`Channel`](crate::channel::mpmc::Channel) with a buffer size of 1, except | 9 | /// This is similar to a [`Channel`](crate::channel::Channel) with a buffer size of 1, except |
| 10 | /// "sending" to it (calling [`Signal::signal`]) when full will overwrite the previous value instead | 10 | /// "sending" to it (calling [`Signal::signal`]) when full will overwrite the previous value instead |
| 11 | /// of waiting for the receiver to pop the previous value. | 11 | /// of waiting for the receiver to pop the previous value. |
| 12 | /// | 12 | /// |
| @@ -14,7 +14,7 @@ use core::task::{Context, Poll, Waker}; | |||
| 14 | /// the latest data, and therefore it's fine to "lose" messages. This is often the case for "state" | 14 | /// the latest data, and therefore it's fine to "lose" messages. This is often the case for "state" |
| 15 | /// updates. | 15 | /// updates. |
| 16 | /// | 16 | /// |
| 17 | /// For more advanced use cases, you might want to use [`Channel`](crate::channel::mpmc::Channel) instead. | 17 | /// For more advanced use cases, you might want to use [`Channel`](crate::channel::Channel) instead. |
| 18 | /// | 18 | /// |
| 19 | /// Signals are generally declared as `static`s and then borrowed as required. | 19 | /// Signals are generally declared as `static`s and then borrowed as required. |
| 20 | /// | 20 | /// |
diff --git a/embassy-time/README.md b/embassy-time/README.md new file mode 100644 index 000000000..2be80ff9c --- /dev/null +++ b/embassy-time/README.md | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | # embassy-time | ||
| 2 | |||
| 3 | Timekeeping, delays and timeouts. | ||
| 4 | |||
| 5 | Timekeeping is done with elapsed time since system boot. Time is represented in | ||
| 6 | ticks, where the tick rate is defined by the current driver, usually to match | ||
| 7 | the tick rate of the hardware. | ||
| 8 | |||
| 9 | Tick counts are 64 bits. At the highest supported tick rate of 1Mhz this supports | ||
| 10 | representing time spans of up to ~584558 years, which is big enough for all practical | ||
| 11 | purposes and allows not having to worry about overflows. | ||
| 12 | |||
| 13 | [`Instant`] represents a given instant of time (relative to system boot), and [`Duration`] | ||
| 14 | represents the duration of a span of time. They implement the math operations you'd expect, | ||
| 15 | like addition and substraction. | ||
| 16 | |||
| 17 | # Delays and timeouts | ||
| 18 | |||
| 19 | [`Timer`] allows performing async delays. [`Ticker`] allows periodic delays without drifting over time. | ||
| 20 | |||
| 21 | An implementation of the `embedded-hal` delay traits is provided by [`Delay`], for compatibility | ||
| 22 | with libraries from the ecosystem. | ||
| 23 | |||
| 24 | # Wall-clock time | ||
| 25 | |||
| 26 | The `time` module deals exclusively with a monotonically increasing tick count. | ||
| 27 | Therefore it has no direct support for wall-clock time ("real life" datetimes | ||
| 28 | like `2021-08-24 13:33:21`). | ||
| 29 | |||
| 30 | If persistence across reboots is not needed, support can be built on top of | ||
| 31 | `embassy_time` by storing the offset between "seconds elapsed since boot" | ||
| 32 | and "seconds since unix epoch". | ||
| 33 | |||
| 34 | # Time driver | ||
| 35 | |||
| 36 | The `time` module is backed by a global "time driver" specified at build time. | ||
| 37 | Only one driver can be active in a program. | ||
| 38 | |||
| 39 | All methods and structs transparently call into the active driver. This makes it | ||
| 40 | possible for libraries to use `embassy_time` in a driver-agnostic way without | ||
| 41 | requiring generic parameters. | ||
| 42 | |||
| 43 | For more details, check the [`driver`] module. | ||
diff --git a/embassy-time/src/lib.rs b/embassy-time/src/lib.rs index a6454d55e..a6c5d78cc 100644 --- a/embassy-time/src/lib.rs +++ b/embassy-time/src/lib.rs | |||
| @@ -1,50 +1,9 @@ | |||
| 1 | #![cfg_attr(not(any(feature = "std", feature = "wasm")), no_std)] | 1 | #![cfg_attr(not(any(feature = "std", feature = "wasm")), no_std)] |
| 2 | #![cfg_attr(feature = "nightly", feature(generic_associated_types, type_alias_impl_trait))] | 2 | #![cfg_attr(feature = "nightly", feature(generic_associated_types, type_alias_impl_trait))] |
| 3 | #![doc = include_str!("../README.md")] | ||
| 3 | #![allow(clippy::new_without_default)] | 4 | #![allow(clippy::new_without_default)] |
| 4 | #![warn(missing_docs)] | 5 | #![warn(missing_docs)] |
| 5 | 6 | ||
| 6 | //! Timekeeping, delays and timeouts. | ||
| 7 | //! | ||
| 8 | //! Timekeeping is done with elapsed time since system boot. Time is represented in | ||
| 9 | //! ticks, where the tick rate is defined by the current driver, usually to match | ||
| 10 | //! the tick rate of the hardware. | ||
| 11 | //! | ||
| 12 | //! Tick counts are 64 bits. At the highest supported tick rate of 1Mhz this supports | ||
| 13 | //! representing time spans of up to ~584558 years, which is big enough for all practical | ||
| 14 | //! purposes and allows not having to worry about overflows. | ||
| 15 | //! | ||
| 16 | //! [`Instant`] represents a given instant of time (relative to system boot), and [`Duration`] | ||
| 17 | //! represents the duration of a span of time. They implement the math operations you'd expect, | ||
| 18 | //! like addition and substraction. | ||
| 19 | //! | ||
| 20 | //! # Delays and timeouts | ||
| 21 | //! | ||
| 22 | //! [`Timer`] allows performing async delays. [`Ticker`] allows periodic delays without drifting over time. | ||
| 23 | //! | ||
| 24 | //! An implementation of the `embedded-hal` delay traits is provided by [`Delay`], for compatibility | ||
| 25 | //! with libraries from the ecosystem. | ||
| 26 | //! | ||
| 27 | //! # Wall-clock time | ||
| 28 | //! | ||
| 29 | //! The `time` module deals exclusively with a monotonically increasing tick count. | ||
| 30 | //! Therefore it has no direct support for wall-clock time ("real life" datetimes | ||
| 31 | //! like `2021-08-24 13:33:21`). | ||
| 32 | //! | ||
| 33 | //! If persistence across reboots is not needed, support can be built on top of | ||
| 34 | //! `embassy_time` by storing the offset between "seconds elapsed since boot" | ||
| 35 | //! and "seconds since unix epoch". | ||
| 36 | //! | ||
| 37 | //! # Time driver | ||
| 38 | //! | ||
| 39 | //! The `time` module is backed by a global "time driver" specified at build time. | ||
| 40 | //! Only one driver can be active in a program. | ||
| 41 | //! | ||
| 42 | //! All methods and structs transparently call into the active driver. This makes it | ||
| 43 | //! possible for libraries to use `embassy_time` in a driver-agnostic way without | ||
| 44 | //! requiring generic parameters. | ||
| 45 | //! | ||
| 46 | //! For more details, check the [`driver`] module. | ||
| 47 | |||
| 48 | // This mod MUST go first, so that the others see its macros. | 7 | // This mod MUST go first, so that the others see its macros. |
| 49 | pub(crate) mod fmt; | 8 | pub(crate) mod fmt; |
| 50 | 9 | ||
