aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/build.rs
diff options
context:
space:
mode:
authorliebman <[email protected]>2025-12-13 08:36:04 -0800
committerliebman <[email protected]>2025-12-13 08:38:11 -0800
commit803b809e5dbe7651b7171917e02289b067e90dad (patch)
treed8ee8b31c0ab918b621dd2247b4869a02d0a1d81 /embassy-stm32/build.rs
parentd2740f8fad566f30bed24df970f1297209005126 (diff)
stm32: set pins to ANALOG on init
Diffstat (limited to 'embassy-stm32/build.rs')
-rw-r--r--embassy-stm32/build.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs
index 46d6290e7..665717e26 100644
--- a/embassy-stm32/build.rs
+++ b/embassy-stm32/build.rs
@@ -950,6 +950,24 @@ fn main() {
950 } 950 }
951 } 951 }
952 952
953 for p in METADATA.peripherals {
954 // only set GPIOs to analog mode for GPIOs that are not version 1
955 // version 1 uses 0b00 for analog mode instead of 0b11 and has no ALTERNATE mode (0b10 for v2)
956 if p.registers.is_some() && p.registers.as_ref().unwrap().kind == "gpio" && p.registers.as_ref().unwrap().version != "v1" {
957 let port = format_ident!("{}", p.name);
958 let value = if p.name == "GPIOA" {
959 // GPIOA is special because it has a special mode for PA13 and PA14 which are SWDIO and SWDCLK
960 // and we leave those as ALTERNATE mode (0b10)
961 0b11_10_10_11_11_11_11_11_11_11_11_11_11_11_11_11_u32
962 } else {
963 u32::MAX
964 };
965 gg.extend(quote! {
966 crate::pac::#port.moder().modify(|w| w.0 = #value);
967 })
968 }
969 }
970
953 let fname = format_ident!("init_{}", kind); 971 let fname = format_ident!("init_{}", kind);
954 g.extend(quote! { 972 g.extend(quote! {
955 pub unsafe fn #fname(){ 973 pub unsafe fn #fname(){