aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-stm32/Cargo.toml4
-rw-r--r--embassy-stm32/build.rs23
2 files changed, 13 insertions, 14 deletions
diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml
index 7e11e2631..01a9d482f 100644
--- a/embassy-stm32/Cargo.toml
+++ b/embassy-stm32/Cargo.toml
@@ -58,7 +58,7 @@ rand_core = "0.6.3"
58sdio-host = "0.5.0" 58sdio-host = "0.5.0"
59embedded-sdmmc = { git = "https://github.com/embassy-rs/embedded-sdmmc-rs", rev = "a4f293d3a6f72158385f79c98634cb8a14d0d2fc", optional = true } 59embedded-sdmmc = { git = "https://github.com/embassy-rs/embedded-sdmmc-rs", rev = "a4f293d3a6f72158385f79c98634cb8a14d0d2fc", optional = true }
60critical-section = "1.1" 60critical-section = "1.1"
61stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-8381654ade324de3945c3c755d359686e957e99b" } 61stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-1374ed622714ef4702826699ca21cc1f741f4133" }
62vcell = "0.1.3" 62vcell = "0.1.3"
63bxcan = "0.7.0" 63bxcan = "0.7.0"
64nb = "1.0.0" 64nb = "1.0.0"
@@ -76,7 +76,7 @@ critical-section = { version = "1.1", features = ["std"] }
76[build-dependencies] 76[build-dependencies]
77proc-macro2 = "1.0.36" 77proc-macro2 = "1.0.36"
78quote = "1.0.15" 78quote = "1.0.15"
79stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-8381654ade324de3945c3c755d359686e957e99b", default-features = false, features = ["metadata"]} 79stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-1374ed622714ef4702826699ca21cc1f741f4133", default-features = false, features = ["metadata"]}
80 80
81 81
82[features] 82[features]
diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs
index 1307656a0..6b41cd397 100644
--- a/embassy-stm32/build.rs
+++ b/embassy-stm32/build.rs
@@ -6,7 +6,7 @@ use std::{env, fs};
6use proc_macro2::{Ident, TokenStream}; 6use proc_macro2::{Ident, TokenStream};
7use quote::{format_ident, quote}; 7use quote::{format_ident, quote};
8use stm32_metapac::metadata::ir::{BlockItemInner, Enum, FieldSet}; 8use stm32_metapac::metadata::ir::{BlockItemInner, Enum, FieldSet};
9use stm32_metapac::metadata::{MemoryRegionKind, PeripheralRccRegister, METADATA}; 9use stm32_metapac::metadata::{MemoryRegionKind, PeripheralRccRegister, StopMode, METADATA};
10 10
11fn main() { 11fn main() {
12 let target = env::var("TARGET").unwrap(); 12 let target = env::var("TARGET").unwrap();
@@ -557,18 +557,18 @@ fn main() {
557 }; 557 };
558 558
559 /* 559 /*
560 If LP and non-LP peripherals share the same RCC enable bit, then a refcount leak will result. 560 A refcount leak can result if the same field is shared by peripherals with different stop modes
561 561
562 This should be checked in stm32-data-gen. 562 This condition should be checked in stm32-data
563 */ 563 */
564 let stop_refcount = if p.name.starts_with("LP") { 564 let stop_refcount = match rcc.stop_mode {
565 quote! { REFCOUNT_STOP2 } 565 StopMode::Standby => None,
566 } else { 566 StopMode::Stop2 => Some(quote! { REFCOUNT_STOP2 }),
567 quote! { REFCOUNT_STOP1 } 567 StopMode::Stop1 => Some(quote! { REFCOUNT_STOP1 }),
568 }; 568 };
569 569
570 let (incr_stop_refcount, decr_stop_refcount) = if p.name != "RTC" { 570 let (incr_stop_refcount, decr_stop_refcount) = match stop_refcount {
571 ( 571 Some(stop_refcount) => (
572 quote! { 572 quote! {
573 #[cfg(feature = "low-power")] 573 #[cfg(feature = "low-power")]
574 unsafe { crate::rcc::#stop_refcount += 1 }; 574 unsafe { crate::rcc::#stop_refcount += 1 };
@@ -577,9 +577,8 @@ fn main() {
577 #[cfg(feature = "low-power")] 577 #[cfg(feature = "low-power")]
578 unsafe { crate::rcc::#stop_refcount -= 1 }; 578 unsafe { crate::rcc::#stop_refcount -= 1 };
579 }, 579 },
580 ) 580 ),
581 } else { 581 None => (TokenStream::new(), TokenStream::new()),
582 (quote! {}, quote! {})
583 }; 582 };
584 583
585 g.extend(quote! { 584 g.extend(quote! {