Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
actuators_dualpwm_arch.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010 The Paparazzi Team
3 *
4 * This file is part of Paparazzi.
5 *
6 * Paparazzi is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * Paparazzi is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with Paparazzi; see the file COPYING. If not, write to
18 * the Free Software Foundation, 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
26//VALID TIMERS IS TIM5 ON THE LISA/M
27
29#include "modules/actuators/actuators_dualpwm_arch.h"
31
32#include <libopencm3/stm32/gpio.h>
33#include <libopencm3/stm32/rcc.h>
34#include <libopencm3/stm32/timer.h>
35#include <libopencm3/cm3/nvic.h>
36
37#include "mcu_periph/gpio_arch.h"
38
40
41
43
47{
48
49 /*-----------------------------------
50 * Configure timer peripheral clocks
51 *-----------------------------------*/
52#if PWM_USE_TIM1
54#endif
55#if PWM_USE_TIM2
57#endif
58#if PWM_USE_TIM3
60#endif
61#if PWM_USE_TIM4
63#endif
64#if PWM_USE_TIM5
66#endif
67#if PWM_USE_TIM8
69#endif
70#if PWM_USE_TIM9
72#endif
73#if PWM_USE_TIM12
75#endif
76
77 /*----------------
78 * Configure GPIO
79 *----------------*/
80#ifdef DUAL_PWM_SERVO_5
82#endif
83#ifdef DUAL_PWM_SERVO_6
85#endif
86
87#if DUAL_PWM_USE_TIM5
90
94#endif
95
96 //calculation the values to put into the timer registers to generate pulses every 4ms and 16ms.
97 ratio_4ms = (ONE_MHZ_CLK / 250) - 1;
98 ratio_16ms = (ONE_MHZ_CLK / 62.5) - 1;
99
100}
101
102
105#if DUAL_PWM_USE_TIM5
106void tim5_isr(void)
107{
108
109 dual_pwm_isr();
110}
111#endif
112
113
114
115
119{
120
121#if DUAL_PWM_USE_TIM5
123#endif
124}
125
126
128{
129
130#if DUAL_PWM_USE_TIM5
132#endif
133}
134
135
144
145
146
147
148void dual_pwm_isr(void)
149{
150
151 static int num_pulse = 0; //status of the timer. Are we controling the first or the second servo
152
154
155 if (num_pulse == 1) {
156
159
160 num_pulse = 0;
161 } else {
162
165
166 num_pulse = 1;
167 }
168}
169
170
174{
175
176 //we don't need to commit the values into this function as far as it's done in the interuption
177 //(wich is called every 4ms and 16ms alternatively (twice every 20ms))
178
179}
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.
Definition gpio_arch.c:65
#define ONE_MHZ_CLK
#define TIM5_SERVO_HZ
#define PWM_TIM5_CHAN_MASK
uint16_t foo
Definition main_demo5.c:58
void actuators_dualpwm_arch_init(void)
Arch dependent init file.
#define TRUE
Definition std.h:4
uint32_t ratio_4ms
uint32_t ratio_16ms
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 dual_pwm_isr(void)
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.