Paparazzi UAS  v5.0.5_stable-7-g4b8bbb7
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
test_servos.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010 Antoine Drouin <poinix@gmail.com>
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 
22 #include <inttypes.h>
23 
24 #include "mcu.h"
25 #include "mcu_periph/sys_time.h"
27 #include "led.h"
28 
29 static inline void main_init( void );
30 static inline void main_periodic( void );
31 
32 int main(void) {
33 
34  main_init();
35  while (1) {
37  main_periodic();
38  };
39  return 0;
40 }
41 
42 static inline void main_init( void ) {
43  mcu_init();
46 }
47 
48 static inline void main_periodic( void ) {
49  static float foo = 0.;
50  foo += 0.0025;
51  int32_t bar = 1500 + 500. * sin(foo);
52  for (int i = 0; i < ACTUATORS_PWM_NB; i++) {
53  ActuatorPwmSet(i, bar);
54  }
56 
57  LED_PERIODIC();
58 }
59 
60 
61 
#define ActuatorPwmSet(_i, _v)
Actuator set macro.
void mcu_init(void)
Microcontroller peripherals initialization.
Definition: mcu.c:61
#define ActuatorsPwmInit()
Definition: actuators_pwm.h:32
static void main_init(void)
Definition: test_servos.c:42
#define ActuatorsPwmCommit()
Actuator commit macro.
Architecture independent timing functions.
static void main_periodic(void)
Definition: test_servos.c:48
uint16_t foo
Definition: main_demo5.c:54
int sys_time_register_timer(float duration, sys_time_cb cb)
Register a new system timer.
Definition: sys_time.c:37
#define ACTUATORS_PWM_NB
static bool_t sys_time_check_and_ack_timer(tid_t id)
Check if timer has elapsed.
Definition: sys_time.h:111
signed long int32_t
Definition: types.h:19
#define LED_PERIODIC()
Definition: led_hw.h:8
Arch independent mcu ( Micro Controller Unit ) utilities.
int main(void)
Definition: test_servos.c:32
#define PERIODIC_FREQUENCY
Definition: imu_aspirin2.c:54
arch independent LED (Light Emitting Diodes) API