Paparazzi UAS  v5.8.2_stable-0-g6260b7c
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces 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  /*-----------------------------------
48  * Configure timer peripheral clocks
49  *-----------------------------------*/
50 #if PWM_USE_TIM1
51  rcc_periph_clock_enable(RCC_TIM1);
52 #endif
53 #if PWM_USE_TIM2
54  rcc_periph_clock_enable(RCC_TIM2);
55 #endif
56 #if PWM_USE_TIM3
57  rcc_periph_clock_enable(RCC_TIM3);
58 #endif
59 #if PWM_USE_TIM4
60  rcc_periph_clock_enable(RCC_TIM4);
61 #endif
62 #if PWM_USE_TIM5
63  rcc_periph_clock_enable(RCC_TIM5);
64 #endif
65 #if PWM_USE_TIM8
66  rcc_periph_clock_enable(RCC_TIM8);
67 #endif
68 #if PWM_USE_TIM9
69  rcc_periph_clock_enable(RCC_TIM9);
70 #endif
71 #if PWM_USE_TIM12
72  rcc_periph_clock_enable(RCC_TIM12);
73 #endif
74 
75  /*----------------
76  * Configure GPIO
77  *----------------*/
78 #ifdef PWM_SERVO_0
80 #endif
81 #ifdef PWM_SERVO_1
83 #endif
84 #ifdef PWM_SERVO_2
86 #endif
87 #ifdef PWM_SERVO_3
89 #endif
90 #ifdef PWM_SERVO_4
92 #endif
93 #ifdef PWM_SERVO_5
95 #endif
96 #ifdef PWM_SERVO_6
98 #endif
99 #ifdef PWM_SERVO_7
101 #endif
102 #ifdef PWM_SERVO_8
104 #endif
105 #ifdef PWM_SERVO_9
107 #endif
108 #ifdef PWM_SERVO_10
109  gpio_setup_pin_af(PWM_SERVO_10_GPIO, PWM_SERVO_10_PIN, PWM_SERVO_10_AF, TRUE);
110 #endif
111 #ifdef PWM_SERVO_11
112  gpio_setup_pin_af(PWM_SERVO_11_GPIO, PWM_SERVO_11_PIN, PWM_SERVO_11_AF, TRUE);
113 #endif
114 
115 #if PWM_USE_TIM1
117 #endif
118 
119 #if PWM_USE_TIM2
121 #endif
122 
123 #if PWM_USE_TIM3
125 #endif
126 
127 #if PWM_USE_TIM4
129 #endif
130 
131 #if PWM_USE_TIM5
133 #endif
134 
135 #if PWM_USE_TIM8
137 #endif
138 
139 #if PWM_USE_TIM9
141 #endif
142 
143 #if PWM_USE_TIM12
145 #endif
146 
147 }
148 
152 {
153 #ifdef PWM_SERVO_0
155 #endif
156 #ifdef PWM_SERVO_1
158 #endif
159 #ifdef PWM_SERVO_2
161 #endif
162 #ifdef PWM_SERVO_3
164 #endif
165 #ifdef PWM_SERVO_4
167 #endif
168 #ifdef PWM_SERVO_5
170 #endif
171 #ifdef PWM_SERVO_6
173 #endif
174 #ifdef PWM_SERVO_7
176 #endif
177 #ifdef PWM_SERVO_8
179 #endif
180 #ifdef PWM_SERVO_9
182 #endif
183 #ifdef PWM_SERVO_10
184  timer_set_oc_value(PWM_SERVO_10_TIMER, PWM_SERVO_10_OC, actuators_pwm_values[PWM_SERVO_10]);
185 #endif
186 #ifdef PWM_SERVO_11
187  timer_set_oc_value(PWM_SERVO_11_TIMER, PWM_SERVO_11_OC, actuators_pwm_values[PWM_SERVO_11]);
188 #endif
189 
190 }
#define TIM9_SERVO_HZ
#define PWM_SERVO_9
Definition: krooz_sd.h:328
#define PWM_SERVO_3_AF
Definition: apogee_1.0.h:285
#define PWM_SERVO_3
Definition: apogee_1.0.h:281
#define PWM_SERVO_7_AF
Definition: krooz_sd.h:308
void set_servo_timer(uint32_t timer, uint32_t freq, uint8_t channels_mask)
Set Timer configuration.
#define PWM_SERVO_1_AF
Definition: apogee_1.0.h:255
#define PWM_SERVO_8_TIMER
Definition: krooz_sd.h:317
#define PWM_SERVO_8_GPIO
Definition: krooz_sd.h:318
#define PWM_SERVO_4
Definition: apogee_1.0.h:296
#define TIM2_SERVO_HZ
#define PWM_TIM9_CHAN_MASK
#define PWM_SERVO_4_TIMER
Definition: apogee_1.0.h:297
#define PWM_SERVO_0_OC
Definition: apogee_1.0.h:241
void actuators_pwm_commit(void)
Set pulse widths from actuator values, assumed to be in us.
#define TIM4_SERVO_HZ
#define TIM8_SERVO_HZ
#define PWM_SERVO_1_GPIO
Definition: apogee_1.0.h:253
#define TIM3_SERVO_HZ
#define PWM_SERVO_2
Definition: apogee_1.0.h:266
#define PWM_SERVO_6_AF
Definition: elle0_common.h:413
#define PWM_SERVO_9_OC
Definition: krooz_sd.h:333
#define PWM_SERVO_6_OC
Definition: elle0_common.h:414
#define PWM_SERVO_3_PIN
Definition: apogee_1.0.h:284
#define PWM_SERVO_1
Definition: apogee_1.0.h:251
#define PWM_SERVO_0_TIMER
Definition: apogee_1.0.h:237
#define PWM_SERVO_5_AF
Definition: apogee_1.0.h:315
#define PWM_SERVO_5_GPIO
Definition: apogee_1.0.h:313
#define PWM_SERVO_8_PIN
Definition: krooz_sd.h:319
#define PWM_SERVO_2_TIMER
Definition: apogee_1.0.h:267
#define PWM_SERVO_2_AF
Definition: apogee_1.0.h:270
#define PWM_SERVO_4_PIN
Definition: apogee_1.0.h:299
#define PWM_SERVO_7_TIMER
Definition: krooz_sd.h:305
#define PWM_SERVO_6_GPIO
Definition: elle0_common.h:411
#define PWM_SERVO_1_TIMER
Definition: apogee_1.0.h:252
#define PWM_SERVO_5_TIMER
Definition: apogee_1.0.h:312
#define PWM_SERVO_8_AF
Definition: krooz_sd.h:320
#define PWM_SERVO_4_OC
Definition: apogee_1.0.h:301
#define TRUE
Definition: std.h:4
#define PWM_SERVO_2_PIN
Definition: apogee_1.0.h:269
int32_t actuators_pwm_values[ACTUATORS_PWM_NB]
#define PWM_SERVO_8
Definition: krooz_sd.h:316
#define PWM_TIM4_CHAN_MASK
Definition: cc3d.h:236
#define PWM_SERVO_5
Definition: apogee_1.0.h:311
#define PWM_TIM5_CHAN_MASK
Definition: elle0_common.h:447
#define PWM_SERVO_4_GPIO
Definition: apogee_1.0.h:298
#define PWM_TIM1_CHAN_MASK
Definition: cc3d.h:238
#define PWM_TIM2_CHAN_MASK
Definition: apogee_1.0.h:336
#define PWM_SERVO_7_GPIO
Definition: krooz_sd.h:306
#define PWM_TIM12_CHAN_MASK
#define PWM_SERVO_6
Definition: elle0_common.h:409
#define PWM_SERVO_7_OC
Definition: krooz_sd.h:309
#define PWM_SERVO_6_PIN
Definition: elle0_common.h:412
#define PWM_SERVO_7_PIN
Definition: krooz_sd.h:307
#define PWM_SERVO_9_PIN
Definition: krooz_sd.h:331
#define PWM_SERVO_0_AF
Definition: apogee_1.0.h:240
#define ACTUATORS_PWM_NB
STM32 PWM and dualPWM servos shared functions.
signed long int32_t
Definition: types.h:19
#define PWM_SERVO_3_OC
Definition: apogee_1.0.h:286
#define PWM_SERVO_0_GPIO
Definition: apogee_1.0.h:238
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_8_OC
Definition: krooz_sd.h:321
#define PWM_SERVO_6_TIMER
Definition: elle0_common.h:410
#define PWM_SERVO_9_AF
Definition: krooz_sd.h:332
#define PWM_SERVO_1_PIN
Definition: apogee_1.0.h:254
#define PWM_SERVO_9_GPIO
Definition: krooz_sd.h:330
#define PWM_SERVO_3_GPIO
Definition: apogee_1.0.h:283
#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_1_OC
Definition: apogee_1.0.h:256
#define PWM_SERVO_5_PIN
Definition: apogee_1.0.h:314
void actuators_pwm_arch_init(void)
Arch dependent init file.
#define PWM_SERVO_2_OC
Definition: apogee_1.0.h:271
#define PWM_SERVO_0
Definition: apogee_1.0.h:236
#define PWM_TIM3_CHAN_MASK
Definition: apogee_1.0.h:337
#define PWM_SERVO_0_PIN
Definition: apogee_1.0.h:239
#define PWM_SERVO_3_TIMER
Definition: apogee_1.0.h:282
#define PWM_SERVO_5_OC
Definition: apogee_1.0.h:316
#define TIM5_SERVO_HZ
#define PWM_SERVO_4_AF
Definition: apogee_1.0.h:300
#define PWM_SERVO_2_GPIO
Definition: apogee_1.0.h:268