aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Daede2012-10-31 00:42:58 -0500
committerThomas Daede2012-10-31 00:42:58 -0500
commit94689337352002fa3dfb3dc14804c1f6d087750a (patch)
treea96dbf99873a21f5e4280fbb7330034fb7aac835
parenta56764667c9b94747ea91edbe413c8c1329587fe (diff)
Add back timer_set_option for STM32F4, and document.
-rw-r--r--lib/stm32/timer.c24
1 files changed, 24 insertions, 0 deletions
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 <libopencm3/stm32/f2/rcc.h>
#elif defined(STM32F4)
+# include <libopencm3/stm32/f4/timer.h>
# include <libopencm3/stm32/f4/rcc.h>
#else
# error "stm32 family not defined."
@@ -1707,6 +1708,29 @@ u32 timer_get_counter(u32 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
Set the value of a timer's counter register contents.