Paparazzi UAS  v5.17_devel-24-g2ae834f
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 {
52  RADIO_ROLL_NEUTRAL, \
53  RADIO_ROLL_MIN, \
54  RADIO_ROLL_MAX);
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);
64  RADIO_THROTTLE_NEUTRAL, \
65  RADIO_THROTTLE_MIN, \
66  RADIO_THROTTLE_MAX);
68  RADIO_MODE_NEUTRAL, \
69  RADIO_MODE_MIN, \
70  RADIO_MODE_MAX);
71  ppm_frame_available = true;
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
79 value update_rc_channel(value c, value v)
80 {
81  ppm_pulses[Int_val(c)] = Double_val(v);
82  return Val_unit;
83 }
84 
85 value send_ppm(value unit)
86 {
87  ppm_frame_available = true;
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: intermcu_ap.h:41
uint16_t ppm_pulses[RADIO_CTL_NB]
Definition: ppm.c:31
value send_ppm(value unit)
Definition: ppm_arch.c:85
struct NpsRadioControl nps_radio_control
#define RADIO_MODE
Definition: intermcu_ap.h:44
void ppm_arch_init(void)
Architecture dependant code.
Definition: ppm_arch.c:89
#define RADIO_THROTTLE
Definition: intermcu_ap.h:40
#define RADIO_PITCH
Definition: intermcu_ap.h:42
#define RADIO_YAW
Definition: intermcu_ap.h:43
value update_rc_channel(value c, value v)
Definition: ppm_arch.c:79
volatile bool ppm_frame_available
Definition: ppm.c:32