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);
void set_servo_timer(uint32_t timer, uint32_t freq, uint8_t channels_mask)
Set Timer configuration.
stm32 arch dependant microcontroller initialisation functions.
uint32_t timer_get_frequency(uint32_t timer_peripheral)
Get Timer clock frequency (before prescaling) Only valid if using the internal clock for the timer...
void actuators_pwm_arch_channel_init(uint32_t timer_peripheral, enum tim_oc_id oc_id)
Set PWM channel configuration.
STM32 PWM and dualPWM servos shared functions.