Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for using TIM2 as a PWM output #165

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- PWM complementary output capability for TIM1 with new example to demonstrate
- Implement interface for reading and writing to the internal flash memory and an example for demonstration.
- PWM output on complementary channels only for single channel timers (TIM16 + TIM17)
- PWM capability for TIM2

### Fixed

Expand Down
21 changes: 20 additions & 1 deletion src/pwm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,26 @@ macro_rules! pwm_1_channel_with_complementary_outputs {

use crate::pac::*;

pwm_4_channels!(TIM3: (tim3, tim3en, tim3rst, apb1enr, apb1rstr),);
pwm_4_channels!(
TIM3: (tim3, tim3en, tim3rst, apb1enr, apb1rstr),
);

#[cfg(any(
feature = "stm32f031",
feature = "stm32f038",
feature = "stm32f042",
feature = "stm32f048",
feature = "stm32f051",
feature = "stm32f058",
feature = "stm32f071",
feature = "stm32f072",
feature = "stm32f078",
feature = "stm32f091",
feature = "stm32f098",
))]
pwm_4_channels!(
TIM2: (tim2, tim2en, tim2rst, apb1enr, apb1rstr),
);

pwm_4_channels_with_3_complementary_outputs!(TIM1: (tim1, tim1en, tim1rst, apb2enr, apb2rstr),);
pwm_1_channel!(TIM14: (tim14, tim14en, tim14rst, apb1enr, apb1rstr),);
Expand Down
25 changes: 25 additions & 0 deletions src/timers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,31 @@ channel_impl!(
TIM17, PinC1, PB9, Alternate<AF2>;
);

#[cfg(any(
feature = "stm32f031",
feature = "stm32f038",
feature = "stm32f042",
feature = "stm32f048",
feature = "stm32f051",
feature = "stm32f058",
feature = "stm32f071",
feature = "stm32f072",
feature = "stm32f078",
feature = "stm32f091",
feature = "stm32f098",
))]
channel_impl!(
TIM2, PinC1, PA0, Alternate<AF2>;
TIM2, PinC2, PA1, Alternate<AF2>;
TIM2, PinC3, PA2, Alternate<AF2>;
TIM2, PinC4, PA3, Alternate<AF2>;
TIM2, PinC1, PA5, Alternate<AF2>;
TIM2, PinC1, PA15, Alternate<AF2>;
TIM2, PinC2, PB3, Alternate<AF2>;
TIM2, PinC3, PB10, Alternate<AF2>;
TIM2, PinC4, PB11, Alternate<AF2>;
);

#[cfg(any(
feature = "stm32f030x8",
feature = "stm32f030xc",
Expand Down
Loading