-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extract embassy support into esp-hal-embassy
package
#1595
Merged
SergioGasquez
merged 8 commits into
esp-rs:main
from
jessebraham:feature/esp-hal-embassy
Jun 3, 2024
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3040aec
Extract embassy support into `esp-hal-embassy` package
jessebraham 9a6656e
Update relevant packages/examples/tests to get CI green again
jessebraham 26e8e5e
Add back `defmt` support
jessebraham eade5ce
Re-export `Executor` and `InterruptExecutor` rather than making `exec…
jessebraham 4f93870
Document the `esp-hal-embassy` package
jessebraham bb6bdcb
Update `CHANGELOG.md`
jessebraham 73af359
Hack together a "fix" for the `SYSTIMER` time driver
jessebraham 4ca40ac
Make `clippy` shut up
jessebraham File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
[package] | ||
name = "esp-hal-embassy" | ||
version = "0.1.0" | ||
edition = "2021" | ||
rust-version = "1.76.0" | ||
description = "Embassy support for esp-hal" | ||
repository = "https://github.com/esp-rs/esp-hal" | ||
license = "MIT OR Apache-2.0" | ||
|
||
[package.metadata.docs.rs] | ||
default-target = "riscv32imac-unknown-none-elf" | ||
features = ["esp32c6", "time-timg0"] | ||
|
||
[dependencies] | ||
critical-section = "1.1.2" | ||
defmt = { version = "0.3.8", optional = true } | ||
document-features = "0.2.8" | ||
embassy-executor = "0.5.0" | ||
embassy-time-driver = "0.1.0" | ||
esp-hal = { version = "0.17.0", path = "../esp-hal" } | ||
portable-atomic = "1.6.0" | ||
|
||
[build-dependencies] | ||
cfg-if = "1.0.0" | ||
esp-build = { version = "0.1.0", path = "../esp-build" } | ||
esp-metadata = { version = "0.1.0", path = "../esp-metadata" } | ||
|
||
[features] | ||
esp32 = ["esp-hal/esp32"] | ||
esp32c2 = ["esp-hal/esp32c2"] | ||
esp32c3 = ["esp-hal/esp32c3"] | ||
esp32c6 = ["esp-hal/esp32c6"] | ||
esp32h2 = ["esp-hal/esp32h2"] | ||
esp32s2 = ["esp-hal/esp32s2"] | ||
esp32s3 = ["esp-hal/esp32s3"] | ||
|
||
## Implement `defmt::Format` on certain types. | ||
defmt = ["dep:defmt", "embassy-executor/defmt", "esp-hal/defmt"] | ||
## Use the executor-integrated `embassy-time` timer queue. | ||
integrated-timers = ["embassy-executor/integrated-timers"] | ||
|
||
#! ### Time Driver Feature Flags | ||
## SYSTIMER (16MHz) | ||
time-systimer-16mhz = ["embassy-time-driver/tick-hz-16_000_000"] | ||
## SYSTIMER (80MHz) | ||
time-systimer-80mhz = ["embassy-time-driver/tick-hz-80_000_000"] | ||
## TIMG0 (1MHz) | ||
time-timg0 = ["embassy-time-driver/tick-hz-1_000_000"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# esp-hal-embassy | ||
|
||
[![Crates.io](https://img.shields.io/crates/v/esp-hal-embassy?labelColor=1C2C2E&color=C96329&logo=Rust&style=flat-square)](https://crates.io/crates/esp-hal-embassy) | ||
[![docs.rs](https://img.shields.io/docsrs/esp-hal-embassy?labelColor=1C2C2E&color=C96329&logo=rust&style=flat-square)](https://docs.rs/esp-hal-embassy) | ||
![MSRV](https://img.shields.io/badge/MSRV-1.76-blue?labelColor=1C2C2E&style=flat-square) | ||
![Crates.io](https://img.shields.io/crates/l/esp-hal-embassy?labelColor=1C2C2E&style=flat-square) | ||
[![Matrix](https://img.shields.io/matrix/esp-rs:matrix.org?label=join%20matrix&labelColor=1C2C2E&color=BEC5C9&logo=matrix&style=flat-square)](https://matrix.to/#/#esp-rs:matrix.org) | ||
|
||
[Embassy] support for `esp-hal`. | ||
|
||
[embassy]: https://github.com/embassy-rs/embassy | ||
|
||
## [Documentation] | ||
|
||
[documentation]: https://docs.rs/esp-hal-embassy/ | ||
|
||
## Minimum Supported Rust Version (MSRV) | ||
|
||
This crate is guaranteed to compile on stable Rust 1.76 and up. It _might_ | ||
compile with older versions but that may change in any new patch release. | ||
|
||
## License | ||
|
||
Licensed under either of: | ||
|
||
- Apache License, Version 2.0 ([LICENSE-APACHE](../LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) | ||
- MIT license ([LICENSE-MIT](../LICENSE-MIT) or http://opensource.org/licenses/MIT) | ||
|
||
at your option. | ||
|
||
### Contribution | ||
|
||
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in | ||
the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without | ||
any additional terms or conditions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
use std::{error::Error, str::FromStr}; | ||
|
||
use esp_build::assert_unique_used_features; | ||
use esp_metadata::{Chip, Config}; | ||
|
||
fn main() -> Result<(), Box<dyn Error>> { | ||
// NOTE: update when adding new device support! | ||
// Ensure that exactly one chip has been specified: | ||
assert_unique_used_features!( | ||
"esp32", "esp32c2", "esp32c3", "esp32c6", "esp32h2", "esp32s2", "esp32s3" | ||
); | ||
|
||
// If the `embassy` feature is enabled, ensure that a time driver implementation | ||
// is available: | ||
cfg_if::cfg_if! { | ||
if #[cfg(feature = "esp32")] { | ||
assert_unique_used_features!("time-timg0"); | ||
} else if #[cfg(feature = "esp32s2")] { | ||
assert_unique_used_features!("time-systimer-80mhz", "time-timg0"); | ||
} else { | ||
assert_unique_used_features!("time-systimer-16mhz", "time-timg0"); | ||
} | ||
} | ||
|
||
// NOTE: update when adding new device support! | ||
// Determine the name of the configured device: | ||
let device_name = if cfg!(feature = "esp32") { | ||
"esp32" | ||
} else if cfg!(feature = "esp32c2") { | ||
"esp32c2" | ||
} else if cfg!(feature = "esp32c3") { | ||
"esp32c3" | ||
} else if cfg!(feature = "esp32c6") { | ||
"esp32c6" | ||
} else if cfg!(feature = "esp32h2") { | ||
"esp32h2" | ||
} else if cfg!(feature = "esp32s2") { | ||
"esp32s2" | ||
} else if cfg!(feature = "esp32s3") { | ||
"esp32s3" | ||
} else { | ||
unreachable!() // We've confirmed exactly one known device was selected | ||
}; | ||
|
||
// Load the configuration file for the configured device: | ||
let chip = Chip::from_str(device_name)?; | ||
let config = Config::for_chip(&chip); | ||
|
||
// Define all necessary configuration symbols for the configured device: | ||
config.define_symbols(); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 3 additions & 4 deletions
7
esp-hal/src/embassy/executor/mod.rs → esp-hal-embassy/src/executor/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
README.md
could definitely use some expansion, however I'm not really sure what should be included here and what belongs in documentation.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we add some links to the embassy book or to website? They are just 1 click further from the repo, but it might be useful.