aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPiotr Esden-Tempski2011-01-31 16:15:09 -0800
committerPiotr Esden-Tempski2011-01-31 16:15:09 -0800
commite85c55a9a70f8f357aceba4cbacd7762ca773d7b (patch)
tree5bac82ef2d4500d42775e28c1814ae4fcb05d983
parentdd0018ffdf89210f04d5fb3ca153c9cbab7c3144 (diff)
Added timer flag reset function.
-rw-r--r--examples/stm32/stm32-h103/pwm_6step/pwm_6step.c3
-rw-r--r--include/libopencm3/stm32/timer.h1
-rw-r--r--lib/stm32/timer.c5
3 files changed, 8 insertions, 1 deletions
diff --git a/examples/stm32/stm32-h103/pwm_6step/pwm_6step.c b/examples/stm32/stm32-h103/pwm_6step/pwm_6step.c
index 9c04c9b..cf53ac6 100644
--- a/examples/stm32/stm32-h103/pwm_6step/pwm_6step.c
+++ b/examples/stm32/stm32-h103/pwm_6step/pwm_6step.c
@@ -253,7 +253,8 @@ void tim1_trg_com_isr(void)
{
static int step = 0;
- TIM1_SR &= ~TIM_SR_COMIF;
+ /* Clear the COM trigger interrupt flag. */
+ timer_clear_flag(TIM1, TIM_SR_COMIF);
/* A simplified and inefficient implementation of PWM On
* scheme. Look at the implementation in Open-BLDC on
diff --git a/include/libopencm3/stm32/timer.h b/include/libopencm3/stm32/timer.h
index 5d1c235..c3bc195 100644
--- a/include/libopencm3/stm32/timer.h
+++ b/include/libopencm3/stm32/timer.h
@@ -854,6 +854,7 @@ enum tim_oc_mode {
/* --- TIM functions ------------------------------------------------------- */
void timer_enable_irq(u32 timer_peripheral, u32 irq);
void timer_disable_irq(u32 timer_peripheral, u32 irq);
+void timer_clear_flag(u32 timer_peripheral, u32 flag);
void timer_set_mode(u32 timer_peripheral, u8 clock_div,
u8 alignment, u8 direction);
void timer_set_clock_division(u32 timer_peripheral, u32 clock_div);
diff --git a/lib/stm32/timer.c b/lib/stm32/timer.c
index 15e3b14..8c612ed 100644
--- a/lib/stm32/timer.c
+++ b/lib/stm32/timer.c
@@ -37,6 +37,11 @@ void timer_disable_irq(u32 timer_peripheral, u32 irq)
TIM_DIER(timer_peripheral) &= ~irq;
}
+void timer_clear_flag(u32 timer_peripheral, u32 flag)
+{
+ TIM_SR(timer_peripheral) &= ~flag;
+}
+
void timer_set_mode(u32 timer_peripheral, u8 clock_div,
u8 alignment, u8 direction)
{