diff --git a/CHANGELOG.md b/CHANGELOG.md index d5ba3d8..ab71e0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/pwm.rs b/src/pwm.rs index 27fff02..da79c9f 100644 --- a/src/pwm.rs +++ b/src/pwm.rs @@ -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),); diff --git a/src/timers.rs b/src/timers.rs index 136bc93..1902de2 100644 --- a/src/timers.rs +++ b/src/timers.rs @@ -333,6 +333,31 @@ channel_impl!( TIM17, PinC1, PB9, Alternate; ); +#[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; + TIM2, PinC2, PA1, Alternate; + TIM2, PinC3, PA2, Alternate; + TIM2, PinC4, PA3, Alternate; + TIM2, PinC1, PA5, Alternate; + TIM2, PinC1, PA15, Alternate; + TIM2, PinC2, PB3, Alternate; + TIM2, PinC3, PB10, Alternate; + TIM2, PinC4, PB11, Alternate; +); + #[cfg(any( feature = "stm32f030x8", feature = "stm32f030xc",