mirror of
https://github.com/esp-rs/esp-hal.git
synced 2025-09-27 20:30:35 +00:00

* inter-state * inter-state (2) * warnings fix * fix warnings * fmt + changelogs * another unsafe extern "C" doode * real fmt now * MSRV + format * Ignore unsafe_op_in_unsafe_fn lint for now in esp-hal and esp-wifi * msrv + fmt * ugh.... * get lcd_cam example right * expr_2021 -> expr experiment * gagagugu * reviews * more unneeded unsafes (help) * finish esp-hal unsafe cleanup * each unsafe call is marked separately fmt * should be good now (?) * piece was never an option... * dumb
115 lines
4.5 KiB
Rust
115 lines
4.5 KiB
Rust
use std::{error::Error as StdError, str::FromStr};
|
|
|
|
use esp_build::assert_unique_used_features;
|
|
use esp_config::{ConfigOption, Stability, Validator, Value, generate_config};
|
|
use esp_metadata::{Chip, Config};
|
|
|
|
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!(
|
|
"esp32", "esp32c2", "esp32c3", "esp32c6", "esp32h2", "esp32s2", "esp32s3"
|
|
);
|
|
|
|
// 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();
|
|
|
|
// emit config
|
|
let crate_config = generate_config(
|
|
"esp_hal_embassy",
|
|
&[
|
|
ConfigOption {
|
|
name: "low-power-wait",
|
|
description: "Enables the lower-power wait if no tasks are ready to run on the \
|
|
thread-mode executor. This allows the MCU to use less power if the workload allows. \
|
|
Recommended for battery-powered systems. May impact analog performance.",
|
|
default_value: Value::Bool(true),
|
|
constraint: None,
|
|
stability: Stability::Unstable,
|
|
active: true,
|
|
},
|
|
ConfigOption {
|
|
name: "timer-queue",
|
|
description: "The flavour of the timer queue provided by this crate. Integrated \
|
|
queues require the `executors` feature to be enabled.</p><p>If you use \
|
|
embassy-executor, the `single-integrated` queue is recommended for ease of use, \
|
|
while the `multiple-integrated` queue is recommended for performance. The \
|
|
`multiple-integrated` option needs one timer per executor.</p><p>The `generic` \
|
|
queue allows using embassy-time without the embassy executors.",
|
|
default_value: Value::String(if cfg!(feature = "executors") {
|
|
String::from("single-integrated")
|
|
} else {
|
|
String::from("generic")
|
|
}),
|
|
constraint: Some(if cfg!(feature = "executors") {
|
|
Validator::Enumeration(vec![
|
|
String::from("generic"),
|
|
String::from("single-integrated"),
|
|
String::from("multiple-integrated"),
|
|
])
|
|
} else {
|
|
Validator::Enumeration(vec![String::from("generic")])
|
|
}),
|
|
stability: Stability::Unstable,
|
|
active: cfg!(feature = "executors"),
|
|
},
|
|
ConfigOption {
|
|
name: "generic-queue-size",
|
|
description: "The capacity of the queue when the `generic` timer \
|
|
queue flavour is selected.",
|
|
default_value: Value::Integer(64),
|
|
constraint: Some(Validator::PositiveInteger),
|
|
stability: Stability::Unstable,
|
|
active: true,
|
|
},
|
|
],
|
|
true,
|
|
true,
|
|
);
|
|
|
|
println!("cargo:rustc-check-cfg=cfg(integrated_timers)");
|
|
println!("cargo:rustc-check-cfg=cfg(single_queue)");
|
|
println!("cargo:rustc-check-cfg=cfg(generic_timers)");
|
|
|
|
match &crate_config["ESP_HAL_EMBASSY_CONFIG_TIMER_QUEUE"] {
|
|
Value::String(s) if s.as_str() == "single-integrated" => {
|
|
println!("cargo:rustc-cfg=integrated_timers");
|
|
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(())
|
|
}
|