29 #include "subsystems/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
90 nvic_set_priority(NVIC_TIM5_IRQ, 2);
91 nvic_enable_irq(NVIC_TIM5_IRQ);
92 timer_enable_irq(TIM5, TIM_DIER_CC1IE);
104 #if DUAL_PWM_USE_TIM5
120 #if DUAL_PWM_USE_TIM5
129 #if DUAL_PWM_USE_TIM5
130 timer_set_period(TIM5, period);
138 #if DUAL_PWM_USE_TIM5
139 timer_set_oc_value(DUAL_PWM_SERVO_5_TIMER, DUAL_PWM_SERVO_5_OC, oc_value);
140 timer_set_oc_value(DUAL_PWM_SERVO_6_TIMER, DUAL_PWM_SERVO_6_OC, oc_value2);
150 static int num_pulse = 0;
154 if (num_pulse == 1) {
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.
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.
void set_servo_timer(uint32_t timer, uint32_t freq, uint8_t channels_mask)
Set Timer configuration.
void set_dual_pwm_timer_s_period(uint32_t period)
void set_dual_pwm_timer_s_oc(uint32_t oc_value, uint32_t oc_value2)
#define ACTUATORS_DUALPWM_NB
timer_clear_flag(TIMx, TIM_SR_UIF)
#define PWM_TIM5_CHAN_MASK
STM32 PWM and dualPWM servos shared functions.
void actuators_dualpwm_arch_init(void)
Arch dependent init file.
uint32_t actuators_dualpwm_values[ACTUATORS_DUALPWM_NB]