Skip to content

Commit

Permalink
Deprecate pwm implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Sh3Rm4n committed Nov 28, 2023
1 parent f428bb6 commit daf09bf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

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

### Changed

- The PWM implementation was deprecated. There is not yet an alternative
implementation, but it is hard to maintain the current implementation
and not easy to verify if it is really a safe implementation.
It is also not consistent with the rest of the crates API. ([#352])

## [v0.9.2] - 2023-02-20

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

[#352]: https://github.com/stm32-rs/stm32f3xx-hal/pull/352
[#345]: https://github.com/stm32-rs/stm32f3xx-hal/pull/345
[#346]: https://github.com/stm32-rs/stm32f3xx-hal/pull/346
[#347]: https://github.com/stm32-rs/stm32f3xx-hal/pull/347
Expand Down
5 changes: 5 additions & 0 deletions examples/pwm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use hal::flash::FlashExt;
use hal::gpio::GpioExt;
use hal::pac;
use hal::prelude::*;
#[allow(deprecated)]
use hal::pwm::{tim16, tim2, tim3, tim8};
use hal::rcc::RccExt;

Expand Down Expand Up @@ -70,6 +71,7 @@ fn main() -> ! {
// TIM3
//
// A four channel general purpose timer that's broadly available
#[allow(deprecated)]
let tim3_channels = tim3(
dp.TIM3,
1280, // resolution of duty cycle
Expand Down Expand Up @@ -119,6 +121,7 @@ fn main() -> ! {
// TIM2
//
// A 32-bit timer, so we can set a larger resolution
#[allow(deprecated)]
let tim2_channels = tim2(
dp.TIM2,
160000, // resolution of duty cycle
Expand All @@ -134,6 +137,7 @@ fn main() -> ! {
//
// A single channel timer, so it doesn't return a tuple. We can
// just use it directly
#[allow(deprecated)]
let mut tim16_ch1 = tim16(
dp.TIM16,
1280, // resolution of duty cycle
Expand All @@ -148,6 +152,7 @@ fn main() -> ! {
//
// An advanced timer with complementary outputs, so we can output
// to complementary pins (works just like standard pins)
#[allow(deprecated)]
let tim8_channels = tim8(
dp.TIM8,
1280, // resolution of duty cycle
Expand Down
1 change: 1 addition & 0 deletions src/pwm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ macro_rules! pwm_timer_private {
/// of exactly one degree.
#[allow(unused_parens)]
#[must_use]
#[deprecated(since = "0.10.0", note = "needs refactoring and might violate safety rules conflicting with the timer API")]
pub fn $timx(tim: $TIMx, res: $res, freq: Hertz, clocks: &Clocks) -> ($(PwmChannel<$TIMx_CHy, NoPins>),+) {
// Power the timer and reset it to ensure a clean state
// We use unsafe here to abstract away this implementation detail
Expand Down

0 comments on commit daf09bf

Please sign in to comment.