Paparazzi UAS  v5.18.0_stable
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 "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
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 {
152 #ifdef PWM_SERVO_0
154 #endif
155 #ifdef PWM_SERVO_1
157 #endif
158 #ifdef PWM_SERVO_2
160 #endif
161 #ifdef PWM_SERVO_3
163 #endif
164 #ifdef PWM_SERVO_4
166 #endif
167 #ifdef PWM_SERVO_5
169 #endif
170 #ifdef PWM_SERVO_6
172 #endif
173 #ifdef PWM_SERVO_7
175 #endif
176 #ifdef PWM_SERVO_8
178 #endif
179 #ifdef PWM_SERVO_9
181 #endif
182 #ifdef PWM_SERVO_10
184 #endif
185 #ifdef PWM_SERVO_11
186  timer_set_oc_value(PWM_SERVO_11_TIMER, PWM_SERVO_11_OC, actuators_pwm_values[PWM_SERVO_11]);
187 #endif
188 
189 }
actuators_pwm.h
PWM_TIM1_CHAN_MASK
#define PWM_TIM1_CHAN_MASK
Definition: cc3d.h:238
PWM_SERVO_8
#define PWM_SERVO_8
Definition: krooz_sd.h:316
PWM_TIM12_CHAN_MASK
#define PWM_TIM12_CHAN_MASK
Definition: matek_f405_wing_v1.h:428
PWM_SERVO_5_PIN
#define PWM_SERVO_5_PIN
Definition: board.h:289
TIM5_SERVO_HZ
#define TIM5_SERVO_HZ
Definition: actuators_pwm_arch.h:69
PWM_TIM4_CHAN_MASK
#define PWM_TIM4_CHAN_MASK
Definition: cc3d.h:236
PWM_SERVO_3_GPIO
#define PWM_SERVO_3_GPIO
Definition: board.h:258
TIM2_SERVO_HZ
#define TIM2_SERVO_HZ
Definition: actuators_pwm_arch.h:60
PWM_SERVO_6_OC
#define PWM_SERVO_6_OC
Definition: elle0_common.h:397
PWM_SERVO_0
#define PWM_SERVO_0
Definition: board.h:212
PWM_SERVO_9_AF
#define PWM_SERVO_9_AF
Definition: krooz_sd.h:332
actuators_shared_arch.h
PWM_SERVO_3_OC
#define PWM_SERVO_3_OC
Definition: apogee_1.0.h:286
PWM_SERVO_10
#define PWM_SERVO_10
Definition: matekF765-WING.h:247
PWM_SERVO_8_TIMER
#define PWM_SERVO_8_TIMER
Definition: krooz_sd.h:317
PWM_TIM9_CHAN_MASK
#define PWM_TIM9_CHAN_MASK
Definition: openpilot_revo_1.0.h:367
TIM12_SERVO_HZ
#define TIM12_SERVO_HZ
Definition: actuators_pwm_arch.h:78
TIM3_SERVO_HZ
#define TIM3_SERVO_HZ
Definition: actuators_pwm_arch.h:63
PWM_SERVO_1_GPIO
#define PWM_SERVO_1_GPIO
Definition: board.h:228
PWM_SERVO_8_GPIO
#define PWM_SERVO_8_GPIO
Definition: krooz_sd.h:318
PWM_SERVO_9
#define PWM_SERVO_9
Definition: krooz_sd.h:328
PWM_SERVO_2_GPIO
#define PWM_SERVO_2_GPIO
Definition: board.h:243
PWM_SERVO_2
#define PWM_SERVO_2
Definition: board.h:242
PWM_SERVO_2_AF
#define PWM_SERVO_2_AF
Definition: board.h:245
PWM_SERVO_7_AF
#define PWM_SERVO_7_AF
Definition: krooz_sd.h:308
PWM_SERVO_8_OC
#define PWM_SERVO_8_OC
Definition: krooz_sd.h:321
PWM_SERVO_7_OC
#define PWM_SERVO_7_OC
Definition: krooz_sd.h:309
PWM_SERVO_5_GPIO
#define PWM_SERVO_5_GPIO
Definition: board.h:288
PWM_SERVO_1_OC
#define PWM_SERVO_1_OC
Definition: apogee_1.0.h:256
PWM_SERVO_0_AF
#define PWM_SERVO_0_AF
Definition: board.h:215
PWM_SERVO_7_PIN
#define PWM_SERVO_7_PIN
Definition: krooz_sd.h:307
PWM_SERVO_0_GPIO
#define PWM_SERVO_0_GPIO
Definition: board.h:213
actuators_pwm_commit
void actuators_pwm_commit(void)
Definition: actuators_pwm_arch.c:188
PWM_SERVO_6_PIN
#define PWM_SERVO_6_PIN
Definition: chimera.h:309
PWM_SERVO_5_OC
#define PWM_SERVO_5_OC
Definition: apogee_1.0.h:316
set_servo_timer
void set_servo_timer(uint32_t timer, uint32_t freq, uint8_t channels_mask)
Set Timer configuration.
Definition: actuators_shared_arch.c:59
PWM_SERVO_1
#define PWM_SERVO_1
Definition: board.h:227
PWM_SERVO_4_PIN
#define PWM_SERVO_4_PIN
Definition: board.h:274
PWM_TIM3_CHAN_MASK
#define PWM_TIM3_CHAN_MASK
Definition: apogee_1.0.h:337
PWM_SERVO_8_PIN
#define PWM_SERVO_8_PIN
Definition: krooz_sd.h:319
PWM_SERVO_0_PIN
#define PWM_SERVO_0_PIN
Definition: board.h:214
PWM_SERVO_10_OC
#define PWM_SERVO_10_OC
Definition: opa_ftd_1.0.h:353
PWM_SERVO_3_TIMER
#define PWM_SERVO_3_TIMER
Definition: apogee_1.0.h:282
PWM_SERVO_3_PIN
#define PWM_SERVO_3_PIN
Definition: board.h:259
PWM_SERVO_7_TIMER
#define PWM_SERVO_7_TIMER
Definition: krooz_sd.h:305
PWM_SERVO_1_AF
#define PWM_SERVO_1_AF
Definition: board.h:230
PWM_SERVO_2_OC
#define PWM_SERVO_2_OC
Definition: apogee_1.0.h:271
PWM_SERVO_6_TIMER
#define PWM_SERVO_6_TIMER
Definition: elle0_common.h:393
PWM_SERVO_9_OC
#define PWM_SERVO_9_OC
Definition: krooz_sd.h:333
PWM_SERVO_10_TIMER
#define PWM_SERVO_10_TIMER
Definition: opa_ftd_1.0.h:349
PWM_SERVO_3_AF
#define PWM_SERVO_3_AF
Definition: board.h:260
TIM1_SERVO_HZ
#define TIM1_SERVO_HZ
Definition: actuators_pwm_arch.h:57
ACTUATORS_PWM_NB
#define ACTUATORS_PWM_NB
Definition: actuators_pwm_arch.h:42
PWM_SERVO_0_OC
#define PWM_SERVO_0_OC
Definition: apogee_1.0.h:241
gpio_setup_pin_af
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:61
PWM_SERVO_7
#define PWM_SERVO_7
Definition: krooz_sd.h:304
PWM_SERVO_9_TIMER
#define PWM_SERVO_9_TIMER
Definition: krooz_sd.h:329
TIM9_SERVO_HZ
#define TIM9_SERVO_HZ
Definition: actuators_pwm_arch.h:75
PWM_SERVO_6_AF
#define PWM_SERVO_6_AF
Definition: chimera.h:310
PWM_SERVO_10_GPIO
#define PWM_SERVO_10_GPIO
Definition: matekF765-WING.h:248
PWM_SERVO_4_AF
#define PWM_SERVO_4_AF
Definition: board.h:275
PWM_SERVO_4_TIMER
#define PWM_SERVO_4_TIMER
Definition: apogee_1.0.h:297
PWM_SERVO_4_GPIO
#define PWM_SERVO_4_GPIO
Definition: board.h:273
int32_t
signed long int32_t
Definition: types.h:19
PWM_SERVO_9_PIN
#define PWM_SERVO_9_PIN
Definition: krooz_sd.h:331
PWM_SERVO_5
#define PWM_SERVO_5
Definition: board.h:287
PWM_SERVO_4_OC
#define PWM_SERVO_4_OC
Definition: apogee_1.0.h:301
PWM_SERVO_1_PIN
#define PWM_SERVO_1_PIN
Definition: board.h:229
PWM_SERVO_8_AF
#define PWM_SERVO_8_AF
Definition: krooz_sd.h:320
PWM_SERVO_10_AF
#define PWM_SERVO_10_AF
Definition: matekF765-WING.h:250
PWM_TIM5_CHAN_MASK
#define PWM_TIM5_CHAN_MASK
Definition: elle0_common.h:430
PWM_SERVO_5_AF
#define PWM_SERVO_5_AF
Definition: board.h:290
PWM_SERVO_10_PIN
#define PWM_SERVO_10_PIN
Definition: matekF765-WING.h:249
PWM_SERVO_3
#define PWM_SERVO_3
Definition: board.h:257
TIM8_SERVO_HZ
#define TIM8_SERVO_HZ
Definition: actuators_pwm_arch.h:72
PWM_SERVO_2_TIMER
#define PWM_SERVO_2_TIMER
Definition: apogee_1.0.h:267
PWM_SERVO_2_PIN
#define PWM_SERVO_2_PIN
Definition: board.h:244
PWM_SERVO_6_GPIO
#define PWM_SERVO_6_GPIO
Definition: chimera.h:308
actuators_pwm_arch_init
void actuators_pwm_arch_init(void)
Arch dependent init file.
Definition: actuators_pwm_arch.c:95
PWM_TIM2_CHAN_MASK
#define PWM_TIM2_CHAN_MASK
Definition: apogee_1.0.h:336
TRUE
#define TRUE
Definition: std.h:4
PWM_SERVO_1_TIMER
#define PWM_SERVO_1_TIMER
Definition: apogee_1.0.h:252
PWM_SERVO_7_GPIO
#define PWM_SERVO_7_GPIO
Definition: krooz_sd.h:306
PWM_SERVO_0_TIMER
#define PWM_SERVO_0_TIMER
Definition: apogee_1.0.h:237
PWM_TIM8_CHAN_MASK
#define PWM_TIM8_CHAN_MASK
Definition: matek_f405_wing_v1.h:426
PWM_SERVO_6
#define PWM_SERVO_6
Definition: chimera.h:307
PWM_SERVO_5_TIMER
#define PWM_SERVO_5_TIMER
Definition: apogee_1.0.h:312
TIM4_SERVO_HZ
#define TIM4_SERVO_HZ
Definition: actuators_pwm_arch.h:66
actuators_pwm_values
int32_t actuators_pwm_values[ACTUATORS_PWM_NB]
Definition: actuators_pwm_arch.c:50
PWM_SERVO_9_GPIO
#define PWM_SERVO_9_GPIO
Definition: krooz_sd.h:330
PWM_SERVO_4
#define PWM_SERVO_4
Definition: board.h:272