Paparazzi UAS v7.0_unstable
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) 2013 AggieAir, A Remote Sensing Unmanned Aerial System for Scientific Applications
3 * Utah State University, http://aggieair.usu.edu/
4 *
5 * Michal Podhradsky (michal.podhradsky@aggiemail.usu.edu)
6 * Calvin Coopmans (c.r.coopmans@ieee.org)
7 *
8 *
9 * This file is part of paparazzi.
10 *
11 * paparazzi is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2, or (at your option)
14 * any later version.
15 *
16 * paparazzi is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with paparazzi; see the file COPYING. If not, write to
23 * the Free Software Foundation, 59 Temple Place - Suite 330,
24 * Boston, MA 02111-1307, USA.
25 */
33#include "modules/actuators/actuators_pwm_arch.h"
35#include "mcu_periph/gpio.h"
36
37/* Default timer base frequency is 1MHz */
38#ifndef PWM_FREQUENCY
39#define PWM_FREQUENCY 1000000
40#endif
41
42/* Default servo update rate in Hz */
43#ifndef SERVO_HZ
44#define SERVO_HZ 40
45#endif
46
47/* For each timer the period van be configured differently */
48#ifndef TIM1_SERVO_HZ
49#define TIM1_SERVO_HZ SERVO_HZ
50#endif
51#ifndef TIM2_SERVO_HZ
52#define TIM2_SERVO_HZ SERVO_HZ
53#endif
54#ifndef TIM3_SERVO_HZ
55#define TIM3_SERVO_HZ SERVO_HZ
56#endif
57#ifndef TIM4_SERVO_HZ
58#define TIM4_SERVO_HZ SERVO_HZ
59#endif
60#ifndef TIM5_SERVO_HZ
61#define TIM5_SERVO_HZ SERVO_HZ
62#endif
63#ifndef TIM8_SERVO_HZ
64#define TIM8_SERVO_HZ SERVO_HZ
65#endif
66#ifndef TIM9_SERVO_HZ
67#define TIM9_SERVO_HZ SERVO_HZ
68#endif
69#ifndef TIM12_SERVO_HZ
70#define TIM12_SERVO_HZ SERVO_HZ
71#endif
72
79
80
88#ifndef PWM_CMD_TO_US
89#define PWM_CMD_TO_US(_t) (PWM_FREQUENCY * _t / 1000000)
90#endif
91
93
103 __attribute__((unused)) static void pwmpcb(PWMDriver *pwmp __attribute__((unused))) {}
104
105#if USE_PWM_TIM1
106static PWMConfig pwmcfg1 = {
107 .frequency = PWM_FREQUENCY,
109 .callback = NULL,
110 .channels = {
115 },
116 .cr2 = 0,
117 .bdtr = 0,
118 .dier = 0
119};
120#endif
121#if USE_PWM_TIM2
122static PWMConfig pwmcfg2 = {
123 .frequency = PWM_FREQUENCY,
125 .callback = NULL,
126 .channels = {
131 },
132 .cr2 = 0,
133 .bdtr = 0,
134 .dier = 0
135};
136#endif
137#if USE_PWM_TIM3
138static PWMConfig pwmcfg3 = {
139 .frequency = PWM_FREQUENCY,
141 .callback = NULL,
142 .channels = {
147 },
148 .cr2 = 0,
149 .bdtr = 0,
150 .dier = 0
151};
152#endif
153#if USE_PWM_TIM4
154static PWMConfig pwmcfg4 = {
155 .frequency = PWM_FREQUENCY,
157 .callback = NULL,
158 .channels = {
163 },
164 .cr2 = 0,
165 .bdtr = 0,
166 .dier = 0
167};
168#endif
169#if USE_PWM_TIM5
170static PWMConfig pwmcfg5 = {
171 .frequency = PWM_FREQUENCY,
173 .callback = NULL,
174 .channels = {
179 },
180 .cr2 = 0,
181 .bdtr = 0,
182 .dier = 0
183};
184#endif
185#if USE_PWM_TIM8
186static PWMConfig pwmcfg8 = {
187 .frequency = PWM_FREQUENCY,
189 .callback = NULL,
190 .channels = {
195 },
196 .cr2 = 0,
197 .bdtr = 0,
198 .dier = 0
199};
200#endif
201#if USE_PWM_TIM9
202static PWMConfig pwmcfg9 = {
203 .frequency = PWM_FREQUENCY,
205 .callback = NULL,
206 .channels = {
211 },
212 .cr2 = 0,
213 .bdtr = 0,
214 .dier = 0
215};
216#endif
217#if USE_PWM_TIM10
218static PWMConfig pwmcfg10 = {
219 .frequency = PWM_FREQUENCY,
221 .callback = NULL,
222 .channels = {
227 },
228 .cr2 = 0,
229 .bdtr = 0,
230 .dier = 0
231};
232#endif
233#if USE_PWM_TIM11
234static PWMConfig pwmcfg11 = {
235 .frequency = PWM_FREQUENCY,
237 .callback = NULL,
238 .channels = {
243 },
244 .cr2 = 0,
245 .bdtr = 0,
246 .dier = 0
247};
248#endif
249#if USE_PWM_TIM12
250static PWMConfig pwmcfg12 = {
251 .frequency = PWM_FREQUENCY,
253 .callback = NULL,
254 .channels = {
259 },
260 .cr2 = 0,
261 .bdtr = 0,
262 .dier = 0
263};
264#endif
265
266
268{
269 /*----------------
270 * Configure GPIO
271 *----------------*/
272#ifdef PWM_SERVO_0
275#endif
276#ifdef PWM_SERVO_1
279#endif
280#ifdef PWM_SERVO_2
283#endif
284#ifdef PWM_SERVO_3
287#endif
288#ifdef PWM_SERVO_4
291#endif
292#ifdef PWM_SERVO_5
295#endif
296#ifdef PWM_SERVO_6
299#endif
300#ifdef PWM_SERVO_7
303#endif
304#ifdef PWM_SERVO_8
307#endif
308#ifdef PWM_SERVO_9
311#endif
312#ifdef PWM_SERVO_10
315#endif
316#ifdef PWM_SERVO_11
319#endif
320#ifdef PWM_SERVO_12
323#endif
324#ifdef PWM_SERVO_13
327#endif
328#ifdef PWM_SERVO_14
331#endif
332#ifdef PWM_SERVO_15
335#endif
336#ifdef PWM_SERVO_16
339#endif
340
341 /*---------------
342 * Configure PWM
343 *---------------*/
344#if USE_PWM_TIM1
346#endif
347#if USE_PWM_TIM2
349#endif
350#if USE_PWM_TIM3
352#endif
353#if USE_PWM_TIM4
355#endif
356#if USE_PWM_TIM5
358#endif
359#if USE_PWM_TIM8
361#endif
362#if USE_PWM_TIM9
364#endif
365#if USE_PWM_TIM10
367#endif
368#if USE_PWM_TIM11
370#endif
371#if USE_PWM_TIM12
373#endif
374}
375
376
378{
379#ifdef PWM_SERVO_0
381#endif
382#ifdef PWM_SERVO_1
384#endif
385#ifdef PWM_SERVO_2
387#endif
388#ifdef PWM_SERVO_3
390#endif
391#ifdef PWM_SERVO_4
393#endif
394#ifdef PWM_SERVO_5
396#endif
397#ifdef PWM_SERVO_6
399#endif
400#ifdef PWM_SERVO_7
402#endif
403#ifdef PWM_SERVO_8
405#endif
406#ifdef PWM_SERVO_9
408#endif
409#ifdef PWM_SERVO_10
411#endif
412#ifdef PWM_SERVO_11
414#endif
415#ifdef PWM_SERVO_12
417#endif
418#ifdef PWM_SERVO_13
420#endif
421#ifdef PWM_SERVO_14
423#endif
424#ifdef PWM_SERVO_15
426#endif
427#ifdef PWM_SERVO_16
429#endif
430}
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 PWM_CMD_TO_US(_t)
Print the configuration variables from the header.
static void pwmpcb(PWMDriver *pwmp)
PWM callback function.
#define TIM4_SERVO_HZ
#define SERVO_HZ
#define TIM8_SERVO_HZ
#define TIM9_SERVO_HZ
#define TIM12_SERVO_HZ
#define PWM_FREQUENCY
#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
Some architecture independent helper functions for GPIOs.
uint16_t foo
Definition main_demo5.c:58
#define PWM_SERVO_6
#define PWM_SERVO_3
#define PWM_SERVO_4
#define PWM_SERVO_5
PRINT_CONFIG_VAR(ONELOOP_ANDI_FILT_CUTOFF)
int int32_t
Typedef defining 32 bit int type.