Skip to content

Commit fbc7225

Browse files
authored
Merge pull request #283 from Sh3Rm4n/features
Set some features as the default
2 parents 5ece8e8 + ea9cd83 commit fbc7225

File tree

9 files changed

+59
-50
lines changed

9 files changed

+59
-50
lines changed

.clippy.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
msrv = "1.51"
1+
msrv = "1.52"

.github/workflows/ci.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- stm32f303x6
2525
# - stm32f303x8
2626
- stm32f303xb
27-
# - stm32f303xc
27+
- stm32f303xc
2828
- stm32f303xd
2929
# - stm32f303xe
3030
- stm32f328x8
@@ -37,10 +37,6 @@ jobs:
3737
- stm32f334x4
3838
# - stm32f334x6
3939
# - stm32f334x8
40-
features: ["rt"]
41-
include:
42-
- mcu: stm32f303xc
43-
features: rt,can,stm32-usbd,enumset
4440
steps:
4541
- uses: actions/checkout@v2
4642
- uses: actions-rs/toolchain@v1
@@ -49,7 +45,7 @@ jobs:
4945
target: thumbv7em-none-eabihf
5046
override: true
5147
profile: minimal
52-
- run: cargo check --features=${{ matrix.mcu }},ld,${{ matrix.features }} --lib --examples
48+
- run: cargo check --features=${{ matrix.mcu }} --lib --examples
5349

5450
# This is our MSRV. However this is only for documentation
5551
# purposes and should be increased if newer features are used.
@@ -61,7 +57,7 @@ jobs:
6157
- uses: actions/checkout@v2
6258
- uses: actions-rs/toolchain@v1
6359
with:
64-
toolchain: 1.51.0
60+
toolchain: 1.52.0
6561
target: thumbv7em-none-eabihf
6662
override: true
6763
profile: minimal
@@ -138,7 +134,7 @@ jobs:
138134
- uses: actions-rs/cargo@v1
139135
with:
140136
command: doc
141-
args: --features=stm32f303xc,rt,stm32-usbd,can,enumset
137+
args: --features=stm32f303xc
142138

143139
clippy:
144140
name: Clippy
@@ -156,7 +152,7 @@ jobs:
156152
with:
157153
token: ${{ secrets.GITHUB_TOKEN }}
158154
args: >
159-
--features=stm32f303xc,ld,rt,stm32-usbd,can --lib --examples
155+
--features=stm32f303xc --lib --examples
160156
-- -D warnings
161157
162158
rustfmt:

CHANGELOG.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,23 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1414

1515
## Unreleased
1616

17-
No changes.
17+
### Added
18+
19+
- Support cortex-m-rt `v0.7.0` but still allow `v0.6.13` ([#283])
20+
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+
27+
### Breaking Changes
28+
29+
- Make `rtc` an optional feature. Without that feature `rtcc` as a dependency is
30+
not needed. ([#283])
31+
- Enable `rt`, `usb`, `can`, `rtc` and `ld` feature by default.
32+
To disable that behavior, set `default-features = false`. ([#283])
33+
- The MSRV was bumped to 1.52 ([#283])
1834

1935
## [v0.8.0] - 2021-08-16
2036

@@ -476,6 +492,7 @@ let clocks = rcc
476492
[defmt]: https://github.com/knurling-rs/defmt
477493
[filter]: https://defmt.ferrous-systems.com/filtering.html
478494

495+
[#283]: https://github.com/stm32-rs/stm32f3xx-hal/pull/283
479496
[#278]: https://github.com/stm32-rs/stm32f3xx-hal/pull/278
480497
[#277]: https://github.com/stm32-rs/stm32f3xx-hal/pull/277
481498
[#273]: https://github.com/stm32-rs/stm32f3xx-hal/pull/273

Cargo.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,22 @@ rustc-args = ["--cfg", "docsrs"]
3535
[dependencies]
3636
cfg-if = "1.0.0"
3737
cortex-m = "0.7.2"
38-
cortex-m-rt = "0.6.14"
38+
cortex-m-rt = { version = ">=0.6.13, <0.8" }
3939
defmt = { version = "0.2.3", optional = true }
4040
embedded-dma = "0.1.2"
4141
embedded-hal = { version = "0.2.5", features = ["unproven"] }
4242
embedded-time = "0.12.0"
4343
nb = "1.0.0"
4444
paste = "1.0.5"
45-
rtcc = "0.2.1"
46-
stm32f3 = "0.13.2"
45+
rtcc = { version = "0.2.1", optional = true }
46+
stm32f3 = { version = "0.13.2", default-features = false }
4747
bxcan = { version = ">=0.4, <0.6", optional = true }
4848
stm32-usbd = { version = "0.6.0", optional = true }
4949
void = { version = "1.0.2", default-features = false }
5050
enumset = { version = "1.0.6", optional = true}
5151

5252
[dev-dependencies]
5353
cortex-m = "0.7.2"
54-
cortex-m-rt = { version = "0.6.13", features = ["device"] }
5554
cortex-m-semihosting = "0.3.7"
5655
defmt-rtt = "0.2.0"
5756
defmt-test = "0.2.3"
@@ -68,12 +67,14 @@ rtt-target = { version = "0.3.0", features = ["cortex-m"] }
6867
slice-group-by = "0.2.6"
6968

7069
[features]
70+
default = ["rt", "ld", "usb", "can", "rtc", "enumset"]
7171
device-selected = []
7272
direct-call-deprecated = []
7373
ld = []
7474
rt = ["stm32f3/rt"]
7575
can = ["bxcan"]
7676
usb = ["stm32-usbd"]
77+
rtc = ["rtcc"]
7778

7879
svd-f301 = ["stm32f3/stm32f301"]
7980
svd-f302 = ["stm32f3/stm32f302"]

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![Crate](https://img.shields.io/crates/v/stm32f3xx-hal.svg)](https://crates.io/crates/stm32f3xx-hal)
55
[![Docs](https://docs.rs/stm32f3xx-hal/badge.svg)](https://docs.rs/stm32f3xx-hal)
66
[![Crates.io](https://img.shields.io/crates/d/stm32f3xx-hal.svg)](https://crates.io/crates/stm32f3xx-hal)
7-
![Minimum Supported Rust Version](https://img.shields.io/badge/rustc-1.51+-blue.svg)
7+
![Minimum Supported Rust Version](https://img.shields.io/badge/rustc-1.52+-blue.svg)
88

99
`stm32f3xx-hal` contains a multi device hardware abstraction on top of the
1010
peripheral access API for the STMicro STM32F3 series microcontrollers. The
@@ -139,7 +139,7 @@ See the [examples folder](examples) for more example programs.
139139

140140
## Minimum Supported Rust Version (MSRV)
141141

142-
This crate is guaranteed to compile on stable Rust 1.51.0 and up. It *might*
142+
This crate is guaranteed to compile on stable Rust 1.52.0 and up. It *might*
143143
compile with older versions but that may change in any new patch release.
144144

145145
<!-- This should not prevent anyone to use newer features. -->

src/can.rs

Lines changed: 10 additions & 22 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;
@@ -22,33 +22,21 @@ use bxcan::RegisterBlock;
2222

2323
use cfg_if::cfg_if;
2424

25-
mod sealed {
26-
pub trait Sealed {}
27-
}
28-
2925
/// Marker trait for pins (with specific AF mode) that can be used as a CAN RX pin.
30-
pub trait RxPin: sealed::Sealed {}
26+
pub trait RxPin: crate::private::Sealed {}
3127

3228
/// Marker trait for pins (with specific AF mode) that can be used as a CAN TX pin.
33-
pub trait TxPin: sealed::Sealed {}
34-
35-
cfg_if! {
36-
if #[cfg(any(feature = "gpio-f302", feature = "gpio-f303"))] {
37-
use crate::gpio::gpiod;
38-
39-
impl sealed::Sealed for gpioa::PA11<AF9<PushPull>> {}
40-
impl RxPin for gpioa::PA11<AF9<PushPull>> {}
41-
impl sealed::Sealed for gpioa::PA12<AF9<PushPull>> {}
42-
impl TxPin for gpioa::PA12<AF9<PushPull>> {}
29+
pub trait TxPin: crate::private::Sealed {}
4330

44-
impl sealed::Sealed for gpiob::PB8<AF9<PushPull>> {}
45-
impl RxPin for gpiob::PB8<AF9<PushPull>> {}
46-
impl sealed::Sealed for gpiob::PB9<AF9<PushPull>> {}
47-
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>> {}
4835

49-
impl sealed::Sealed for gpiod::PD0<AF7<PushPull>> {}
36+
cfg_if! {
37+
if #[cfg(any(feature = "gpio-f303", feature = "gpio-f303e", feature = "gpio-f373"))] {
38+
use crate::gpio::{gpiod, AF7};
5039
impl RxPin for gpiod::PD0<AF7<PushPull>> {}
51-
impl sealed::Sealed for gpiod::PD1<AF7<PushPull>> {}
5240
impl TxPin for gpiod::PD1<AF7<PushPull>> {}
5341
}
5442
}

src/lib.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@
8080
8181
### `usb`
8282
83-
Enable USB peripherals on supported targets via the [`stm32-usbd`](https://crates.io/crates/sttm32-usbd) crate.
83+
Enable USB peripherals on supported targets via the [`stm32-usbd`](https://crates.io/crates/stm32-usbd) crate.
84+
85+
### `rtc`
86+
87+
Enables RTC support, build upon [`rtcc`](https://crates.io/crates/rtcc) crate.
8488
8589
### `enumset`
8690
@@ -168,7 +172,7 @@ pub use crate::pac::interrupt;
168172
#[cfg(feature = "stm32f303")]
169173
#[cfg_attr(docsrs, doc(cfg(feature = "stm32f303")))]
170174
pub mod adc;
171-
#[cfg(feature = "can")]
175+
#[cfg(all(feature = "can", not(feature = "svd-f301")))]
172176
#[cfg_attr(docsrs, doc(cfg(feature = "can")))]
173177
pub mod can;
174178
pub mod delay;
@@ -180,6 +184,8 @@ pub mod interrupts;
180184
pub mod prelude;
181185
pub mod pwm;
182186
pub mod rcc;
187+
#[cfg(feature = "rtc")]
188+
#[cfg_attr(docsrs, doc(cfg(feature = "rtc")))]
183189
pub mod rtc;
184190
pub mod serial;
185191
pub mod spi;

src/spi.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,7 @@ mod interrupts {
501501
// generated an enum-number for that. The RM0365 does also not list it as an interrupt.
502502
// Strangly though, the Stm32CubeMx program let's us choose to enable the NVIC
503503
// interrupt. This is probably a documentation bug.
504+
#[allow(unused)]
504505
pub(crate) const SPI4: Interrupt = Interrupt::SPI3;
505506
} else if #[cfg(feature = "gpio-f303e")] {
506507
pub(crate) const SPI4: Interrupt = Interrupt::SPI4;

testsuite/Cargo.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,25 +50,25 @@ harness = false
5050
[dependencies]
5151
cfg-if = "1.0"
5252
cortex-m = "0.7.0"
53-
cortex-m-rt = "0.6.15"
53+
cortex-m-rt = "0.6.13"
5454
defmt = "0.2.0"
5555
defmt-rtt = "0.2.0"
5656
defmt-test = "0.2.0"
5757
enumset = { version = "1.0.6" }
5858
# TODO: Set stm32f303xc as default, but make it overwritable
59-
stm32f3xx-hal = { path = "..", features = ["rt", "defmt-trace", "can", "ld", "enumset"]}
59+
stm32f3xx-hal = { path = "..", features = ["defmt-trace"]}
6060
panic-probe = { version = "0.2.0", features = ["print-defmt"] }
6161
nb = "1.0.0"
6262
num-traits = { version = "0.2.14", default-features = false }
6363

6464
[features]
6565
# enable all defmt logging levels
66-
default = ["defmt-trace", "stm32f3xx-hal/stm32f303xc", "stm32f3xx-hal/ld"]
66+
default = ["stm32f3xx-hal/stm32f303xc"]
6767

6868
# do not modify these features
69-
defmt-default = []
70-
defmt-trace = []
71-
defmt-debug = []
72-
defmt-info = []
73-
defmt-warn = []
74-
defmt-error = []
69+
defmt-default = ["defmt-info"]
70+
defmt-trace = ["stm32f3xx-hal/defmt-trace"]
71+
defmt-debug = ["stm32f3xx-hal/defmt-trace"]
72+
defmt-info = ["stm32f3xx-hal/defmt-trace"]
73+
defmt-warn = ["stm32f3xx-hal/defmt-trace"]
74+
defmt-error = ["stm32f3xx-hal/defmt-trace"]

0 commit comments

Comments
 (0)