Paparazzi UAS
v6.1.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
28
#include "
modules/radio_control/radio_control.h
"
29
#include "
modules/radio_control/ppm.h
"
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);
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
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
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
NpsRadioControl::pitch
double pitch
Definition:
nps_radio_control.h:47
send_ppm
value send_ppm(value unit)
Definition:
ppm_arch.c:85
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
update_rc_channel
value update_rc_channel(value c, value v)
Definition:
ppm_arch.c:79
RADIO_YAW
#define RADIO_YAW
Definition:
intermcu_ap.h:43
RADIO_PITCH
#define RADIO_PITCH
Definition:
intermcu_ap.h:42
NpsRadioControl::throttle
double throttle
Definition:
nps_radio_control.h:45
sw
airborne
arch
sim
modules
radio_control
ppm_arch.c
Generated on Tue Feb 1 2022 13:08:43 for Paparazzi UAS by
1.8.17