Configure via esp-config
This commit is contained in:
parent
b92d6fcecf
commit
a572e631df
@ -51,12 +51,6 @@ defmt = ["dep:defmt", "embassy-executor?/defmt", "esp-hal/defmt"]
|
||||
log = ["dep:log"]
|
||||
## Provide `Executor` and `InterruptExecutor`
|
||||
executors = ["dep:embassy-executor", "esp-hal/__esp_hal_embassy"]
|
||||
## Use a single generic timer queue that can be used with any executor. If not set, the crate
|
||||
## provides an executor-integrated timer queue which does not need a set capacity.
|
||||
generic-queue = ["embassy-time-queue-driver/_generic-queue"]
|
||||
## Use a single, global timer queue. This option only needs a single alarm, no matter how many
|
||||
## executors are used. Ignored if `generic-queue` is set.
|
||||
single-queue = []
|
||||
|
||||
[lints.rust]
|
||||
unexpected_cfgs = "allow"
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
use std::{error::Error, str::FromStr};
|
||||
use std::{error::Error as StdError, str::FromStr};
|
||||
|
||||
use esp_build::assert_unique_used_features;
|
||||
use esp_config::{generate_config, Validator, Value};
|
||||
use esp_config::{generate_config, Error, Validator, Value};
|
||||
use esp_metadata::{Chip, Config};
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
fn main() -> Result<(), Box<dyn StdError>> {
|
||||
// NOTE: update when adding new device support!
|
||||
// Ensure that exactly one chip has been specified:
|
||||
assert_unique_used_features!(
|
||||
@ -39,7 +39,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
config.define_symbols();
|
||||
|
||||
// emit config
|
||||
generate_config(
|
||||
let crate_config = generate_config(
|
||||
"esp_hal_embassy",
|
||||
&[(
|
||||
"low-power-wait",
|
||||
@ -52,7 +52,29 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
"The size of the generic queue. Only used if `generic-queue` is enabled.",
|
||||
Value::Integer(64),
|
||||
Some(Validator::PositiveInteger),
|
||||
)],
|
||||
),
|
||||
(
|
||||
"timer-queue",
|
||||
"The flavour of the timer queue provided by this crate. Accepts one of 'single-integrated', 'multiple-integrated' or 'generic'. Integrated queues require the 'executors' feature to be enabled.",
|
||||
Value::String(if cfg!(feature = "executors") {
|
||||
String::from("single-integrated")
|
||||
} else {
|
||||
String::from("generic")
|
||||
}),
|
||||
Some(Validator::Custom(Box::new(|value| {
|
||||
let Value::String(string) = value else {
|
||||
return Err(Error::Validation(String::from("Expected a string")));
|
||||
};
|
||||
|
||||
match string.as_str() {
|
||||
"single-integrated" => Ok(()), // preferred for ease of use
|
||||
"multiple-integrated" => Ok(()), // preferred for performance
|
||||
"generic" => Ok(()), // allows using embassy-time without the embassy executors
|
||||
_ => Err(Error::Validation(format!("Expected 'single-integrated', 'multiple-integrated' or 'generic', found {string}")))
|
||||
}
|
||||
})))
|
||||
)
|
||||
],
|
||||
true,
|
||||
);
|
||||
|
||||
@ -60,14 +82,19 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
println!("cargo:rustc-check-cfg=cfg(single_queue)");
|
||||
println!("cargo:rustc-check-cfg=cfg(generic_timers)");
|
||||
|
||||
if cfg!(feature = "generic-queue") {
|
||||
println!("cargo:rustc-cfg=generic_timers");
|
||||
println!("cargo:rustc-cfg=single_queue");
|
||||
} else {
|
||||
match &crate_config["ESP_HAL_EMBASSY_TIMER_QUEUE"] {
|
||||
Value::String(s) if s.as_str() == "single-integrated" => {
|
||||
println!("cargo:rustc-cfg=integrated_timers");
|
||||
if cfg!(feature = "single-queue") {
|
||||
println!("cargo:rustc-cfg=single_queue");
|
||||
}
|
||||
Value::String(s) if s.as_str() == "multiple-integrated" => {
|
||||
println!("cargo:rustc-cfg=integrated_timers");
|
||||
}
|
||||
Value::String(s) if s.as_str() == "generic" => {
|
||||
println!("cargo:rustc-cfg=generic-timers");
|
||||
println!("cargo:rustc-cfg=single_queue");
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@ -2,9 +2,6 @@
|
||||
//! code.
|
||||
|
||||
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
||||
//% FEATURES(integrated): unstable embassy
|
||||
//% FEATURES(integrated_single): unstable embassy esp-hal-embassy/single-queue
|
||||
//% FEATURES(generic): unstable embassy esp-hal-embassy/generic-queue
|
||||
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
//! Reproduction and regression test for a sneaky issue.
|
||||
|
||||
//% CHIPS: esp32 esp32s2 esp32s3 esp32c3 esp32c6 esp32h2
|
||||
//% FEATURES(integrated): unstable embassy
|
||||
//% FEATURES(integrated_single): unstable embassy esp-hal-embassy/single-queue
|
||||
//% FEATURES(generic): unstable embassy esp-hal-embassy/generic-queue
|
||||
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
//! Embassy timer and executor Test
|
||||
|
||||
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
||||
//% FEATURES(integrated): unstable embassy
|
||||
//% FEATURES(integrated_single): unstable embassy esp-hal-embassy/single-queue
|
||||
//% FEATURES(generic): unstable embassy esp-hal-embassy/generic-queue
|
||||
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
@ -6,9 +6,6 @@
|
||||
//! async API works for user handlers automatically.
|
||||
|
||||
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
||||
//% FEATURES(integrated): unstable embassy
|
||||
//% FEATURES(integrated_single): unstable embassy esp-hal-embassy/single-queue
|
||||
//% FEATURES(generic): unstable embassy esp-hal-embassy/generic-queue
|
||||
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
//! Embassy executor benchmark, used to try out optimization ideas.
|
||||
|
||||
//% CHIPS: esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
||||
//% FEATURES:
|
||||
// FEATURES: esp-hal-embassy/single-queue
|
||||
// FEATURES: esp-hal-embassy/generic-queue
|
||||
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user