Skip to content

Commit 564f9cf

Browse files
committed
Fix and expand can pin support
1 parent 7c33859 commit 564f9cf

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1818

1919
- Support cortex-m-rt `v0.7.0` but still allow `v0.6.13` ([#283])
2020

21+
### Fixed
22+
23+
- Fix `can` support. Can would not build for `stm32f302x6` for example.
24+
Also support `can` for every chip other than `stm32f301` and `stm32f318`.
25+
([#283])
26+
2127
### Breaking Changes
2228

2329
- Make `rtc` an optional feature. Without that feature `rtcc` as a dependency is

src/can.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//! [examples/can.rs]: https://github.com/stm32-rs/stm32f3xx-hal/blob/v0.8.0/examples/can.rs
1313
1414
use crate::gpio::{gpioa, gpiob};
15-
use crate::gpio::{PushPull, AF7, AF9};
15+
use crate::gpio::{PushPull, AF9};
1616
use crate::pac;
1717

1818
use crate::rcc::APB1;
@@ -28,16 +28,14 @@ pub trait RxPin: crate::private::Sealed {}
2828
/// Marker trait for pins (with specific AF mode) that can be used as a CAN TX pin.
2929
pub trait TxPin: crate::private::Sealed {}
3030

31-
cfg_if! {
32-
if #[cfg(any(feature = "gpio-f302", feature = "gpio-f303"))] {
33-
use crate::gpio::gpiod;
34-
35-
impl RxPin for gpioa::PA11<AF9<PushPull>> {}
36-
impl TxPin for gpioa::PA12<AF9<PushPull>> {}
37-
38-
impl RxPin for gpiob::PB8<AF9<PushPull>> {}
39-
impl TxPin for gpiob::PB9<AF9<PushPull>> {}
31+
impl RxPin for gpioa::PA11<AF9<PushPull>> {}
32+
impl TxPin for gpioa::PA12<AF9<PushPull>> {}
33+
impl RxPin for gpiob::PB8<AF9<PushPull>> {}
34+
impl TxPin for gpiob::PB9<AF9<PushPull>> {}
4035

36+
cfg_if! {
37+
if #[cfg(any(feature = "gpio-f303", feature = "gpio-f303e", feature = "gpio-f373"))] {
38+
use crate::gpio::{gpiod, AF7};
4139
impl RxPin for gpiod::PD0<AF7<PushPull>> {}
4240
impl TxPin for gpiod::PD1<AF7<PushPull>> {}
4341
}

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ pub use crate::pac::interrupt;
172172
#[cfg(feature = "stm32f303")]
173173
#[cfg_attr(docsrs, doc(cfg(feature = "stm32f303")))]
174174
pub mod adc;
175-
#[cfg(feature = "can")]
175+
#[cfg(all(feature = "can", not(feature = "svd-f301")))]
176176
#[cfg_attr(docsrs, doc(cfg(feature = "can")))]
177177
pub mod can;
178178
pub mod delay;

0 commit comments

Comments
 (0)