Paparazzi UAS  v5.8.2_stable-0-g6260b7c
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ppm_arch.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010-2014 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, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
30 
31 #include <inttypes.h>
32 
33 #if USE_NPS
34 #include "nps_radio_control.h"
35 #else
36 #include <caml/mlvalues.h>
37 #endif
38 
39 
40 void ppm_arch_init(void)
41 {
42 }
43 
44 #if USE_NPS
45 #ifdef RADIO_CONTROL
46 #define PPM_OF_NPS(_nps, _neutral, _min, _max) \
47  ((_nps) >= 0 ? (_neutral) + (_nps) * ((_max)-(_neutral)) : (_neutral) + (_nps) * ((_neutral)- (_min)))
48 
49 void radio_control_feed(void)
50 {
51  ppm_pulses[RADIO_ROLL] = PPM_OF_NPS(nps_radio_control.roll, \
52  RADIO_ROLL_NEUTRAL, \
53  RADIO_ROLL_MIN, \
54  RADIO_ROLL_MAX);
55  ppm_pulses[RADIO_PITCH] = PPM_OF_NPS(nps_radio_control.pitch, \
56  RADIO_PITCH_NEUTRAL, \
57  RADIO_PITCH_MIN, \
58  RADIO_PITCH_MAX);
59  ppm_pulses[RADIO_YAW] = PPM_OF_NPS(nps_radio_control.yaw, \
60  RADIO_YAW_NEUTRAL, \
61  RADIO_YAW_MIN, \
62  RADIO_YAW_MAX);
63  ppm_pulses[RADIO_THROTTLE] = PPM_OF_NPS(nps_radio_control.throttle, \
64  RADIO_THROTTLE_NEUTRAL, \
65  RADIO_THROTTLE_MIN, \
66  RADIO_THROTTLE_MAX);
67  ppm_pulses[RADIO_MODE] = PPM_OF_NPS(nps_radio_control.mode, \
68  RADIO_MODE_NEUTRAL, \
69  RADIO_MODE_MIN, \
70  RADIO_MODE_MAX);
72 }
73 #else //RADIO_CONTROL
74 void radio_control_feed(void) {}
75 #endif //RADIO_CONTROL
76 
77 #elif !USE_JSBSIM // not NPS and not JSBSIM -> simple ocaml sim
78 #ifdef RADIO_CONTROL
80 {
81  ppm_pulses[Int_val(c)] = Double_val(v);
82  return Val_unit;
83 }
84 
86 {
88  return unit;
89 }
90 #else // RADIO_CONTROL
91 value update_rc_channel(value c __attribute__((unused)), value v __attribute__((unused)))
92 {
93  return Val_unit;
94 }
95 value send_ppm(value unit) {return unit;}
96 #endif // RADIO_CONTROL
97 #endif // USE_NPS
#define RADIO_ROLL
Definition: spektrum_arch.h:43
uint16_t value
Definition: adc_arch.c:586
#define RADIO_YAW
Definition: spektrum_arch.h:45
void ppm_arch_init(void)
Architecture dependant code.
Definition: ppm_arch.c:32
uint16_t ppm_pulses[RADIO_CTL_NB]
Definition: ppm.c:31
value send_ppm(value unit)
Definition: ppm_arch.c:85
#define TRUE
Definition: std.h:4
#define RADIO_PITCH
Definition: spektrum_arch.h:44
volatile bool_t ppm_frame_available
Definition: ppm.c:32
#define RADIO_THROTTLE
Definition: spektrum_arch.h:42
#define RADIO_MODE
Definition: spektrum_arch.h:59
value update_rc_channel(value c, value v)
Definition: ppm_arch.c:79