]> mj.ucw.cz Git - home-hw.git/blob - lib/ext-timer.h
Rolety: Annotation
[home-hw.git] / lib / ext-timer.h
1 /*
2  *      Timer Functions Missing from LibOpenCM3
3  *
4  *      (c) 2019 Martin Mareš <mj@ucw.cz>
5  */
6
7 #ifndef _EXT_TIMER_H
8 #define _EXT_TIMER_H
9
10 #include <libopencm3/stm32/timer.h>
11
12 static inline bool timer_is_counter_enabled(u32 timer)
13 {
14         return TIM_CR1(timer) & TIM_CR1_CEN;
15 }
16
17 static inline void timer_enable_dma_cc1(u32 timer)
18 {
19         TIM_DIER(timer) |= TIM_DIER_CC1DE;
20 }
21
22 static inline void timer_disable_dma_cc1(u32 timer)
23 {
24         TIM_DIER(timer) &= ~TIM_DIER_CC1DE;
25 }
26
27 #endif