esp-hal/esp-hal-common/build.rs
Scott Mabin 0000d46ac5 Embassy init updates:
- Rename timg feature to timg0 to better refect which TG is being used
- Use the time_driver::TimerType in the signature of init to fix #268
- Update examples
- Fix CI features
- Add timg0 cfg to build.rs
2022-12-08 06:36:42 -08:00

115 lines
2.9 KiB
Rust

fn main() {
let esp32 = cfg!(feature = "esp32");
let esp32c2 = cfg!(feature = "esp32c2");
let esp32c3 = cfg!(feature = "esp32c3");
let esp32s2 = cfg!(feature = "esp32s2");
let esp32s3 = cfg!(feature = "esp32s3");
// Ensure that exactly one chip has been specified
let chip_features = [esp32, esp32c2, esp32c3, esp32s2, esp32s3];
match chip_features.iter().filter(|&&f| f).count() {
1 => {}
n => panic!("Exactly 1 chip must be enabled via its Cargo feature, {n} provided"),
}
// Define all required configuration symbols for the enabled chip.
//
// When adding a new device, at the bare minimum the following symbols MUST be
// defined:
// - the name of the device
// - the architecture ('riscv' or 'xtensa')
// - the core count ('single_core' or 'multi_core')
//
// Additionally, the following symbols MAY be defined if present:
// - 'dac'
// - 'gdma'
// - 'i2c1'
// - 'i2s'
// - 'mcpwm'
// - 'pdma'
// - 'rmt'
// - 'spi3'
// - 'systimer'
// - 'timg0'
// - 'timg1'
// - 'uart2'
// - 'usb_otg'
// - 'usb_serial_jtag'
//
// New symbols can be added as needed, but please be sure to update both this
// comment and the required vectors below.
let symbols = if esp32 {
vec![
"esp32",
"xtensa",
"mcpwm",
"multi_core",
"dac",
"i2c1",
"i2s",
"pdma",
"rmt",
"spi3",
"timg0",
"timg1",
"uart2",
]
} else if esp32c2 {
vec!["esp32c2", "riscv", "single_core", "gdma", "systimer", "timg0"]
} else if esp32c3 {
vec![
"esp32c3",
"riscv",
"single_core",
"gdma",
"i2s",
"rmt",
"spi3",
"systimer",
"timg0",
"timg1",
"usb_serial_jtag",
]
} else if esp32s2 {
vec![
"esp32s2",
"xtensa",
"single_core",
"dac",
"i2c1",
"i2s",
"pdma",
"rmt",
"spi3",
"systimer",
"timg0",
"timg1",
"usb_otg",
]
} else if esp32s3 {
vec![
"esp32s3",
"xtensa",
"multi_core",
"gdma",
"i2c1",
"i2s",
"mcpwm",
"rmt",
"spi3",
"systimer",
"timg0",
"timg1",
"uart2",
"usb_otg",
"usb_serial_jtag",
]
} else {
unreachable!(); // We've already confirmed exactly one chip was selected
};
for symbol in symbols {
println!("cargo:rustc-cfg={symbol}");
}
}