Paparazzi UAS  v4.2.2_stable-4-gcc32f65
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ppm_arch.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010-2012 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, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 
22 #include "mcu_periph/sys_time.h"
25 
26 #include <inttypes.h>
27 
28 #if USE_NPS
29 #include "nps_radio_control.h"
30 #else
31 #include <caml/mlvalues.h>
32 #endif
33 
37 
38 void ppm_arch_init ( void ) {
43 }
44 
45 #if USE_NPS
46 #ifdef RADIO_CONTROL
47 #define PPM_OF_NPS(_nps, _neutral, _min, _max) \
48  ((_nps) >= 0 ? (_neutral) + (_nps) * ((_max)-(_neutral)) : (_neutral) + (_nps) * ((_neutral)- (_min)))
49 
50 void radio_control_feed(void) {
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 #else
78 #ifdef RADIO_CONTROL
79 value update_rc_channel(value c, value v) {
80  ppm_pulses[Int_val(c)] = Double_val(v);
81  return Val_unit;
82 }
83 
84 value send_ppm(value unit) {
86  return unit;
87 }
88 #else // RADIO_CONTROL
89 value update_rc_channel(value c __attribute__ ((unused)), value v __attribute__ ((unused))) {
90  return Val_unit;
91 }
92 value send_ppm(value unit) {return unit;}
93 #endif // RADIO_CONTROL
94 #endif // USE_NPS
value update_rc_channel(value c __attribute__((unused)), value v __attribute__((unused)))
USE_NPS.
Definition: ppm_arch.c:89
uint32_t ppm_last_pulse_time
Definition: ppm_arch.c:28
bool_t ppm_data_valid
Definition: ppm_arch.c:29
void ppm_arch_init(void)
Architecture dependant code.
Definition: ppm_arch.c:31
value send_ppm(value unit)
Definition: ppm_arch.c:92
#define FALSE
Definition: imu_chimu.h:141
#define RADIO_PITCH
Definition: spektrum_arch.h:42
uint8_t ppm_cur_pulse
State machine for decoding ppm frames.
Definition: ppm_arch.c:27
Architecture independent timing functions.
volatile bool_t ppm_frame_available
Definition: ppm.c:28
unsigned long uint32_t
Definition: types.h:18
#define RADIO_YAW
Definition: spektrum_arch.h:43
uint16_t ppm_pulses[PPM_NB_CHANNEL]
Definition: ppm.c:27
#define TRUE
Definition: imu_chimu.h:144
#define RADIO_MODE
Definition: spektrum_arch.h:63
#define RADIO_THROTTLE
Definition: spektrum_arch.h:40
#define RADIO_CONTROL_NB_CHANNEL
Definition: spektrum_arch.h:36
unsigned char uint8_t
Definition: types.h:14
#define RADIO_ROLL
Definition: spektrum_arch.h:41
static struct point c
Definition: discsurvey.c:13
__attribute__((always_inline))
Definition: i2c_arch.c:35