28 #include <libopencm3/stm32/timer.h>
39 timer_disable_oc_output(timer_peripheral, oc_id);
41 if (timer_peripheral != TIM9 && timer_peripheral != TIM12) {
42 timer_disable_oc_clear(timer_peripheral, oc_id);
44 timer_enable_oc_preload(timer_peripheral, oc_id);
45 timer_set_oc_slow_mode(timer_peripheral, oc_id);
46 timer_set_oc_mode(timer_peripheral, oc_id, TIM_OCM_PWM1);
47 timer_set_oc_polarity_high(timer_peripheral, oc_id);
48 timer_enable_oc_output(timer_peripheral, oc_id);
50 timer_enable_break_main_output(timer_peripheral);
69 if ((timer == TIM9) || (timer == TIM12))
72 timer_set_mode(timer, TIM_CR1_CKD_CK_INT, 0, 0);
74 timer_set_mode(timer, TIM_CR1_CKD_CK_INT, TIM_CR1_CMS_EDGE, TIM_CR1_DIR_UP);
82 timer_disable_preload(timer);
84 timer_continuous_mode(timer);
89 if (bit_is_set(channels_mask, 0)) {
92 if (bit_is_set(channels_mask, 1)) {
95 if (bit_is_set(channels_mask, 2)) {
98 if (bit_is_set(channels_mask, 3)) {
119 timer_enable_preload(timer);
122 timer_enable_counter(timer);