Skip to content

Commit ce7ebb1

Browse files
authored
Deprecate pwm implementation (#352)
1 parent f428bb6 commit ce7ebb1

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

CHANGELOG.md

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

3636
- Fix wrong timer frequency calculation and unexpected panics ([#338])
3737

38+
### Changed
39+
40+
- The PWM implementation was deprecated. There is not yet an alternative
41+
implementation, but it is hard to maintain the current implementation
42+
and not easy to verify if it is really a safe implementation.
43+
It is also not consistent with the rest of the crates API. ([#352])
44+
3845
## [v0.9.2] - 2023-02-20
3946

4047
### Added
@@ -599,6 +606,7 @@ let clocks = rcc
599606
[defmt]: https://github.com/knurling-rs/defmt
600607
[filter]: https://defmt.ferrous-systems.com/filtering.html
601608

609+
[#352]: https://github.com/stm32-rs/stm32f3xx-hal/pull/352
602610
[#345]: https://github.com/stm32-rs/stm32f3xx-hal/pull/345
603611
[#346]: https://github.com/stm32-rs/stm32f3xx-hal/pull/346
604612
[#347]: https://github.com/stm32-rs/stm32f3xx-hal/pull/347

examples/pwm.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use hal::flash::FlashExt;
1717
use hal::gpio::GpioExt;
1818
use hal::pac;
1919
use hal::prelude::*;
20+
#[allow(deprecated)]
2021
use hal::pwm::{tim16, tim2, tim3, tim8};
2122
use hal::rcc::RccExt;
2223

@@ -70,6 +71,7 @@ fn main() -> ! {
7071
// TIM3
7172
//
7273
// A four channel general purpose timer that's broadly available
74+
#[allow(deprecated)]
7375
let tim3_channels = tim3(
7476
dp.TIM3,
7577
1280, // resolution of duty cycle
@@ -119,6 +121,7 @@ fn main() -> ! {
119121
// TIM2
120122
//
121123
// A 32-bit timer, so we can set a larger resolution
124+
#[allow(deprecated)]
122125
let tim2_channels = tim2(
123126
dp.TIM2,
124127
160000, // resolution of duty cycle
@@ -134,6 +137,7 @@ fn main() -> ! {
134137
//
135138
// A single channel timer, so it doesn't return a tuple. We can
136139
// just use it directly
140+
#[allow(deprecated)]
137141
let mut tim16_ch1 = tim16(
138142
dp.TIM16,
139143
1280, // resolution of duty cycle
@@ -148,6 +152,7 @@ fn main() -> ! {
148152
//
149153
// An advanced timer with complementary outputs, so we can output
150154
// to complementary pins (works just like standard pins)
155+
#[allow(deprecated)]
151156
let tim8_channels = tim8(
152157
dp.TIM8,
153158
1280, // resolution of duty cycle

src/pwm.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ macro_rules! pwm_timer_private {
282282
/// of exactly one degree.
283283
#[allow(unused_parens)]
284284
#[must_use]
285+
#[deprecated(since = "0.10.0", note = "needs refactoring and might violate safety rules conflicting with the timer API")]
285286
pub fn $timx(tim: $TIMx, res: $res, freq: Hertz, clocks: &Clocks) -> ($(PwmChannel<$TIMx_CHy, NoPins>),+) {
286287
// Power the timer and reset it to ensure a clean state
287288
// We use unsafe here to abstract away this implementation detail

0 commit comments

Comments
 (0)