Skip to content

Commit 6ac43f0

Browse files
committed
duty time
1 parent 516c713 commit 6ac43f0

File tree

2 files changed

+28
-19
lines changed

2 files changed

+28
-19
lines changed

CHANGELOG.md

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,33 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10-
### Added
11-
12-
- Implementation of From trait for Pin-to-PartiallyErasedPin [#507]
13-
- Implementation of From trait for Pin-to-ErasedPin [#507]
14-
- Implementation of From trait for PartiallyErasedPin-to-ErasedPin [#507]
15-
16-
[#507]: https://github.com/stm32-rs/stm32f4xx-hal/pull/507
17-
1810
### Changed
1911

20-
- update `stm32f4` to 0.15.1
21-
- use `stm32_i2s_v12x` version 0.3, reexport it, and implements requirement for it
22-
- i2s module don't reuse marker from spi module and define its own.
23-
- `i2s-audio-out` example updated and now use pcm5102 dac module instead one from discovery board.
24-
- extend visibility of gpio/marker to crate since i2s module require it.
25-
- Bump `synopsys-usb-otg` to `0.3.0`
26-
- Bump `embedded-hal` to `1.0.0-alpha.8`
27-
28-
### Added
29-
- example of using i2s in out with rtic and interrupt.
12+
- update `stm32f4` to 0.15.1 [#481]
13+
- use `stm32_i2s_v12x` version 0.3, reexport it, and implements requirement for it [#490]
14+
- i2s module don't reuse marker from spi module and define its own [#490]
15+
- `i2s-audio-out` example updated and now use pcm5102 dac module instead one from discovery board [#490]
16+
- extend visibility of gpio/marker to crate since i2s module require it [#490]
17+
- Bump `synopsys-usb-otg` to `0.3.0` [#508]
18+
- Bump `embedded-hal` to `1.0.0-alpha.8` [#510]
3019

3120
### Removed
3221
- `i2s-audio-out-dma.rs` example, too difficult to fix.
33-
- Add `SysMonoTimerExt` helper trait [#497]
3422

23+
### Added
24+
25+
- Implementation of From trait for Pin-to-PartiallyErasedPin [#507]
26+
- Implementation of From trait for Pin-to-ErasedPin [#507]
27+
- Implementation of From trait for PartiallyErasedPin-to-ErasedPin [#507]
28+
- `SysMonoTimerExt` helper trait, `Pwm::(get/set)_duty_time` [#497]
29+
- example of using i2s in out with rtic and interrupt.
30+
31+
[#489]: https://github.com/stm32-rs/stm32f4xx-hal/pull/489
32+
[#490]: https://github.com/stm32-rs/stm32f4xx-hal/pull/490
3533
[#497]: https://github.com/stm32-rs/stm32f4xx-hal/pull/497
34+
[#507]: https://github.com/stm32-rs/stm32f4xx-hal/pull/507
35+
[#508]: https://github.com/stm32-rs/stm32f4xx-hal/pull/508
36+
[#510]: https://github.com/stm32-rs/stm32f4xx-hal/pull/510
3637

3738
## [v0.13.2] - 2022-05-16
3839

src/timer/pwm.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,10 +421,18 @@ where
421421
TIM::read_cc_value(PINS::check_used(channel) as u8) as u16
422422
}
423423

424+
pub fn get_duty_time(&self, channel: Channel) -> TimerDurationU32<FREQ> {
425+
TimerDurationU32::from_ticks(TIM::read_cc_value(PINS::check_used(channel) as u8))
426+
}
427+
424428
pub fn set_duty(&mut self, channel: Channel, duty: u16) {
425429
TIM::set_cc_value(PINS::check_used(channel) as u8, duty.into())
426430
}
427431

432+
pub fn set_duty_time(&mut self, channel: Channel, duty: TimerDurationU32<FREQ>) {
433+
TIM::set_cc_value(PINS::check_used(channel) as u8, duty.ticks())
434+
}
435+
428436
/// If `0` returned means max_duty is 2^16
429437
pub fn get_max_duty(&self) -> u16 {
430438
(TIM::read_auto_reload() as u16).wrapping_add(1)

0 commit comments

Comments
 (0)