Skip to content

Commit 3519f37

Browse files
danielgallagher0Sh3Rm4n
authored andcommitted
Update SPI impls for STM32F373 and STM32F378
Based on the datasheets for the 373 and 378, the following pins and peripherals are supported on both processors: - SPI1: - SCK: PA5<AF5>, PA12<AF6>, PB3<AF5>, PC7<AF5> - MISO: PA6<AF5>, PA13<AF6>, PB4<AF5>, PC8<AF5> - MOSI: PA7<AF5>, PB0<AF5>, PB5<AF5>, PC9<AF5>, PF6<AF5> - SPI2: - SCK: PA8<AF5>, PB8<AF5>, PB10<AF5>, PD7<AF5>, PD8<AF5> - MISO: PA9<AF5>, PB14<AF5>, PC2<AF5>, PD3<AF5> - MOSI: PA10<AF5>, PB15<AF5>, PC3<AF5>, PD4<AF5> - SPI3: - SCK: PA1<AF6>, PB3<AF6>, PC10<AF6> - MISO: PA2<AF6>, PB4<AF6>, PC11<AF6> - MOSI: PA3<AF6>, PB5<AF6>, PC12<AF6>
1 parent 259a610 commit 3519f37

File tree

1 file changed

+63
-1
lines changed

1 file changed

+63
-1
lines changed

src/spi.rs

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ use crate::stm32::spi1;
1818
))]
1919
use crate::stm32::SPI4;
2020

21+
#[cfg(any(feature = "stm32f373", feature = "stm32f378"))]
22+
use crate::gpio::gpioa::{PA1, PA10, PA12, PA13, PA2, PA3, PA8, PA9};
2123
#[cfg(any(
2224
feature = "stm32f302x6",
2325
feature = "stm32f302x8",
@@ -39,16 +41,24 @@ use crate::gpio::gpioa::{PA5, PA6, PA7};
3941
feature = "stm32f398"
4042
))]
4143
use crate::gpio::gpiob::PB13;
44+
#[cfg(any(feature = "stm32f373", feature = "stm32f378"))]
45+
use crate::gpio::gpiob::{PB0, PB10, PB8};
4246
use crate::gpio::gpiob::{PB14, PB15, PB5};
4347
#[cfg(any(
4448
feature = "stm32f302",
4549
feature = "stm32f303",
4650
feature = "stm32f318",
4751
feature = "stm32f328",
4852
feature = "stm32f358",
53+
feature = "stm32f373",
54+
feature = "stm32f378",
4955
))]
5056
use crate::gpio::gpiob::{PB3, PB4};
5157
use crate::gpio::gpioc::{PC10, PC11, PC12};
58+
#[cfg(any(feature = "stm32f373", feature = "stm32f378"))]
59+
use crate::gpio::gpioc::{PC2, PC3, PC7, PC8, PC9};
60+
#[cfg(any(feature = "stm32f373", feature = "stm32f378"))]
61+
use crate::gpio::gpiod::{PD3, PD4, PD7, PD8};
5262
#[cfg(any(
5363
feature = "stm32f302xd",
5464
feature = "stm32f302xe",
@@ -66,6 +76,8 @@ use crate::gpio::gpioe::{PE12, PE13, PE14, PE2, PE5, PE6};
6676
feature = "stm32f318",
6777
))]
6878
use crate::gpio::gpiof::PF1;
79+
#[cfg(any(feature = "stm32f373", feature = "stm32f378"))]
80+
use crate::gpio::gpiof::PF6;
6981
#[cfg(any(
7082
feature = "stm32f302xb",
7183
feature = "stm32f302xc",
@@ -134,6 +146,8 @@ pub unsafe trait MisoPin<SPI> {}
134146
pub unsafe trait MosiPin<SPI> {}
135147

136148
unsafe impl SckPin<SPI1> for PA5<AF5> {}
149+
#[cfg(any(feature = "stm32f373", feature = "stm32f378"))]
150+
unsafe impl SckPin<SPI1> for PA12<AF6> {}
137151
#[cfg(any(
138152
feature = "stm32f302xb",
139153
feature = "stm32f302xc",
@@ -142,9 +156,19 @@ unsafe impl SckPin<SPI1> for PA5<AF5> {}
142156
feature = "stm32f303",
143157
feature = "stm32f328",
144158
feature = "stm32f358",
159+
feature = "stm32f373",
160+
feature = "stm32f378",
145161
))]
146162
unsafe impl SckPin<SPI1> for PB3<AF5> {}
147-
163+
#[cfg(any(feature = "stm32f373", feature = "stm32f378"))]
164+
unsafe impl SckPin<SPI1> for PC7<AF5> {}
165+
166+
#[cfg(any(feature = "stm32f373", feature = "stm32f378"))]
167+
unsafe impl SckPin<SPI2> for PA8<AF5> {}
168+
#[cfg(any(feature = "stm32f373", feature = "stm32f378"))]
169+
unsafe impl SckPin<SPI2> for PB8<AF5> {}
170+
#[cfg(any(feature = "stm32f373", feature = "stm32f378"))]
171+
unsafe impl SckPin<SPI2> for PB10<AF5> {}
148172
#[cfg(any(
149173
feature = "stm32f301",
150174
feature = "stm32f302",
@@ -155,6 +179,10 @@ unsafe impl SckPin<SPI1> for PB3<AF5> {}
155179
feature = "stm32f398"
156180
))]
157181
unsafe impl SckPin<SPI2> for PB13<AF5> {}
182+
#[cfg(any(feature = "stm32f373", feature = "stm32f378"))]
183+
unsafe impl SckPin<SPI2> for PD7<AF5> {}
184+
#[cfg(any(feature = "stm32f373", feature = "stm32f378"))]
185+
unsafe impl SckPin<SPI2> for PD8<AF5> {}
158186
#[cfg(any(
159187
feature = "stm32f302x6",
160188
feature = "stm32f302x8",
@@ -190,11 +218,15 @@ unsafe impl SckPin<SPI2> for PF9<AF5> {}
190218
))]
191219
unsafe impl SckPin<SPI2> for PF10<AF5> {}
192220

221+
#[cfg(any(feature = "stm32f373", feature = "stm32f378"))]
222+
unsafe impl SckPin<SPI3> for PA1<AF6> {}
193223
#[cfg(any(
194224
feature = "stm32f302",
195225
feature = "stm32f303xd",
196226
feature = "stm32f303xe",
197227
feature = "stm32f318",
228+
feature = "stm32f373",
229+
feature = "stm32f378",
198230
))]
199231
unsafe impl SckPin<SPI3> for PB3<AF6> {}
200232
unsafe impl SckPin<SPI3> for PC10<AF6> {}
@@ -215,6 +247,8 @@ unsafe impl SckPin<SPI4> for PE2<AF5> {}
215247
unsafe impl SckPin<SPI4> for PE12<AF5> {}
216248

217249
unsafe impl MisoPin<SPI1> for PA6<AF5> {}
250+
#[cfg(any(feature = "stm32f373", feature = "stm32f378"))]
251+
unsafe impl MisoPin<SPI1> for PA13<AF6> {}
218252
#[cfg(any(
219253
feature = "stm32f302xb",
220254
feature = "stm32f302xc",
@@ -223,9 +257,15 @@ unsafe impl MisoPin<SPI1> for PA6<AF5> {}
223257
feature = "stm32f303",
224258
feature = "stm32f328",
225259
feature = "stm32f358",
260+
feature = "stm32f373",
261+
feature = "stm32f378",
226262
))]
227263
unsafe impl MisoPin<SPI1> for PB4<AF5> {}
264+
#[cfg(any(feature = "stm32f373", feature = "stm32f378"))]
265+
unsafe impl MisoPin<SPI1> for PC8<AF5> {}
228266

267+
#[cfg(any(feature = "stm32f373", feature = "stm32f378"))]
268+
unsafe impl MisoPin<SPI2> for PA9<AF5> {}
229269
#[cfg(any(
230270
feature = "stm32f302x6",
231271
feature = "stm32f302x8",
@@ -237,12 +277,20 @@ unsafe impl MisoPin<SPI1> for PB4<AF5> {}
237277
))]
238278
unsafe impl MisoPin<SPI2> for PA10<AF5> {}
239279
unsafe impl MisoPin<SPI2> for PB14<AF5> {}
280+
#[cfg(any(feature = "stm32f373", feature = "stm32f378"))]
281+
unsafe impl MisoPin<SPI2> for PC2<AF5> {}
282+
#[cfg(any(feature = "stm32f373", feature = "stm32f378"))]
283+
unsafe impl MisoPin<SPI2> for PD3<AF5> {}
240284

285+
#[cfg(any(feature = "stm32f373", feature = "stm32f378"))]
286+
unsafe impl MisoPin<SPI3> for PA2<AF6> {}
241287
#[cfg(any(
242288
feature = "stm32f302",
243289
feature = "stm32f303xd",
244290
feature = "stm32f303xe",
245291
feature = "stm32f318",
292+
feature = "stm32f373",
293+
feature = "stm32f378",
246294
))]
247295
unsafe impl MisoPin<SPI3> for PB4<AF6> {}
248296
unsafe impl MisoPin<SPI3> for PC11<AF6> {}
@@ -263,8 +311,16 @@ unsafe impl MisoPin<SPI4> for PE5<AF5> {}
263311
unsafe impl MisoPin<SPI4> for PE13<AF5> {}
264312

265313
unsafe impl MosiPin<SPI1> for PA7<AF5> {}
314+
#[cfg(any(feature = "stm32f373", feature = "stm32f378"))]
315+
unsafe impl MosiPin<SPI1> for PB0<AF5> {}
266316
unsafe impl MosiPin<SPI1> for PB5<AF5> {}
317+
#[cfg(any(feature = "stm32f373", feature = "stm32f378"))]
318+
unsafe impl MosiPin<SPI1> for PC9<AF5> {}
319+
#[cfg(any(feature = "stm32f373", feature = "stm32f378"))]
320+
unsafe impl MosiPin<SPI1> for PF6<AF5> {}
267321

322+
#[cfg(any(feature = "stm32f373", feature = "stm32f378"))]
323+
unsafe impl MosiPin<SPI2> for PA10<AF5> {}
268324
#[cfg(any(
269325
feature = "stm32f302x6",
270326
feature = "stm32f302x8",
@@ -276,7 +332,13 @@ unsafe impl MosiPin<SPI1> for PB5<AF5> {}
276332
))]
277333
unsafe impl MosiPin<SPI2> for PA11<AF5> {}
278334
unsafe impl MosiPin<SPI2> for PB15<AF5> {}
335+
#[cfg(any(feature = "stm32f373", feature = "stm32f378"))]
336+
unsafe impl MisoPin<SPI2> for PC3<AF5> {}
337+
#[cfg(any(feature = "stm32f373", feature = "stm32f378"))]
338+
unsafe impl MisoPin<SPI2> for PD4<AF5> {}
279339

340+
#[cfg(any(feature = "stm32f373", feature = "stm32f378"))]
341+
unsafe impl MisoPin<SPI3> for PA3<AF6> {}
280342
unsafe impl MosiPin<SPI3> for PB5<AF6> {}
281343
unsafe impl MosiPin<SPI3> for PC12<AF6> {}
282344

0 commit comments

Comments
 (0)