aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-stm32/Cargo.toml3
-rw-r--r--embassy-stm32/build.rs77
-rw-r--r--embassy-stm32/src/time_driver.rs8
-rw-r--r--examples/stm32f0/Cargo.toml2
-rw-r--r--examples/stm32f1/Cargo.toml2
-rw-r--r--examples/stm32f3/Cargo.toml2
-rw-r--r--examples/stm32f4/Cargo.toml2
-rw-r--r--examples/stm32f7/Cargo.toml2
-rw-r--r--examples/stm32g0/Cargo.toml2
-rw-r--r--examples/stm32g4/Cargo.toml2
-rw-r--r--examples/stm32h7/Cargo.toml2
-rw-r--r--examples/stm32l0/Cargo.toml2
-rw-r--r--examples/stm32l1/Cargo.toml2
-rw-r--r--examples/stm32l4/Cargo.toml2
-rw-r--r--examples/stm32wb55/Cargo.toml2
-rw-r--r--examples/stm32wl55/Cargo.toml2
16 files changed, 88 insertions, 26 deletions
diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml
index ee5e7b173..c0c024b73 100644
--- a/embassy-stm32/Cargo.toml
+++ b/embassy-stm32/Cargo.toml
@@ -28,9 +28,7 @@ stm32-metapac = { version = "0.1.0", path = "../stm32-metapac", features = ["rt"
28vcell = { version = "0.1.3", optional = true } 28vcell = { version = "0.1.3", optional = true }
29bxcan = "0.6.2" 29bxcan = "0.6.2"
30nb = "1.0.0" 30nb = "1.0.0"
31
32seq-macro = "0.2.2" 31seq-macro = "0.2.2"
33
34cfg-if = "1.0.0" 32cfg-if = "1.0.0"
35 33
36[build-dependencies] 34[build-dependencies]
@@ -46,6 +44,7 @@ exti = []
46# Features starting with `_` are for internal use only. They're not intended 44# Features starting with `_` are for internal use only. They're not intended
47# to be enabled by other crates, and are not covered by semver guarantees. 45# to be enabled by other crates, and are not covered by semver guarantees.
48_time-driver = ["embassy/time-tick-32768hz"] 46_time-driver = ["embassy/time-tick-32768hz"]
47time-driver-any = ["_time-driver"]
49time-driver-tim2 = ["_time-driver"] 48time-driver-tim2 = ["_time-driver"]
50time-driver-tim3 = ["_time-driver"] 49time-driver-tim3 = ["_time-driver"]
51 50
diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs
index 517ee57ba..f3c8cd58e 100644
--- a/embassy-stm32/build.rs
+++ b/embassy-stm32/build.rs
@@ -4,13 +4,18 @@ use std::fs;
4use std::path::PathBuf; 4use std::path::PathBuf;
5 5
6fn main() { 6fn main() {
7 let chip_name = env::vars_os() 7 let chip_name = match env::vars()
8 .map(|(a, _)| a.to_string_lossy().to_string()) 8 .map(|(a, _)| a)
9 .find(|x| x.starts_with("CARGO_FEATURE_STM32")) 9 .filter(|x| x.starts_with("CARGO_FEATURE_STM32"))
10 .expect("No stm32xx Cargo feature enabled") 10 .get_one()
11 .strip_prefix("CARGO_FEATURE_") 11 {
12 .unwrap() 12 Ok(x) => x,
13 .to_ascii_lowercase(); 13 Err(GetOneError::None) => panic!("No stm32xx Cargo feature enabled"),
14 Err(GetOneError::Multiple) => panic!("Multiple stm32xx Cargo features enabled"),
15 }
16 .strip_prefix("CARGO_FEATURE_")
17 .unwrap()
18 .to_ascii_lowercase();
14 19
15 struct Peripheral { 20 struct Peripheral {
16 kind: String, 21 kind: String,
@@ -120,5 +125,63 @@ fn main() {
120 println!("cargo:rustc-cfg={}", &chip_name[..chip_name.len() - 2]); 125 println!("cargo:rustc-cfg={}", &chip_name[..chip_name.len() - 2]);
121 } 126 }
122 127
128 // ========
129 // Handle time-driver-XXXX features.
130
131 let time_driver = match env::vars()
132 .map(|(a, _)| a)
133 .filter(|x| x.starts_with("CARGO_FEATURE_TIME_DRIVER_"))
134 .get_one()
135 {
136 Ok(x) => Some(
137 x.strip_prefix("CARGO_FEATURE_TIME_DRIVER_")
138 .unwrap()
139 .to_ascii_lowercase(),
140 ),
141 Err(GetOneError::None) => None,
142 Err(GetOneError::Multiple) => panic!("Multiple stm32xx Cargo features enabled"),
143 };
144
145 match time_driver.as_ref().map(|x| x.as_ref()) {
146 None => {}
147 Some("tim2") => println!("cargo:rustc-cfg=time_driver_tim2"),
148 Some("tim3") => println!("cargo:rustc-cfg=time_driver_tim3"),
149 Some("any") => {
150 if singletons.contains(&"TIM2".to_string()) {
151 println!("cargo:rustc-cfg=time_driver_tim2");
152 } else if singletons.contains(&"TIM3".to_string()) {
153 println!("cargo:rustc-cfg=time_driver_tim3");
154 } else {
155 panic!("time-driver-any requested, but the chip doesn't have TIM2 or TIM3.")
156 }
157 }
158 _ => panic!("unknown time_driver {:?}", time_driver),
159 }
160
161 // Handle time-driver-XXXX features.
162 if env::var("CARGO_FEATURE_TIME_DRIVER_ANY").is_ok() {}
163 println!("cargo:rustc-cfg={}", &chip_name[..chip_name.len() - 2]);
164
123 println!("cargo:rerun-if-changed=build.rs"); 165 println!("cargo:rerun-if-changed=build.rs");
124} 166}
167
168enum GetOneError {
169 None,
170 Multiple,
171}
172
173trait IteratorExt: Iterator {
174 fn get_one(self) -> Result<Self::Item, GetOneError>;
175}
176
177impl<T: Iterator> IteratorExt for T {
178 fn get_one(mut self) -> Result<Self::Item, GetOneError> {
179 match self.next() {
180 None => Err(GetOneError::None),
181 Some(res) => match self.next() {
182 Some(_) => Err(GetOneError::Multiple),
183 None => Ok(res),
184 },
185 }
186 }
187}
diff --git a/embassy-stm32/src/time_driver.rs b/embassy-stm32/src/time_driver.rs
index d20929e17..5affb1fae 100644
--- a/embassy-stm32/src/time_driver.rs
+++ b/embassy-stm32/src/time_driver.rs
@@ -18,17 +18,17 @@ use self::sealed::Instance as _;
18 18
19const ALARM_COUNT: usize = 3; 19const ALARM_COUNT: usize = 3;
20 20
21#[cfg(feature = "time-driver-tim2")] 21#[cfg(time_driver_tim2)]
22type T = peripherals::TIM2; 22type T = peripherals::TIM2;
23#[cfg(feature = "time-driver-tim3")] 23#[cfg(time_driver_tim3)]
24type T = peripherals::TIM3; 24type T = peripherals::TIM3;
25 25
26#[cfg(feature = "time-driver-tim2")] 26#[cfg(time_driver_tim2)]
27#[interrupt] 27#[interrupt]
28fn TIM2() { 28fn TIM2() {
29 DRIVER.on_interrupt() 29 DRIVER.on_interrupt()
30} 30}
31#[cfg(feature = "time-driver-tim3")] 31#[cfg(time_driver_tim3)]
32#[interrupt] 32#[interrupt]
33fn TIM3() { 33fn TIM3() {
34 DRIVER.on_interrupt() 34 DRIVER.on_interrupt()
diff --git a/examples/stm32f0/Cargo.toml b/examples/stm32f0/Cargo.toml
index f13ef0949..ca06db031 100644
--- a/examples/stm32f0/Cargo.toml
+++ b/examples/stm32f0/Cargo.toml
@@ -14,5 +14,5 @@ defmt = "0.3"
14defmt-rtt = "0.3" 14defmt-rtt = "0.3"
15panic-probe = "0.3" 15panic-probe = "0.3"
16embassy = { path = "../../embassy", features = ["defmt"] } 16embassy = { path = "../../embassy", features = ["defmt"] }
17embassy-stm32 = { path = "../../embassy-stm32", features = ["defmt", "memory-x", "stm32f030f4", "time-driver-tim3"] } 17embassy-stm32 = { path = "../../embassy-stm32", features = ["defmt", "memory-x", "stm32f030f4", "time-driver-any"] }
18 18
diff --git a/examples/stm32f1/Cargo.toml b/examples/stm32f1/Cargo.toml
index 765e91b5d..44673104e 100644
--- a/examples/stm32f1/Cargo.toml
+++ b/examples/stm32f1/Cargo.toml
@@ -8,7 +8,7 @@ resolver = "2"
8[dependencies] 8[dependencies]
9embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] } 9embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] }
10embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] } 10embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] }
11embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32f103c8", "unstable-pac", "memory-x", "time-driver-tim2"] } 11embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32f103c8", "unstable-pac", "memory-x", "time-driver-any"] }
12 12
13defmt = "0.3" 13defmt = "0.3"
14defmt-rtt = "0.3" 14defmt-rtt = "0.3"
diff --git a/examples/stm32f3/Cargo.toml b/examples/stm32f3/Cargo.toml
index fdc627f2e..d36188798 100644
--- a/examples/stm32f3/Cargo.toml
+++ b/examples/stm32f3/Cargo.toml
@@ -8,7 +8,7 @@ resolver = "2"
8[dependencies] 8[dependencies]
9embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] } 9embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] }
10embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] } 10embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] }
11embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32f303vc", "unstable-pac", "memory-x", "time-driver-tim2", "exti"] } 11embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32f303vc", "unstable-pac", "memory-x", "time-driver-any", "exti"] }
12 12
13defmt = "0.3" 13defmt = "0.3"
14defmt-rtt = "0.3" 14defmt-rtt = "0.3"
diff --git a/examples/stm32f4/Cargo.toml b/examples/stm32f4/Cargo.toml
index c75491081..070d17d48 100644
--- a/examples/stm32f4/Cargo.toml
+++ b/examples/stm32f4/Cargo.toml
@@ -9,7 +9,7 @@ resolver = "2"
9[dependencies] 9[dependencies]
10embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] } 10embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] }
11embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] } 11embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] }
12embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32f429zi", "unstable-pac", "memory-x", "time-driver-tim2", "exti"] } 12embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32f429zi", "unstable-pac", "memory-x", "time-driver-any", "exti"] }
13 13
14defmt = "0.3" 14defmt = "0.3"
15defmt-rtt = "0.3" 15defmt-rtt = "0.3"
diff --git a/examples/stm32f7/Cargo.toml b/examples/stm32f7/Cargo.toml
index d9c7a67e5..f9bbd8757 100644
--- a/examples/stm32f7/Cargo.toml
+++ b/examples/stm32f7/Cargo.toml
@@ -8,7 +8,7 @@ resolver = "2"
8[dependencies] 8[dependencies]
9embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] } 9embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] }
10embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] } 10embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] }
11embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "net", "stm32f767zi", "unstable-pac", "time-driver-tim2", "exti"] } 11embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "net", "stm32f767zi", "unstable-pac", "time-driver-any", "exti"] }
12embassy-net = { path = "../../embassy-net", default-features = false, features = ["defmt", "tcp", "medium-ethernet", "pool-16"] } 12embassy-net = { path = "../../embassy-net", default-features = false, features = ["defmt", "tcp", "medium-ethernet", "pool-16"] }
13 13
14defmt = "0.3" 14defmt = "0.3"
diff --git a/examples/stm32g0/Cargo.toml b/examples/stm32g0/Cargo.toml
index 511d99689..692267501 100644
--- a/examples/stm32g0/Cargo.toml
+++ b/examples/stm32g0/Cargo.toml
@@ -8,7 +8,7 @@ resolver = "2"
8[dependencies] 8[dependencies]
9embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] } 9embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] }
10embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] } 10embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] }
11embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "time-driver-tim2", "stm32g071rb", "memory-x", "unstable-pac", "exti"] } 11embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "time-driver-any", "stm32g071rb", "memory-x", "unstable-pac", "exti"] }
12 12
13defmt = "0.3" 13defmt = "0.3"
14defmt-rtt = "0.3" 14defmt-rtt = "0.3"
diff --git a/examples/stm32g4/Cargo.toml b/examples/stm32g4/Cargo.toml
index a0a2e4650..d61eb86cd 100644
--- a/examples/stm32g4/Cargo.toml
+++ b/examples/stm32g4/Cargo.toml
@@ -8,7 +8,7 @@ resolver = "2"
8[dependencies] 8[dependencies]
9embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] } 9embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] }
10embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] } 10embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] }
11embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "time-driver-tim3", "stm32g491re", "memory-x", "unstable-pac", "exti"] } 11embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "time-driver-any", "stm32g491re", "memory-x", "unstable-pac", "exti"] }
12embassy-hal-common = {version = "0.1.0", path = "../../embassy-hal-common" } 12embassy-hal-common = {version = "0.1.0", path = "../../embassy-hal-common" }
13 13
14defmt = "0.3" 14defmt = "0.3"
diff --git a/examples/stm32h7/Cargo.toml b/examples/stm32h7/Cargo.toml
index de294318f..67f1cfc94 100644
--- a/examples/stm32h7/Cargo.toml
+++ b/examples/stm32h7/Cargo.toml
@@ -10,7 +10,7 @@ resolver = "2"
10[dependencies] 10[dependencies]
11embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] } 11embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] }
12embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] } 12embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] }
13embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32h743zi", "net", "time-driver-tim2", "exti", "unstable-pac"] } 13embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32h743zi", "net", "time-driver-any", "exti", "unstable-pac"] }
14embassy-net = { path = "../../embassy-net", default-features = false, features = ["defmt", "tcp", "medium-ethernet", "pool-16"] } 14embassy-net = { path = "../../embassy-net", default-features = false, features = ["defmt", "tcp", "medium-ethernet", "pool-16"] }
15embassy-hal-common = { path = "../../embassy-hal-common", default-features = false, features = ["defmt"] } 15embassy-hal-common = { path = "../../embassy-hal-common", default-features = false, features = ["defmt"] }
16 16
diff --git a/examples/stm32l0/Cargo.toml b/examples/stm32l0/Cargo.toml
index 20a2ec8d0..f101c15f5 100644
--- a/examples/stm32l0/Cargo.toml
+++ b/examples/stm32l0/Cargo.toml
@@ -8,7 +8,7 @@ resolver = "2"
8[dependencies] 8[dependencies]
9embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] } 9embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] }
10embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] } 10embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] }
11embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32l072cz", "time-driver-tim3", "exti", "memory-x"] } 11embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32l072cz", "time-driver-any", "exti", "memory-x"] }
12 12
13embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["sx127x", "time", "defmt"] } 13embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["sx127x", "time", "defmt"] }
14 14
diff --git a/examples/stm32l1/Cargo.toml b/examples/stm32l1/Cargo.toml
index 212fe7103..aad7cf6d2 100644
--- a/examples/stm32l1/Cargo.toml
+++ b/examples/stm32l1/Cargo.toml
@@ -8,7 +8,7 @@ resolver = "2"
8[dependencies] 8[dependencies]
9embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] } 9embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] }
10embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] } 10embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] }
11embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32l151cb-a", "time-driver-tim2", "memory-x"] } 11embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32l151cb-a", "time-driver-any", "memory-x"] }
12 12
13defmt = "0.3" 13defmt = "0.3"
14defmt-rtt = "0.3" 14defmt-rtt = "0.3"
diff --git a/examples/stm32l4/Cargo.toml b/examples/stm32l4/Cargo.toml
index 71086961d..d01c76f6e 100644
--- a/examples/stm32l4/Cargo.toml
+++ b/examples/stm32l4/Cargo.toml
@@ -10,7 +10,7 @@ resolver = "2"
10[dependencies] 10[dependencies]
11embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt" ] } 11embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt" ] }
12embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] } 12embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] }
13embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "unstable-pac", "stm32l4s5vi", "time-driver-tim2", "exti"] } 13embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "unstable-pac", "stm32l4s5vi", "time-driver-any", "exti"] }
14 14
15defmt = "0.3" 15defmt = "0.3"
16defmt-rtt = "0.3" 16defmt-rtt = "0.3"
diff --git a/examples/stm32wb55/Cargo.toml b/examples/stm32wb55/Cargo.toml
index 03826e476..7ba244ac6 100644
--- a/examples/stm32wb55/Cargo.toml
+++ b/examples/stm32wb55/Cargo.toml
@@ -8,7 +8,7 @@ resolver = "2"
8[dependencies] 8[dependencies]
9embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] } 9embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] }
10embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] } 10embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] }
11embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32wb55cc", "time-driver-tim2", "exti"] } 11embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32wb55cc", "time-driver-any", "exti"] }
12 12
13defmt = "0.3" 13defmt = "0.3"
14defmt-rtt = "0.3" 14defmt-rtt = "0.3"
diff --git a/examples/stm32wl55/Cargo.toml b/examples/stm32wl55/Cargo.toml
index dd55554d2..f68fb4fa2 100644
--- a/examples/stm32wl55/Cargo.toml
+++ b/examples/stm32wl55/Cargo.toml
@@ -8,7 +8,7 @@ resolver = "2"
8[dependencies] 8[dependencies]
9embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] } 9embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] }
10embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] } 10embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] }
11embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32wl55jc-cm4", "time-driver-tim2", "memory-x", "subghz", "unstable-pac", "exti"] } 11embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32wl55jc-cm4", "time-driver-any", "memory-x", "subghz", "unstable-pac", "exti"] }
12embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["stm32wl", "time"] } 12embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["stm32wl", "time"] }
13 13
14lorawan-device = { git = "https://github.com/ivajloip/rust-lorawan.git", rev = "0de1a2a31933f7c97887b5718c1755fa5ab93a42", default-features = false, features = ["async"] } 14lorawan-device = { git = "https://github.com/ivajloip/rust-lorawan.git", rev = "0de1a2a31933f7c97887b5718c1755fa5ab93a42", default-features = false, features = ["async"] }