diff options
| author | Dario Nieuwenhuis <[email protected]> | 2024-01-11 16:20:58 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-01-11 16:20:58 +0000 |
| commit | ae84f2a157cf34c5bbc88ec4637f084f1ab924ea (patch) | |
| tree | f025105ae7449df92f5f42abda0d3bdf094e774d | |
| parent | 650f5661495e5c0d6fe25bd3742058a02ac0bae1 (diff) | |
| parent | 75b05fb3447c449ed14648edbf8382d046acafea (diff) | |
Merge pull request #2434 from embassy-rs/time-driver-crate
time: docs improvements, add ci.
| -rwxr-xr-x | .github/ci/doc.sh | 1 | ||||
| -rwxr-xr-x | .github/ci/test.sh | 1 | ||||
| -rw-r--r-- | embassy-time-driver/README.md | 3 | ||||
| -rw-r--r-- | embassy-time-driver/src/lib.rs | 16 | ||||
| -rw-r--r-- | embassy-time/README.md | 2 |
5 files changed, 9 insertions, 14 deletions
diff --git a/.github/ci/doc.sh b/.github/ci/doc.sh index fbed2752a..0bbe7f690 100755 --- a/.github/ci/doc.sh +++ b/.github/ci/doc.sh | |||
| @@ -30,6 +30,7 @@ docserver-builder -i ./embassy-nrf -o webroot/crates/embassy-nrf/git.zup | |||
| 30 | docserver-builder -i ./embassy-rp -o webroot/crates/embassy-rp/git.zup | 30 | docserver-builder -i ./embassy-rp -o webroot/crates/embassy-rp/git.zup |
| 31 | docserver-builder -i ./embassy-sync -o webroot/crates/embassy-sync/git.zup | 31 | docserver-builder -i ./embassy-sync -o webroot/crates/embassy-sync/git.zup |
| 32 | docserver-builder -i ./embassy-time -o webroot/crates/embassy-time/git.zup | 32 | docserver-builder -i ./embassy-time -o webroot/crates/embassy-time/git.zup |
| 33 | docserver-builder -i ./embassy-time-driver -o webroot/crates/embassy-time-driver/git.zup | ||
| 33 | docserver-builder -i ./embassy-usb -o webroot/crates/embassy-usb/git.zup | 34 | docserver-builder -i ./embassy-usb -o webroot/crates/embassy-usb/git.zup |
| 34 | docserver-builder -i ./embassy-usb-driver -o webroot/crates/embassy-usb-driver/git.zup | 35 | docserver-builder -i ./embassy-usb-driver -o webroot/crates/embassy-usb-driver/git.zup |
| 35 | docserver-builder -i ./embassy-usb-logger -o webroot/crates/embassy-usb-logger/git.zup | 36 | docserver-builder -i ./embassy-usb-logger -o webroot/crates/embassy-usb-logger/git.zup |
diff --git a/.github/ci/test.sh b/.github/ci/test.sh index b16b3c20d..b6a5bcd56 100755 --- a/.github/ci/test.sh +++ b/.github/ci/test.sh | |||
| @@ -12,6 +12,7 @@ cargo test --manifest-path ./embassy-sync/Cargo.toml | |||
| 12 | cargo test --manifest-path ./embassy-embedded-hal/Cargo.toml | 12 | cargo test --manifest-path ./embassy-embedded-hal/Cargo.toml |
| 13 | cargo test --manifest-path ./embassy-hal-internal/Cargo.toml | 13 | cargo test --manifest-path ./embassy-hal-internal/Cargo.toml |
| 14 | cargo test --manifest-path ./embassy-time/Cargo.toml --features generic-queue,mock-driver | 14 | cargo test --manifest-path ./embassy-time/Cargo.toml --features generic-queue,mock-driver |
| 15 | cargo test --manifest-path ./embassy-time-driver/Cargo.toml | ||
| 15 | 16 | ||
| 16 | cargo test --manifest-path ./embassy-boot/boot/Cargo.toml | 17 | cargo test --manifest-path ./embassy-boot/boot/Cargo.toml |
| 17 | cargo test --manifest-path ./embassy-boot/boot/Cargo.toml --features ed25519-dalek | 18 | cargo test --manifest-path ./embassy-boot/boot/Cargo.toml --features ed25519-dalek |
diff --git a/embassy-time-driver/README.md b/embassy-time-driver/README.md index 74a5b7876..426252d2c 100644 --- a/embassy-time-driver/README.md +++ b/embassy-time-driver/README.md | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | # embassy-time-driver | 1 | # embassy-time-driver |
| 2 | 2 | ||
| 3 | |||
| 4 | This crate contains the driver trait necessary for adding [`embassy-time`](https://crates.io/crates/embassy-time) support | 3 | This crate contains the driver trait necessary for adding [`embassy-time`](https://crates.io/crates/embassy-time) support |
| 5 | for a new hardware platform. | 4 | for a new hardware platform. |
| 6 | 5 | ||
| @@ -12,7 +11,7 @@ if the driver trait has not had breaking changes. | |||
| 12 | 11 | ||
| 13 | ## How it works | 12 | ## How it works |
| 14 | 13 | ||
| 15 | `embassy-time` module is backed by a global "time driver" specified at build time. | 14 | `embassy-time` is backed by a global "time driver" specified at build time. |
| 16 | Only one driver can be active in a program. | 15 | Only one driver can be active in a program. |
| 17 | 16 | ||
| 18 | All methods and structs transparently call into the active driver. This makes it | 17 | All methods and structs transparently call into the active driver. This makes it |
diff --git a/embassy-time-driver/src/lib.rs b/embassy-time-driver/src/lib.rs index 39a772aa5..565597935 100644 --- a/embassy-time-driver/src/lib.rs +++ b/embassy-time-driver/src/lib.rs | |||
| @@ -2,22 +2,17 @@ | |||
| 2 | #![doc = include_str!("../README.md")] | 2 | #![doc = include_str!("../README.md")] |
| 3 | #![warn(missing_docs)] | 3 | #![warn(missing_docs)] |
| 4 | 4 | ||
| 5 | //! Time driver interface | 5 | //! ## Implementing a driver |
| 6 | //! | ||
| 7 | //! This module defines the interface a driver needs to implement to power the `embassy_time` module. | ||
| 8 | //! | ||
| 9 | //! # Implementing a driver | ||
| 10 | //! | 6 | //! |
| 11 | //! - Define a struct `MyDriver` | 7 | //! - Define a struct `MyDriver` |
| 12 | //! - Implement [`Driver`] for it | 8 | //! - Implement [`Driver`] for it |
| 13 | //! - Register it as the global driver with [`time_driver_impl`](crate::time_driver_impl). | 9 | //! - Register it as the global driver with [`time_driver_impl`](crate::time_driver_impl). |
| 14 | //! - Enable the Cargo feature `embassy-executor/time` | ||
| 15 | //! | 10 | //! |
| 16 | //! If your driver has a single set tick rate, enable the corresponding [`tick-hz-*`](crate#tick-rate) feature, | 11 | //! If your driver has a single set tick rate, enable the corresponding [`tick-hz-*`](crate#tick-rate) feature, |
| 17 | //! which will prevent users from needing to configure it themselves (or selecting an incorrect configuration). | 12 | //! which will prevent users from needing to configure it themselves (or selecting an incorrect configuration). |
| 18 | //! | 13 | //! |
| 19 | //! If your driver supports a small number of set tick rates, expose your own cargo features and have each one | 14 | //! If your driver supports a small number of set tick rates, expose your own cargo features and have each one |
| 20 | //! enable the corresponding `embassy-time/tick-*`. | 15 | //! enable the corresponding `embassy-time-driver/tick-*`. |
| 21 | //! | 16 | //! |
| 22 | //! Otherwise, don’t enable any `tick-hz-*` feature to let the user configure the tick rate themselves by | 17 | //! Otherwise, don’t enable any `tick-hz-*` feature to let the user configure the tick rate themselves by |
| 23 | //! enabling a feature on `embassy-time`. | 18 | //! enabling a feature on `embassy-time`. |
| @@ -43,7 +38,7 @@ | |||
| 43 | //! # Example | 38 | //! # Example |
| 44 | //! | 39 | //! |
| 45 | //! ``` | 40 | //! ``` |
| 46 | //! use embassy_time::driver::{Driver, AlarmHandle}; | 41 | //! use embassy_time_driver::{Driver, AlarmHandle}; |
| 47 | //! | 42 | //! |
| 48 | //! struct MyDriver{} // not public! | 43 | //! struct MyDriver{} // not public! |
| 49 | //! | 44 | //! |
| @@ -61,9 +56,8 @@ | |||
| 61 | //! todo!() | 56 | //! todo!() |
| 62 | //! } | 57 | //! } |
| 63 | //! } | 58 | //! } |
| 64 | //! ``` | 59 | //! |
| 65 | //! ```ignore | 60 | //! embassy_time_driver::time_driver_impl!(static DRIVER: MyDriver = MyDriver{}); |
| 66 | //! embassy_time::time_driver_impl!(static DRIVER: MyDriver = MyDriver{}); | ||
| 67 | //! ``` | 61 | //! ``` |
| 68 | 62 | ||
| 69 | //! ## Feature flags | 63 | //! ## Feature flags |
diff --git a/embassy-time/README.md b/embassy-time/README.md index 20772f1d8..f5d46df7b 100644 --- a/embassy-time/README.md +++ b/embassy-time/README.md | |||
| @@ -21,7 +21,7 @@ All methods and structs transparently call into the active driver. This makes it | |||
| 21 | possible for libraries to use `embassy_time` in a driver-agnostic way without | 21 | possible for libraries to use `embassy_time` in a driver-agnostic way without |
| 22 | requiring generic parameters. | 22 | requiring generic parameters. |
| 23 | 23 | ||
| 24 | For more details, check the [`embassy_time_driver`] crate. | 24 | For more details, check the [`embassy_time_driver`](https://crates.io/crates/embassy-time-driver) crate. |
| 25 | 25 | ||
| 26 | ## Instants and Durations | 26 | ## Instants and Durations |
| 27 | 27 | ||
