Skip to content

Commit 47dd869

Browse files
committed
Fix most GPIO compilation errors
This commit switches to the current nightly version of the stm32f3 PAC to make use of the fixes regarding the F3 GPIO peripherals. We also need to adjust the codegen of the GPIO pin mappings a bit to account for the fact that the F373 GPIO is still special in that the PAC contains an additional `gpiod` module for it.
1 parent d5b5cbc commit 47dd869

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
[package]
22
edition = "2018"
3-
authors = ["Jorge Aparicio <[email protected]>", "Dylan Frankland <[email protected]>"]
3+
authors = [
4+
"Jorge Aparicio <[email protected]>",
5+
"Dylan Frankland <[email protected]>",
6+
]
47
categories = ["embedded", "hardware-support", "no-std"]
58
description = "Peripheral access API for STM32F3 series microcontrollers"
69
keywords = ["arm", "cortex-m", "stm32f3xx", "hal"]
@@ -22,7 +25,7 @@ cortex-m-rt = "0.6"
2225
embedded-hal = "0.2"
2326
nb = "0.1"
2427
paste = "1"
25-
stm32f3 = "0.11"
28+
stm32f3 = { git = "https://github.com/stm32-rs/stm32-rs-nightlies" }
2629

2730
[dependencies.bare-metal]
2831
version = "0.2"

codegen/src/codegen/gpio.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fn gen_gpio_ip(ip: &gpio::Ip) -> Result<()> {
2222
let ports = merge_pins_by_port(&ip.pins)?;
2323

2424
println!(r#"#[cfg(feature = "{}")]"#, feature);
25-
gen_gpio_macro_call(&ports)?;
25+
gen_gpio_macro_call(&ports, &feature)?;
2626
Ok(())
2727
}
2828

@@ -59,17 +59,17 @@ fn merge_pins_by_port(pins: &[gpio::Pin]) -> Result<Vec<Port>> {
5959
Ok(ports)
6060
}
6161

62-
fn gen_gpio_macro_call(ports: &[Port]) -> Result<()> {
62+
fn gen_gpio_macro_call(ports: &[Port], feature: &str) -> Result<()> {
6363
println!("gpio!([");
6464
for port in ports {
65-
gen_port(port)?;
65+
gen_port(port, feature)?;
6666
}
6767
println!("]);");
6868
Ok(())
6969
}
7070

71-
fn gen_port(port: &Port) -> Result<()> {
72-
let pac_module = get_port_pac_module(port);
71+
fn gen_port(port: &Port, feature: &str) -> Result<()> {
72+
let pac_module = get_port_pac_module(port, feature);
7373

7474
println!(" {{");
7575
println!(
@@ -89,12 +89,13 @@ fn gen_port(port: &Port) -> Result<()> {
8989
Ok(())
9090
}
9191

92-
fn get_port_pac_module(port: &Port) -> &'static str {
92+
fn get_port_pac_module(port: &Port, feature: &str) -> &'static str {
9393
// The registers in ports A and B have different reset values due to the
9494
// presence of debug pins, so they get dedicated PAC modules.
9595
match port.id {
9696
'A' => "gpioa",
9797
'B' => "gpiob",
98+
'D' if feature == "gpio-f373" => "gpiod",
9899
_ => "gpioc",
99100
}
100101
}

src/gpio.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,7 @@ gpio!([
11751175
],
11761176
},
11771177
{
1178-
port: (D/d, pac: gpioc),
1178+
port: (D/d, pac: gpiod),
11791179
pins: [
11801180
0 => { reset: Input<Floating>, afr: L/l, af: [1, 2, 7] },
11811181
1 => { reset: Input<Floating>, afr: L/l, af: [1, 2, 7] },

0 commit comments

Comments
 (0)