Skip to content

Commit 6ddc082

Browse files
authored
Merge pull request #116 from ra-kete/fix-pac-features
Use correct PACs for stm32f318 and stm32f378 According to the "Supported Devices" table in the stm32f3 crate's README (https://crates.io/crates/stm32f3) we were using the wrong PAC module (`stm32f3x8`) for both smt32f318 and stm32f378. Because of that we also supported some peripherals for these devices that are not actually available for them. This commit adds the correct PAC modules for the two devices in question and fixes up the HAL code to use the correct peripherals.
2 parents 2ea16b4 + 650ebcc commit 6ddc082

File tree

8 files changed

+64
-107
lines changed

8 files changed

+64
-107
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ let clocks = rcc
4545
- Split up `stm32f302` into sub-targets `stm32f302xb`,`stm32f302xc`,`stm32f302xd`,`stm32f302xe`
4646
- Bump `stm32f3` dependency to `0.11.0` ([#97](https://github.com/stm32-rs/stm32f3xx-hal/pull/97))
4747
- The `stm32f3` reexport is now renamed from `stm32` to `pac` ([#101](https://github.com/stm32-rs/stm32f3xx-hal/pull/101))
48+
- The correct `stm32f3` modules are now used for the `stm32f318` and `stm32f738`
49+
targets. As a result, some previously (wrongly) supported peripherals have
50+
been removed from these targets. ([#116](https://github.com/stm32-rs/stm32f3xx-hal/pull/116))
4851

4952
## [v0.4.3] - 2020-04-11
5053

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ direct-call-deprecated = []
5858
rt = ["stm32f3/rt"]
5959
# Any Changes here should be mirrored in README.md and src/lib.rs
6060
stm32f301 = ["stm32f3/stm32f301", "device-selected"]
61-
stm32f318 = ["stm32f3/stm32f3x8", "device-selected"]
61+
stm32f318 = ["stm32f3/stm32f301", "device-selected"]
6262
stm32f302 = ["stm32f3/stm32f302", "direct-call-deprecated"]
6363
stm32f302xb = ["stm32f302", "device-selected"]
6464
stm32f302xc = ["stm32f302", "device-selected"]
@@ -72,7 +72,7 @@ stm32f303xe = ["stm32f303", "stm32-usbd/ram_access_2x16", "device-selected"]
7272
stm32f303x6 = ["stm32f303", "device-selected"]
7373
stm32f303x8 = ["stm32f303", "device-selected"]
7474
stm32f373 = ["stm32f3/stm32f373", "device-selected"]
75-
stm32f378 = ["stm32f3/stm32f3x8", "device-selected"]
75+
stm32f378 = ["stm32f3/stm32f373", "device-selected"]
7676
stm32f334 = ["stm32f3/stm32f3x4", "device-selected"]
7777
stm32f328 = ["stm32f3/stm32f3x8", "device-selected"]
7878
stm32f358 = ["stm32f3/stm32f3x8", "device-selected"]

src/gpio.rs

Lines changed: 45 additions & 70 deletions
Large diffs are not rendered by default.

src/i2c.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use crate::gpio::gpiob::{PB6, PB7, PB8, PB9};
1212
feature = "stm32f303xc",
1313
feature = "stm32f303xd",
1414
feature = "stm32f303xe",
15-
feature = "stm32f318",
1615
feature = "stm32f328",
1716
feature = "stm32f358",
1817
feature = "stm32f398",
@@ -61,7 +60,6 @@ unsafe impl SclPin<I2C2> for PF1<AF4> {}
6160
feature = "stm32f303xc",
6261
feature = "stm32f303xd",
6362
feature = "stm32f303xe",
64-
feature = "stm32f318",
6563
feature = "stm32f328",
6664
feature = "stm32f358",
6765
feature = "stm32f398",

src/lib.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ pub use embedded_hal as hal;
8282
pub use nb;
8383
pub use nb::block;
8484

85-
#[cfg(feature = "stm32f301")]
85+
#[cfg(any(feature = "stm32f301", feature = "stm32f318"))]
8686
pub use stm32f3::stm32f301 as pac;
8787

8888
#[cfg(feature = "stm32f302")]
@@ -91,19 +91,13 @@ pub use stm32f3::stm32f302 as pac;
9191
#[cfg(feature = "stm32f303")]
9292
pub use stm32f3::stm32f303 as pac;
9393

94-
#[cfg(feature = "stm32f373")]
94+
#[cfg(any(feature = "stm32f373", feature = "stm32f378"))]
9595
pub use stm32f3::stm32f373 as pac;
9696

9797
#[cfg(feature = "stm32f334")]
9898
pub use stm32f3::stm32f3x4 as pac;
9999

100-
#[cfg(any(
101-
feature = "stm32f318",
102-
feature = "stm32f328",
103-
feature = "stm32f358",
104-
feature = "stm32f378",
105-
feature = "stm32f398"
106-
))]
100+
#[cfg(any(feature = "stm32f328", feature = "stm32f358", feature = "stm32f398"))]
107101
pub use stm32f3::stm32f3x8 as pac;
108102

109103
#[cfg(feature = "device-selected")]

src/rcc.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl APB2 {
9797
const HSI: u32 = 8_000_000; // Hz
9898

9999
// some microcontrollers do not have USB
100-
#[cfg(any(feature = "stm32f301", feature = "stm32f334",))]
100+
#[cfg(any(feature = "stm32f301", feature = "stm32f318", feature = "stm32f334",))]
101101
mod usb_clocking {
102102
use crate::rcc::PllConfig;
103103

@@ -116,7 +116,6 @@ mod usb_clocking {
116116
}
117117

118118
#[cfg(any(
119-
feature = "stm32f318",
120119
feature = "stm32f302",
121120
feature = "stm32f303",
122121
feature = "stm32f373",

src/spi.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use crate::gpio::gpioa::{PA5, PA6, PA7};
1515
feature = "stm32f328",
1616
feature = "stm32f334",
1717
feature = "stm32f358",
18-
feature = "stm32f378",
1918
feature = "stm32f398"
2019
))]
2120
use crate::gpio::gpiob::PB13;
@@ -38,7 +37,6 @@ use crate::rcc::APB1;
3837
#[cfg(any(
3938
feature = "stm32f302",
4039
feature = "stm32f303",
41-
feature = "stm32f318",
4240
feature = "stm32f328",
4341
feature = "stm32f334",
4442
feature = "stm32f358",
@@ -83,7 +81,6 @@ unsafe impl SckPin<SPI1> for PA5<AF5> {}
8381
feature = "stm32f328",
8482
feature = "stm32f334",
8583
feature = "stm32f358",
86-
feature = "stm32f378",
8784
feature = "stm32f398"
8885
))]
8986
unsafe impl SckPin<SPI2> for PB13<AF5> {}
@@ -255,7 +252,7 @@ hal! {
255252
SPI1: (spi1, APB2, spi1en, spi1rst, pclk2),
256253
}
257254

258-
#[cfg(feature = "stm32f301")]
255+
#[cfg(any(feature = "stm32f301", feature = "stm32f318"))]
259256
hal! {
260257
SPI2: (spi2, APB1, spi2en, spi2rst, pclk1),
261258
SPI3: (spi3, APB1, spi3en, spi3rst, pclk1),
@@ -264,7 +261,6 @@ hal! {
264261
#[cfg(any(
265262
feature = "stm32f302",
266263
feature = "stm32f303",
267-
feature = "stm32f318",
268264
feature = "stm32f328",
269265
feature = "stm32f358",
270266
feature = "stm32f373",

src/timer.rs

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,25 @@
22
33
use crate::hal::timer::{CountDown, Periodic};
44
#[cfg(any(
5+
feature = "stm32f301",
56
feature = "stm32f302",
67
feature = "stm32f303",
78
feature = "stm32f334",
89
feature = "stm32f318",
910
feature = "stm32f328",
1011
feature = "stm32f358",
11-
feature = "stm32f378",
1212
feature = "stm32f398",
1313
))]
1414
use crate::pac::TIM1;
1515
#[cfg(any(
1616
feature = "stm32f303",
17-
feature = "stm32f318",
1817
feature = "stm32f328",
1918
feature = "stm32f358",
20-
feature = "stm32f378",
2119
feature = "stm32f398"
2220
))]
2321
use crate::pac::TIM20;
2422
#[cfg(any(
2523
feature = "stm32f303",
26-
feature = "stm32f318",
2724
feature = "stm32f328",
2825
feature = "stm32f358",
2926
feature = "stm32f373",
@@ -33,19 +30,16 @@ use crate::pac::TIM20;
3330
use crate::pac::TIM4;
3431
#[cfg(any(
3532
feature = "stm32f303",
36-
feature = "stm32f318",
3733
feature = "stm32f328",
3834
feature = "stm32f358",
39-
feature = "stm32f378",
4035
feature = "stm32f398",
4136
))]
4237
use crate::pac::TIM8;
43-
#[cfg(feature = "stm32f373")]
38+
#[cfg(any(feature = "stm32f373", feature = "stm32f378"))]
4439
use crate::pac::{TIM12, TIM13, TIM14, TIM18, TIM19, TIM5};
4540
use crate::pac::{TIM15, TIM16, TIM17, TIM2, TIM6};
4641
#[cfg(any(
4742
feature = "stm32f303",
48-
feature = "stm32f318",
4943
feature = "stm32f328",
5044
feature = "stm32f334",
5145
feature = "stm32f358",
@@ -189,8 +183,12 @@ macro_rules! hal {
189183
}
190184
}
191185

192-
#[cfg(feature = "stm32f301")]
186+
#[cfg(any(feature = "stm32f301", feature = "stm32f318"))]
193187
hal! {
188+
{
189+
TIM1: (tim1, tim1en, tim1rst),
190+
APB2: (apb2, pclk2),
191+
},
194192
{
195193
TIM2: (tim2, tim2en, tim2rst),
196194
APB1: (apb1, pclk1),
@@ -325,7 +323,7 @@ hal! {
325323
},
326324
}
327325

328-
#[cfg(feature = "stm32f373")]
326+
#[cfg(any(feature = "stm32f373", feature = "stm32f378"))]
329327
hal! {
330328
{
331329
TIM2: (tim2, tim2en, tim2rst),
@@ -385,13 +383,7 @@ hal! {
385383
},
386384
}
387385

388-
#[cfg(any(
389-
feature = "stm32f318",
390-
feature = "stm32f328",
391-
feature = "stm32f358",
392-
feature = "stm32f378",
393-
feature = "stm32f398"
394-
))]
386+
#[cfg(any(feature = "stm32f328", feature = "stm32f358", feature = "stm32f398"))]
395387
hal! {
396388
{
397389
TIM1: (tim1, tim1en, tim1rst),

0 commit comments

Comments
 (0)