Paparazzi UAS  v5.12_stable-4-g9b43e9b
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  * 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 }
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
#define PWM_SERVO_2_AF
Definition: board.h:808
#define PWM_SERVO_4_AF
Definition: board.h:838
#define PWM_SERVO_0
Definition: board.h:775
#define TIM5_SERVO_HZ
#define PWM_SERVO_9
Definition: krooz_sd.h:328
#define PWM_TIM9_CHAN_MASK
#define PWM_SERVO_1_PIN
Definition: board.h:792
#define PWM_SERVO_0_GPIO
Definition: board.h:776
#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_6
Definition: chimera.h:307
void actuators_pwm_arch_init(void)
Arch dependent init file.
#define PWM_SERVO_8_TIMER
Definition: krooz_sd.h:317
#define PWM_SERVO_8_GPIO
Definition: krooz_sd.h:318
#define PWM_SERVO_4_TIMER
Definition: apogee_1.0.h:297
#define PWM_SERVO_1_GPIO
Definition: board.h:791
#define PWM_SERVO_0_OC
Definition: apogee_1.0.h:241
#define PWM_SERVO_2_PIN
Definition: board.h:807
#define PWM_SERVO_5_GPIO
Definition: board.h:851
#define TIM4_SERVO_HZ
#define PWM_SERVO_9_OC
Definition: krooz_sd.h:333
#define TIM3_SERVO_HZ
#define PWM_SERVO_6_OC
Definition: elle0_common.h:421
#define TIM12_SERVO_HZ
#define PWM_SERVO_0_TIMER
Definition: apogee_1.0.h:237
#define PWM_SERVO_8_PIN
Definition: krooz_sd.h:319
#define PWM_SERVO_2_TIMER
Definition: apogee_1.0.h:267
#define PWM_SERVO_3_AF
Definition: board.h:823
#define PWM_SERVO_7_TIMER
Definition: krooz_sd.h:305
#define PWM_SERVO_10
Definition: opa_ftd_1.0.h:348
#define PWM_SERVO_1
Definition: board.h:790
#define PWM_SERVO_1_TIMER
Definition: apogee_1.0.h:252
#define PWM_SERVO_10_PIN
Definition: opa_ftd_1.0.h:351
#define PWM_SERVO_5_TIMER
Definition: apogee_1.0.h:312
#define PWM_SERVO_0_PIN
Definition: board.h:777
#define PWM_SERVO_8_AF
Definition: krooz_sd.h:320
#define PWM_SERVO_10_AF
Definition: opa_ftd_1.0.h:352
#define PWM_SERVO_4_OC
Definition: apogee_1.0.h:301
#define TRUE
Definition: std.h:4
#define PWM_SERVO_2_GPIO
Definition: board.h:806
#define PWM_SERVO_8
Definition: krooz_sd.h:316
#define PWM_SERVO_6_PIN
Definition: chimera.h:309
#define PWM_TIM4_CHAN_MASK
Definition: cc3d.h:236
#define PWM_TIM5_CHAN_MASK
Definition: elle0_common.h:454
#define PWM_SERVO_0_AF
Definition: board.h:778
#define PWM_TIM1_CHAN_MASK
Definition: cc3d.h:238
#define PWM_SERVO_5_AF
Definition: board.h:853
#define PWM_TIM2_CHAN_MASK
Definition: apogee_1.0.h:336
#define PWM_SERVO_3
Definition: board.h:820
#define PWM_SERVO_7_GPIO
Definition: krooz_sd.h:306
#define PWM_TIM12_CHAN_MASK
#define ACTUATORS_PWM_NB
#define PWM_SERVO_7_OC
Definition: krooz_sd.h:309
#define PWM_SERVO_7_PIN
Definition: krooz_sd.h:307
#define PWM_SERVO_9_PIN
Definition: krooz_sd.h:331
#define PWM_SERVO_10_OC
Definition: opa_ftd_1.0.h:353
STM32 PWM and dualPWM servos shared functions.
#define PWM_SERVO_2
Definition: board.h:805
signed long int32_t
Definition: types.h:19
#define PWM_SERVO_3_OC
Definition: apogee_1.0.h:286
#define PWM_SERVO_5
Definition: board.h:850
#define PWM_SERVO_3_PIN
Definition: board.h:822
#define PWM_SERVO_1_AF
Definition: board.h:793
#define PWM_SERVO_4
Definition: board.h:835
#define PWM_SERVO_8_OC
Definition: krooz_sd.h:321
#define PWM_SERVO_6_TIMER
Definition: elle0_common.h:417
#define PWM_SERVO_6_AF
Definition: chimera.h:310
#define PWM_SERVO_9_AF
Definition: krooz_sd.h:332
#define PWM_SERVO_5_PIN
Definition: board.h:852
#define PWM_SERVO_9_GPIO
Definition: krooz_sd.h:330
#define TIM8_SERVO_HZ
void actuators_pwm_commit(void)
#define PWM_SERVO_4_PIN
Definition: board.h:837
#define PWM_SERVO_3_GPIO
Definition: board.h:821
#define PWM_SERVO_10_GPIO
Definition: opa_ftd_1.0.h:350
#define PWM_SERVO_10_TIMER
Definition: opa_ftd_1.0.h:349
#define PWM_SERVO_9_TIMER
Definition: krooz_sd.h:329
#define PWM_SERVO_4_GPIO
Definition: board.h:836
#define PWM_SERVO_7
Definition: krooz_sd.h:304
#define PWM_SERVO_1_OC
Definition: apogee_1.0.h:256
#define TIM9_SERVO_HZ
#define PWM_SERVO_2_OC
Definition: apogee_1.0.h:271
#define TIM2_SERVO_HZ
#define TIM1_SERVO_HZ
#define PWM_TIM3_CHAN_MASK
Definition: apogee_1.0.h:337
#define PWM_SERVO_6_GPIO
Definition: chimera.h:308
#define PWM_SERVO_3_TIMER
Definition: apogee_1.0.h:282
#define PWM_SERVO_5_OC
Definition: apogee_1.0.h:316
int32_t actuators_pwm_values[ACTUATORS_PWM_NB]