1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
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'
// - 'pdma'
// - 'rmt'
// - 'spi3'
// - 'systimer'
// - '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",
"multi_core",
"dac",
"i2c1",
"pdma",
"rmt",
"spi3",
"timg1",
"uart2",
]
} else if esp32c2 {
vec!["esp32c2", "riscv", "single_core", "gdma", "systimer"]
} else if esp32c3 {
vec![
"esp32c3",
"riscv",
"single_core",
"gdma",
"rmt",
"spi3",
"systimer",
"timg1",
"usb_serial_jtag",
]
} else if esp32s2 {
vec![
"esp32s2",
"xtensa",
"single_core",
"dac",
"i2c1",
"pdma",
"rmt",
"spi3",
"systimer",
"timg1",
"usb_otg",
]
} else if esp32s3 {
vec![
"esp32s3",
"xtensa",
"multi_core",
"gdma",
"i2c1",
"rmt",
"spi3",
"systimer",
"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}");
}
}