From 94689337352002fa3dfb3dc14804c1f6d087750a Mon Sep 17 00:00:00 2001 From: Thomas Daede Date: Wed, 31 Oct 2012 00:42:58 -0500 Subject: Add back timer_set_option for STM32F4, and document. --- lib/stm32/timer.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/stm32/timer.c b/lib/stm32/timer.c index 86c9860..e6c51cf 100644 --- a/lib/stm32/timer.c +++ b/lib/stm32/timer.c @@ -103,6 +103,7 @@ push-pull outputs where the PWM output will appear. #elif defined(STM32F2) # include #elif defined(STM32F4) +# include # include #else # error "stm32 family not defined." @@ -1706,6 +1707,29 @@ u32 timer_get_counter(u32 timer_peripheral) return TIM_CNT(timer_peripheral); } +/*---------------------------------------------------------------------------*/ +/** @brief Set Timer Option + +Set timer options register on TIM2 or TIM5, used for oscillator calibration +on TIM5 and trigger remapping on TIM2. Only available on F4. + +@param[in] timer_peripheral Unsigned int32. Timer register address base +@returns Unsigned int32. Option flags. +*/ + +#if (defined(STM32F4)) +void timer_set_option(u32 timer_peripheral, u32 option) +{ + if (timer_peripheral == TIM2) { + TIM_OR(timer_peripheral) &= ~TIM2_OR_ITR1_RMP_MASK; + TIM_OR(timer_peripheral) |= option; + } else if (timer_peripheral == TIM5) { + TIM_OR(timer_peripheral) &= ~TIM5_OR_TI4_RMP_MASK; + TIM_OR(timer_peripheral) |= option; + } +} +#endif + /*---------------------------------------------------------------------------*/ /** @brief Set Counter -- cgit v1.2.3