diff options
Diffstat (limited to 'embassy-stm32')
| -rw-r--r-- | embassy-stm32/build.rs | 18 |
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(){ |
