From: Martin Mares Date: Sun, 14 Jul 2019 18:49:41 +0000 (+0200) Subject: Library: Extended timer functions X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=f97273f8ae176c1a22d6d5948825c8362d4e4525;p=home-hw.git Library: Extended timer functions --- 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