Skip to content

Commit 9f8128e

Browse files
danielgallagher0Sh3Rm4n
authored andcommitted
Implement all SPI pins for STM32F303
1 parent 33c84a6 commit 9f8128e

File tree

1 file changed

+104
-4
lines changed

1 file changed

+104
-4
lines changed

src/spi.rs

Lines changed: 104 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,17 @@ use crate::pac::{
99
SPI1, SPI2, SPI3,
1010
};
1111
use crate::stm32::spi1;
12+
#[cfg(any(
13+
feature = "stm32f303xb",
14+
feature = "stm32f303xc",
15+
feature = "stm32f303xd",
16+
feature = "stm32f303xe"
17+
))]
18+
use crate::stm32::SPI4;
19+
use nb;
1220

21+
#[cfg(feature = "stm32f303")]
22+
use crate::gpio::gpioa::{PA10, PA11};
1323
use crate::gpio::gpioa::{PA5, PA6, PA7};
1424
#[cfg(any(
1525
feature = "stm32f301",
@@ -23,7 +33,23 @@ use crate::gpio::gpioa::{PA5, PA6, PA7};
2333
))]
2434
use crate::gpio::gpiob::PB13;
2535
use crate::gpio::gpiob::{PB14, PB15, PB5};
36+
#[cfg(feature = "stm32f303")]
37+
use crate::gpio::gpiob::{PB3, PB4};
2638
use crate::gpio::gpioc::{PC10, PC11, PC12};
39+
#[cfg(any(
40+
feature = "stm32f303xb",
41+
feature = "stm32f303xc",
42+
feature = "stm32f303xd",
43+
feature = "stm32f303xe"
44+
))]
45+
use crate::gpio::gpioe::{PE12, PE13, PE14, PE2, PE5, PE6};
46+
#[cfg(any(
47+
feature = "stm32f303xb",
48+
feature = "stm32f303xc",
49+
feature = "stm32f303xd",
50+
feature = "stm32f303xe"
51+
))]
52+
use crate::gpio::gpiof::{PF1, PF10, PF9};
2753
use crate::gpio::{AF5, AF6};
2854
use crate::rcc::Clocks;
2955
#[cfg(any(
@@ -75,7 +101,8 @@ pub unsafe trait MisoPin<SPI> {}
75101
pub unsafe trait MosiPin<SPI> {}
76102

77103
unsafe impl SckPin<SPI1> for PA5<AF5> {}
78-
// unsafe impl SckPin<SPI1> for PB3<AF5> {}
104+
#[cfg(feature = "stm32f303")]
105+
unsafe impl SckPin<SPI1> for PB3<AF5> {}
79106

80107
#[cfg(any(
81108
feature = "stm32f301",
@@ -88,26 +115,99 @@ unsafe impl SckPin<SPI1> for PA5<AF5> {}
88115
feature = "stm32f398"
89116
))]
90117
unsafe impl SckPin<SPI2> for PB13<AF5> {}
118+
#[cfg(any(
119+
feature = "stm32f303xb",
120+
feature = "stm32f303xc",
121+
feature = "stm32f303xd",
122+
feature = "stm32f303xe"
123+
))]
124+
unsafe impl SckPin<SPI2> for PF1<AF5> {}
125+
#[cfg(any(
126+
feature = "stm32f303xb",
127+
feature = "stm32f303xc",
128+
feature = "stm32f303xd",
129+
feature = "stm32f303xe"
130+
))]
131+
unsafe impl SckPin<SPI2> for PF9<AF5> {}
132+
#[cfg(any(
133+
feature = "stm32f303xb",
134+
feature = "stm32f303xc",
135+
feature = "stm32f303xd",
136+
feature = "stm32f303xe"
137+
))]
138+
unsafe impl SckPin<SPI2> for PF10<AF5> {}
91139

92-
// unsafe impl SckPin<SPI3> for PB3<AF6> {}
140+
#[cfg(feature = "stm32f303")]
141+
unsafe impl SckPin<SPI3> for PB3<AF6> {}
93142
unsafe impl SckPin<SPI3> for PC10<AF6> {}
94143

144+
#[cfg(any(
145+
feature = "stm32f303xb",
146+
feature = "stm32f303xc",
147+
feature = "stm32f303xd",
148+
feature = "stm32f303xe"
149+
))]
150+
unsafe impl SckPin<SPI4> for PE2<AF5> {}
151+
#[cfg(any(
152+
feature = "stm32f303xb",
153+
feature = "stm32f303xc",
154+
feature = "stm32f303xd",
155+
feature = "stm32f303xe"
156+
))]
157+
unsafe impl SckPin<SPI4> for PE12<AF5> {}
158+
95159
unsafe impl MisoPin<SPI1> for PA6<AF5> {}
96-
// unsafe impl MisoPin<SPI1> for PB4<AF5> {}
160+
#[cfg(feature = "stm32f303")]
161+
unsafe impl MisoPin<SPI1> for PB4<AF5> {}
97162

163+
#[cfg(any(feature = "stm32f303"))]
164+
unsafe impl MisoPin<SPI2> for PA10<AF5> {}
98165
unsafe impl MisoPin<SPI2> for PB14<AF5> {}
99166

100-
// unsafe impl MisoPin<SPI3> for PB4<AF6> {}
167+
#[cfg(any(
168+
feature = "stm32f303xb",
169+
feature = "stm32f303xc",
170+
feature = "stm32f303xd",
171+
feature = "stm32f303xe"
172+
))]
173+
unsafe impl MisoPin<SPI4> for PE5<AF5> {}
174+
#[cfg(any(
175+
feature = "stm32f303xb",
176+
feature = "stm32f303xc",
177+
feature = "stm32f303xd",
178+
feature = "stm32f303xe"
179+
))]
180+
unsafe impl MisoPin<SPI4> for PE13<AF5> {}
181+
182+
#[cfg(any(feature = "stm32f303"))]
183+
unsafe impl MisoPin<SPI3> for PB4<AF6> {}
101184
unsafe impl MisoPin<SPI3> for PC11<AF6> {}
102185

103186
unsafe impl MosiPin<SPI1> for PA7<AF5> {}
104187
unsafe impl MosiPin<SPI1> for PB5<AF5> {}
105188

189+
#[cfg(any(feature = "stm32f303"))]
190+
unsafe impl MosiPin<SPI2> for PA11<AF5> {}
106191
unsafe impl MosiPin<SPI2> for PB15<AF5> {}
107192

108193
unsafe impl MosiPin<SPI3> for PB5<AF6> {}
109194
unsafe impl MosiPin<SPI3> for PC12<AF6> {}
110195

196+
#[cfg(any(
197+
feature = "stm32f303xb",
198+
feature = "stm32f303xc",
199+
feature = "stm32f303xd",
200+
feature = "stm32f303xe"
201+
))]
202+
unsafe impl MosiPin<SPI4> for PE6<AF5> {}
203+
#[cfg(any(
204+
feature = "stm32f303xb",
205+
feature = "stm32f303xc",
206+
feature = "stm32f303xd",
207+
feature = "stm32f303xe"
208+
))]
209+
unsafe impl MosiPin<SPI4> for PE14<AF5> {}
210+
111211
pub trait Word {
112212
fn register_config() -> (FRXTH_A, DS_A);
113213
}

0 commit comments

Comments
 (0)