29 #include "modules/actuators/actuators_dualpwm_arch.h"
32 #include <libopencm3/stm32/gpio.h>
33 #include <libopencm3/stm32/rcc.h>
34 #include <libopencm3/stm32/timer.h>
35 #include <libopencm3/cm3/nvic.h>
37 #include "mcu_periph/gpio_arch.h"
53 rcc_periph_clock_enable(RCC_TIM1);
56 rcc_periph_clock_enable(RCC_TIM2);
59 rcc_periph_clock_enable(RCC_TIM3);
62 rcc_periph_clock_enable(RCC_TIM4);
65 rcc_periph_clock_enable(RCC_TIM5);
68 rcc_periph_clock_enable(RCC_TIM8);
71 rcc_periph_clock_enable(RCC_TIM9);
74 rcc_periph_clock_enable(RCC_TIM12);
80 #ifdef DUAL_PWM_SERVO_5
83 #ifdef DUAL_PWM_SERVO_6
88 rcc_periph_reset_pulse(RST_TIM5);
91 nvic_set_priority(NVIC_TIM5_IRQ, 2);
92 nvic_enable_irq(NVIC_TIM5_IRQ);
93 timer_enable_irq(TIM5, TIM_DIER_CC1IE);
105 #if DUAL_PWM_USE_TIM5
121 #if DUAL_PWM_USE_TIM5
122 timer_clear_flag(TIM5, TIM_SR_CC1IF);
130 #if DUAL_PWM_USE_TIM5
131 timer_set_period(TIM5, period);
139 #if DUAL_PWM_USE_TIM5
140 timer_set_oc_value(DUAL_PWM_SERVO_5_TIMER, DUAL_PWM_SERVO_5_OC, oc_value);
141 timer_set_oc_value(DUAL_PWM_SERVO_6_TIMER, DUAL_PWM_SERVO_6_OC, oc_value2);
151 static int num_pulse = 0;
155 if (num_pulse == 1) {
void set_servo_timer(uint32_t timer, uint32_t freq, uint8_t channels_mask)
Set Timer configuration.
STM32 PWM and dualPWM servos shared functions.
void gpio_setup_pin_af(ioportid_t port, uint16_t pin, uint8_t af, bool is_output)
Setup a gpio for input or output with alternate function.
#define PWM_TIM5_CHAN_MASK
void actuators_dualpwm_arch_init(void)
Arch dependent init file.
void set_dual_pwm_timer_s_oc(uint32_t oc_value, uint32_t oc_value2)
void set_dual_pwm_timer_s_period(uint32_t period)
void actuators_dualpwm_commit(void)
Set pulse widths from actuator values, assumed to be in us.
void clear_timer_flag(void)
Interuption called at the end of the timer.
uint32_t actuators_dualpwm_values[ACTUATORS_DUALPWM_NB]
#define ACTUATORS_DUALPWM_NB
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.