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);
66 if ((timer == TIM9) || (timer == TIM12))
69 timer_set_mode(timer, TIM_CR1_CKD_CK_INT, 0, 0);
71 timer_set_mode(timer, TIM_CR1_CKD_CK_INT, TIM_CR1_CMS_EDGE, TIM_CR1_DIR_UP);
79 timer_disable_preload(timer);
81 timer_continuous_mode(timer);
86 if (bit_is_set(channels_mask, 0)) {
89 if (bit_is_set(channels_mask, 1)) {
92 if (bit_is_set(channels_mask, 2)) {
95 if (bit_is_set(channels_mask, 3)) {
116 timer_enable_preload(timer);
119 timer_enable_counter(timer);
void actuators_pwm_arch_channel_init(uint32_t timer_peripheral, enum tim_oc_id oc_id)
Set PWM channel configuration.
void set_servo_timer(uint32_t timer, uint32_t freq, uint8_t channels_mask)
Set Timer configuration.
STM32 PWM and dualPWM servos shared 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.
stm32 arch dependant microcontroller initialisation functions.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.