Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
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 "modules/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
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
115  rcc_periph_reset_pulse(RST_TIM1);
117 #endif
118 
119 #if PWM_USE_TIM2
120  rcc_periph_reset_pulse(RST_TIM2);
122 #endif
123 
124 #if PWM_USE_TIM3
125  rcc_periph_reset_pulse(RST_TIM3);
127 #endif
128 
129 #if PWM_USE_TIM4
130  rcc_periph_reset_pulse(RST_TIM4);
132 #endif
133 
134 #if PWM_USE_TIM5
135  rcc_periph_reset_pulse(RST_TIM5);
137 #endif
138 
139 #if PWM_USE_TIM8
140  rcc_periph_reset_pulse(RST_TIM8);
142 #endif
143 
144 #if PWM_USE_TIM9
145  rcc_periph_reset_pulse(RST_TIM9);
147 #endif
148 
149 #if PWM_USE_TIM12
150  rcc_periph_reset_pulse(RST_TIM12);
152 #endif
153 
154 }
155 
159 {
160 #ifdef PWM_SERVO_0
162 #endif
163 #ifdef PWM_SERVO_1
165 #endif
166 #ifdef PWM_SERVO_2
168 #endif
169 #ifdef PWM_SERVO_3
171 #endif
172 #ifdef PWM_SERVO_4
174 #endif
175 #ifdef PWM_SERVO_5
177 #endif
178 #ifdef PWM_SERVO_6
180 #endif
181 #ifdef PWM_SERVO_7
183 #endif
184 #ifdef PWM_SERVO_8
186 #endif
187 #ifdef PWM_SERVO_9
189 #endif
190 #ifdef PWM_SERVO_10
192 #endif
193 #ifdef PWM_SERVO_11
194  timer_set_oc_value(PWM_SERVO_11_TIMER, PWM_SERVO_11_OC, actuators_pwm_values[PWM_SERVO_11]);
195 #endif
196 
197 }
void set_servo_timer(uint32_t timer, uint32_t freq, uint8_t channels_mask)
Set Timer configuration.
STM32 PWM and dualPWM servos shared functions.
#define PWM_SERVO_5_GPIO
Definition: board.h:287
#define PWM_SERVO_2_AF
Definition: board.h:250
#define PWM_SERVO_0
Definition: board.h:221
#define PWM_SERVO_3_AF
Definition: board.h:263
#define PWM_SERVO_4_GPIO
Definition: board.h:274
#define PWM_SERVO_3_PIN
Definition: board.h:262
#define PWM_SERVO_1
Definition: board.h:234
#define PWM_SERVO_5_AF
Definition: board.h:289
#define PWM_SERVO_0_PIN
Definition: board.h:223
#define PWM_SERVO_3
Definition: board.h:260
#define PWM_SERVO_3_GPIO
Definition: board.h:261
#define PWM_SERVO_0_AF
Definition: board.h:224
#define PWM_SERVO_1_AF
Definition: board.h:237
#define PWM_SERVO_4_PIN
Definition: board.h:275
#define PWM_SERVO_4_AF
Definition: board.h:276
#define PWM_SERVO_5_PIN
Definition: board.h:288
#define PWM_SERVO_1_GPIO
Definition: board.h:235
#define PWM_SERVO_4
Definition: board.h:273
#define PWM_SERVO_2_PIN
Definition: board.h:249
#define PWM_SERVO_1_PIN
Definition: board.h:236
#define PWM_SERVO_2
Definition: board.h:247
#define PWM_SERVO_0_GPIO
Definition: board.h:222
#define PWM_SERVO_2_GPIO
Definition: board.h:248
#define PWM_SERVO_5
Definition: board.h:286
#define PWM_SERVO_4_TIMER
Definition: apogee_1.0.h:297
#define PWM_SERVO_0_TIMER
Definition: apogee_1.0.h:237
#define PWM_SERVO_3_TIMER
Definition: apogee_1.0.h:282
#define PWM_SERVO_2_TIMER
Definition: apogee_1.0.h:267
#define PWM_TIM3_CHAN_MASK
Definition: apogee_1.0.h:337
#define PWM_SERVO_2_OC
Definition: apogee_1.0.h:271
#define PWM_SERVO_5_TIMER
Definition: apogee_1.0.h:312
#define PWM_SERVO_1_OC
Definition: apogee_1.0.h:256
#define PWM_SERVO_3_OC
Definition: apogee_1.0.h:286
#define PWM_SERVO_5_OC
Definition: apogee_1.0.h:316
#define PWM_SERVO_4_OC
Definition: apogee_1.0.h:301
#define PWM_TIM2_CHAN_MASK
Definition: apogee_1.0.h:336
#define PWM_SERVO_1_TIMER
Definition: apogee_1.0.h:252
#define PWM_SERVO_0_OC
Definition: apogee_1.0.h:241
#define PWM_TIM1_CHAN_MASK
Definition: cc3d.h:238
#define PWM_TIM4_CHAN_MASK
Definition: cc3d.h:236
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
int32_t actuators_pwm_values[ACTUATORS_PWM_NB]
#define TIM3_SERVO_HZ
#define TIM5_SERVO_HZ
#define TIM4_SERVO_HZ
#define TIM8_SERVO_HZ
#define TIM9_SERVO_HZ
#define TIM12_SERVO_HZ
#define TIM1_SERVO_HZ
#define TIM2_SERVO_HZ
void actuators_pwm_arch_init(void)
Arch dependent init file.
void actuators_pwm_commit(void)
#define ACTUATORS_PWM_NB
#define PWM_SERVO_6
Definition: elle0_common.h:392
#define PWM_SERVO_6_AF
Definition: elle0_common.h:396
#define PWM_SERVO_6_OC
Definition: elle0_common.h:397
#define PWM_TIM5_CHAN_MASK
Definition: elle0_common.h:430
#define PWM_SERVO_6_TIMER
Definition: elle0_common.h:393
#define PWM_SERVO_6_GPIO
Definition: elle0_common.h:394
#define PWM_SERVO_6_PIN
Definition: elle0_common.h:395
#define PWM_SERVO_8_GPIO
Definition: krooz_sd.h:318
#define PWM_SERVO_9_PIN
Definition: krooz_sd.h:331
#define PWM_SERVO_7_PIN
Definition: krooz_sd.h:307
#define PWM_SERVO_7_AF
Definition: krooz_sd.h:308
#define PWM_SERVO_9_GPIO
Definition: krooz_sd.h:330
#define PWM_SERVO_9_AF
Definition: krooz_sd.h:332
#define PWM_SERVO_7
Definition: krooz_sd.h:304
#define PWM_SERVO_8
Definition: krooz_sd.h:316
#define PWM_SERVO_7_GPIO
Definition: krooz_sd.h:306
#define PWM_SERVO_7_TIMER
Definition: krooz_sd.h:305
#define PWM_SERVO_9_TIMER
Definition: krooz_sd.h:329
#define PWM_SERVO_9
Definition: krooz_sd.h:328
#define PWM_SERVO_8_OC
Definition: krooz_sd.h:321
#define PWM_SERVO_9_OC
Definition: krooz_sd.h:333
#define PWM_SERVO_8_TIMER
Definition: krooz_sd.h:317
#define PWM_SERVO_8_AF
Definition: krooz_sd.h:320
#define PWM_SERVO_7_OC
Definition: krooz_sd.h:309
#define PWM_SERVO_8_PIN
Definition: krooz_sd.h:319
#define PWM_SERVO_10_GPIO
#define PWM_SERVO_10_PIN
#define PWM_SERVO_10
#define PWM_SERVO_10_AF
#define PWM_TIM12_CHAN_MASK
#define PWM_TIM8_CHAN_MASK
#define PWM_SERVO_10_TIMER
Definition: opa_ftd_1.0.h:349
#define PWM_SERVO_10_OC
Definition: opa_ftd_1.0.h:353
#define PWM_TIM9_CHAN_MASK
#define TRUE
Definition: std.h:4
int int32_t
Typedef defining 32 bit int type.
Definition: vl53l1_types.h:83