From f97273f8ae176c1a22d6d5948825c8362d4e4525 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sun, 14 Jul 2019 20:49:41 +0200 Subject: [PATCH] Library: Extended timer functions --- lib/ext-timer.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 lib/ext-timer.h diff --git a/lib/ext-timer.h b/lib/ext-timer.h new file mode 100644 index 0000000..e05736f --- /dev/null +++ b/lib/ext-timer.h @@ -0,0 +1,27 @@ +/* + * Timer Functions Missing from LibOpenCM3 + * + * (c) 2019 Martin Mareš + */ + +#ifndef _EXT_TIMER_H +#define _EXT_TIMER_H + +#include + +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 -- 2.39.2