aboutsummaryrefslogtreecommitdiff
path: root/lib/stm32/timer.c
diff options
context:
space:
mode:
authorPiotr Esden-Tempski2011-01-31 13:28:54 -0800
committerPiotr Esden-Tempski2011-01-31 13:28:54 -0800
commitdd0018ffdf89210f04d5fb3ca153c9cbab7c3144 (patch)
treeef704d9ac28a46da88af8e3df867debb9c3f726d /lib/stm32/timer.c
parenta0091f18c71a19d68cf1c0de4ceb3d9e90c23c39 (diff)
Added interrupt and event generation handling functions to timer. Updated pwm 6step example to use those and commutate on button press using PWM ON scheme.
Diffstat (limited to 'lib/stm32/timer.c')
-rw-r--r--lib/stm32/timer.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/stm32/timer.c b/lib/stm32/timer.c
index 125bdff..15e3b14 100644
--- a/lib/stm32/timer.c
+++ b/lib/stm32/timer.c
@@ -27,6 +27,16 @@
#include <libopencm3/stm32/timer.h>
+void timer_enable_irq(u32 timer_peripheral, u32 irq)
+{
+ TIM_DIER(timer_peripheral) |= irq;
+}
+
+void timer_disable_irq(u32 timer_peripheral, u32 irq)
+{
+ TIM_DIER(timer_peripheral) &= ~irq;
+}
+
void timer_set_mode(u32 timer_peripheral, u8 clock_div,
u8 alignment, u8 direction)
{
@@ -829,3 +839,8 @@ void timer_set_deadtime(u32 timer_peripheral, u32 deadtime)
TIM_BDTR(timer_peripheral) |= deadtime;
}
}
+
+void timer_generate_event(u32 timer_peripheral, u32 event)
+{
+ TIM_EGR(timer_peripheral) |= event;
+}