aboutsummaryrefslogtreecommitdiff
path: root/lib/stm32/timer.c
diff options
context:
space:
mode:
authorPiotr Esden-Tempski2011-02-01 22:43:18 -0800
committerPiotr Esden-Tempski2011-02-01 22:43:18 -0800
commitc7587f11ec52157fffd8dbdc6b0d800e349f8bc1 (patch)
treef1e81b61ddb3dfe179fccac436f70a7f0ca1bde2 /lib/stm32/timer.c
parentd40fb96fcf6b7415c445df036641ebd1fa00e55c (diff)
Added get flag and get counter functions to timer. Allow proper interrupt handling and recording timer counter values.
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 827cde0..d0876d9 100644
--- a/lib/stm32/timer.c
+++ b/lib/stm32/timer.c
@@ -104,6 +104,16 @@ void timer_disable_irq(u32 timer_peripheral, u32 irq)
TIM_DIER(timer_peripheral) &= ~irq;
}
+bool timer_get_flag(u32 timer_peripheral, u32 flag)
+{
+ if (((TIM_SR(timer_peripheral) & flag) != 0) &&
+ ((TIM_DIER(timer_peripheral) & flag) != 0)) {
+ return true;
+ }
+
+ return false;
+}
+
void timer_clear_flag(u32 timer_peripheral, u32 flag)
{
TIM_SR(timer_peripheral) &= ~flag;
@@ -929,3 +939,8 @@ void timer_generate_event(u32 timer_peripheral, u32 event)
{
TIM_EGR(timer_peripheral) |= event;
}
+
+u32 timer_get_counter(u32 timer_peripheral)
+{
+ return TIM_CNT(timer_peripheral);
+}