]> mj.ucw.cz Git - home-hw.git/commitdiff
Library: Extended timer functions
authorMartin Mares <mj@ucw.cz>
Sun, 14 Jul 2019 18:49:41 +0000 (20:49 +0200)
committerMartin Mares <mj@ucw.cz>
Sun, 14 Jul 2019 18:49:41 +0000 (20:49 +0200)
lib/ext-timer.h [new file with mode: 0644]

diff --git a/lib/ext-timer.h b/lib/ext-timer.h
new file mode 100644 (file)
index 0000000..e05736f
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ *     Timer Functions Missing from LibOpenCM3
+ *
+ *     (c) 2019 Martin Mareš <mj@ucw.cz>
+ */
+
+#ifndef _EXT_TIMER_H
+#define _EXT_TIMER_H
+
+#include <libopencm3/stm32/timer.h>
+
+static inline bool timer_is_counter_enabled(u32 timer)
+{
+       return TIM_CR1(timer) & TIM_CR1_CEN;
+}
+
+static inline void timer_enable_dma_cc1(u32 timer)
+{
+       TIM_DIER(timer) |= TIM_DIER_CC1DE;
+}
+
+static inline void timer_disable_dma_cc1(u32 timer)
+{
+       TIM_DIER(timer) &= ~TIM_DIER_CC1DE;
+}
+
+#endif