Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
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
c
VIC slots used for the LPC2148 define name e g gps UART1_VIC_SLOT e g modem SPI1_VIC_SLOT SPI1 in mcu_periph spi_arch c or spi_slave_hs_arch c(and some others not using the SPI peripheral yet..) I2C0_VIC_SLOT 8 mcu_periph/i2c_arch.c I2C1_VIC_SLOT 9 mcu_periph/i2c_arch.c USB_VIC_SLOT 10 usb
radio_control.h
RADIO_ROLL
#define RADIO_ROLL
Definition: intermcu_ap.h:41
ppm_pulses
uint16_t ppm_pulses[RADIO_CTL_NB]
Definition: ppm.c:31
NpsRadioControl::roll
double roll
Definition: nps_radio_control.h:46
RADIO_MODE
#define RADIO_MODE
Definition: intermcu_ap.h:44
ppm_frame_available
volatile bool ppm_frame_available
Definition: ppm.c:32
NpsRadioControl::yaw
double yaw
Definition: nps_radio_control.h:48
update_rc_channel
value update_rc_channel(value c, value v)
Definition: ppm_arch.c:79
NpsRadioControl::mode
double mode
Definition: nps_radio_control.h:49
nps_radio_control
struct NpsRadioControl nps_radio_control
Definition: nps_radio_control.c:31
nps_radio_control.h
send_ppm
value send_ppm(value unit)
Definition: ppm_arch.c:85
NpsRadioControl::pitch
double pitch
Definition: nps_radio_control.h:47
ppm.h
RADIO_THROTTLE
#define RADIO_THROTTLE
Definition: intermcu_ap.h:40
ppm_arch_init
void ppm_arch_init(void)
Architecture dependant code.
Definition: ppm_arch.c:90
unit
static unit_t unit
Definition: nav.c:31
RADIO_YAW
#define RADIO_YAW
Definition: intermcu_ap.h:43
RADIO_PITCH
#define RADIO_PITCH
Definition: intermcu_ap.h:42
inttypes.h
NpsRadioControl::throttle
double throttle
Definition: nps_radio_control.h:45