Paparazzi UAS  v5.2.2_stable-0-gd6b9f29
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
actuators_pwm_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 ARE TIM1,2,3,4,5,8,9,12
27 
29 #include "subsystems/actuators/actuators_pwm_arch.h"
31 
32 #include <libopencm3/stm32/gpio.h>
33 #include <libopencm3/stm32/rcc.h>
34 #include <libopencm3/stm32/timer.h>
35 
36 #include "mcu_periph/gpio_arch.h"
37 
38 
40 
41 
45 
46  /*-----------------------------------
47  * Configure timer peripheral clocks
48  *-----------------------------------*/
49 #if PWM_USE_TIM1
50  rcc_periph_clock_enable(RCC_TIM1);
51 #endif
52 #if PWM_USE_TIM2
53  rcc_periph_clock_enable(RCC_TIM2);
54 #endif
55 #if PWM_USE_TIM3
56  rcc_periph_clock_enable(RCC_TIM3);
57 #endif
58 #if PWM_USE_TIM4
59  rcc_periph_clock_enable(RCC_TIM4);
60 #endif
61 #if PWM_USE_TIM5
62  rcc_periph_clock_enable(RCC_TIM5);
63 #endif
64 #if PWM_USE_TIM8
65  rcc_periph_clock_enable(RCC_TIM8);
66 #endif
67 #if PWM_USE_TIM9
68  rcc_periph_clock_enable(RCC_TIM9);
69 #endif
70 #if PWM_USE_TIM12
71  rcc_periph_clock_enable(RCC_TIM12);
72 #endif
73 
74  /*----------------
75  * Configure GPIO
76  *----------------*/
77 #ifdef PWM_SERVO_0
79 #endif
80 #ifdef PWM_SERVO_1
82 #endif
83 #ifdef PWM_SERVO_2
85 #endif
86 #ifdef PWM_SERVO_3
88 #endif
89 #ifdef PWM_SERVO_4
91 #endif
92 #ifdef PWM_SERVO_5
94 #endif
95 #ifdef PWM_SERVO_6
97 #endif
98 #ifdef PWM_SERVO_7
100 #endif
101 #ifdef PWM_SERVO_8
103 #endif
104 #ifdef PWM_SERVO_9
106 #endif
107 #ifdef PWM_SERVO_10
108  gpio_setup_pin_af(PWM_SERVO_10_GPIO, PWM_SERVO_10_PIN, PWM_SERVO_10_AF, TRUE);
109 #endif
110 #ifdef PWM_SERVO_11
111  gpio_setup_pin_af(PWM_SERVO_11_GPIO, PWM_SERVO_11_PIN, PWM_SERVO_11_AF, TRUE);
112 #endif
113 
114 #if PWM_USE_TIM1
116 #endif
117 
118 #if PWM_USE_TIM2
120 #endif
121 
122 #if PWM_USE_TIM3
124 #endif
125 
126 #if PWM_USE_TIM4
128 #endif
129 
130 #if PWM_USE_TIM5
132 #endif
133 
134 #if PWM_USE_TIM8
136 #endif
137 
138 #if PWM_USE_TIM9
140 #endif
141 
142 #if PWM_USE_TIM12
144 #endif
145 
146 }
147 
151 #ifdef PWM_SERVO_0
153 #endif
154 #ifdef PWM_SERVO_1
156 #endif
157 #ifdef PWM_SERVO_2
159 #endif
160 #ifdef PWM_SERVO_3
162 #endif
163 #ifdef PWM_SERVO_4
165 #endif
166 #ifdef PWM_SERVO_5
168 #endif
169 #ifdef PWM_SERVO_6
171 #endif
172 #ifdef PWM_SERVO_7
174 #endif
175 #ifdef PWM_SERVO_8
177 #endif
178 #ifdef PWM_SERVO_9
180 #endif
181 #ifdef PWM_SERVO_10
182  timer_set_oc_value(PWM_SERVO_10_TIMER, PWM_SERVO_10_OC, actuators_pwm_values[PWM_SERVO_10]);
183 #endif
184 #ifdef PWM_SERVO_11
185  timer_set_oc_value(PWM_SERVO_11_TIMER, PWM_SERVO_11_OC, actuators_pwm_values[PWM_SERVO_11]);
186 #endif
187 
188 }
#define TIM9_SERVO_HZ
#define PWM_SERVO_0_OC
Definition: apogee_0.99.h:171
#define PWM_SERVO_6_OC
Definition: krooz_sd.h:297
#define PWM_SERVO_0_PIN
Definition: apogee_0.99.h:169
#define PWM_SERVO_9
Definition: krooz_sd.h:328
#define PWM_SERVO_5_OC
Definition: apogee_0.99.h:231
#define PWM_SERVO_3
Definition: apogee_1.0.h:268
#define PWM_SERVO_7_AF
Definition: krooz_sd.h:308
#define PWM_SERVO_2_OC
Definition: apogee_0.99.h:195
#define PWM_SERVO_0
Definition: apogee_0.99.h:166
#define PWM_SERVO_4_AF
Definition: apogee_0.99.h:218
#define PWM_SERVO_3_OC
Definition: apogee_0.99.h:207
#define PWM_SERVO_8_TIMER
Definition: krooz_sd.h:317
#define PWM_SERVO_8_GPIO
Definition: krooz_sd.h:318
#define TIM2_SERVO_HZ
#define PWM_TIM9_CHAN_MASK
#define PWM_TIM3_CHAN_MASK
Definition: apogee_0.99.h:240
#define PWM_SERVO_1_GPIO
Definition: apogee_0.99.h:180
#define PWM_SERVO_1_OC
Definition: apogee_0.99.h:183
#define PWM_SERVO_4_OC
Definition: apogee_0.99.h:219
#define PWM_SERVO_3_AF
Definition: apogee_0.99.h:206
void actuators_pwm_commit(void)
Set pulse widths from actuator values, assumed to be in us.
#define TIM4_SERVO_HZ
#define PWM_SERVO_2_GPIO
Definition: apogee_0.99.h:192
#define TIM8_SERVO_HZ
#define TIM3_SERVO_HZ
#define PWM_SERVO_9_OC
Definition: krooz_sd.h:333
#define PWM_SERVO_4
Definition: apogee_0.99.h:214
#define PWM_SERVO_8_PIN
Definition: krooz_sd.h:319
#define PWM_SERVO_2
Definition: apogee_0.99.h:190
#define PWM_SERVO_7_TIMER
Definition: krooz_sd.h:305
#define PWM_SERVO_6_TIMER
Definition: krooz_sd.h:293
#define PWM_SERVO_3_PIN
Definition: apogee_0.99.h:205
#define PWM_TIM2_CHAN_MASK
Definition: apogee_0.99.h:239
#define PWM_TIM4_CHAN_MASK
Definition: krooz_sd.h:353
#define PWM_SERVO_8_AF
Definition: krooz_sd.h:320
#define PWM_SERVO_1_AF
Definition: apogee_0.99.h:182
#define PWM_SERVO_1
Definition: apogee_0.99.h:178
#define PWM_SERVO_2_AF
Definition: apogee_0.99.h:194
int32_t actuators_pwm_values[ACTUATORS_PWM_NB]
#define PWM_SERVO_8
Definition: krooz_sd.h:316
#define PWM_SERVO_3_GPIO
Definition: apogee_0.99.h:204
#define PWM_SERVO_0_GPIO
Definition: apogee_0.99.h:168
#define PWM_SERVO_6_PIN
Definition: krooz_sd.h:295
void set_servo_timer(uint32_t timer, uint32_t period, uint8_t channels_mask)
Set Timer configuration.
#define PWM_SERVO_1_TIMER
Definition: apogee_0.99.h:179
#define PWM_SERVO_7_GPIO
Definition: krooz_sd.h:306
#define PWM_SERVO_3_TIMER
Definition: apogee_0.99.h:203
#define PWM_SERVO_6
Definition: krooz_sd.h:292
#define PWM_TIM12_CHAN_MASK
#define PWM_SERVO_1_PIN
Definition: apogee_0.99.h:181
#define PWM_SERVO_7_OC
Definition: krooz_sd.h:309
#define PWM_TIM5_CHAN_MASK
Definition: krooz_sd.h:354
#define PWM_SERVO_0_TIMER
Definition: apogee_0.99.h:167
#define PWM_SERVO_5
Definition: apogee_0.99.h:226
#define PWM_SERVO_7_PIN
Definition: krooz_sd.h:307
#define PWM_SERVO_6_AF
Definition: krooz_sd.h:296
#define PWM_SERVO_5_GPIO
Definition: apogee_0.99.h:228
#define PWM_SERVO_9_PIN
Definition: krooz_sd.h:331
#define ACTUATORS_PWM_NB
STM32 PWM and dualPWM servos shared functions.
signed long int32_t
Definition: types.h:19
#define TRUE
Definition: imu_chimu.h:144
#define PWM_SERVO_2_TIMER
Definition: apogee_0.99.h:191
void gpio_setup_pin_af(uint32_t port, uint16_t pin, uint8_t af, bool_t is_output)
Setup a gpio for input or output with alternate function.
#define TIM1_SERVO_HZ
#define PWM_SERVO_0_AF
Definition: apogee_0.99.h:170
#define PWM_SERVO_4_PIN
Definition: apogee_0.99.h:217
#define PWM_SERVO_8_OC
Definition: krooz_sd.h:321
#define PWM_SERVO_9_AF
Definition: krooz_sd.h:332
#define PWM_SERVO_9_GPIO
Definition: krooz_sd.h:330
#define PWM_SERVO_2_PIN
Definition: apogee_0.99.h:193
#define PWM_SERVO_5_AF
Definition: apogee_0.99.h:230
#define PWM_SERVO_4_GPIO
Definition: apogee_0.99.h:216
#define PWM_SERVO_9_TIMER
Definition: krooz_sd.h:329
#define TIM12_SERVO_HZ
#define PWM_SERVO_7
Definition: krooz_sd.h:304
#define PWM_SERVO_4_TIMER
Definition: apogee_0.99.h:215
#define PWM_SERVO_6_GPIO
Definition: krooz_sd.h:294
void actuators_pwm_arch_init(void)
Arch dependent init file.
#define PWM_SERVO_5_PIN
Definition: apogee_0.99.h:229
#define PWM_SERVO_5_TIMER
Definition: apogee_0.99.h:227
#define TIM5_SERVO_HZ