Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ppm.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#include "modules/core/abi.h"
31
32#if RADIO_CONTROL_NB_CHANNEL < RADIO_CTL_NB
33#error "RADIO_CONTROL_NB_CHANNEL mustn't be lower than number of channels in radio file."
34#endif
35
37volatile bool ppm_frame_available;
38
39/*
40 * State machine for decoding ppm frames
41 */
44static bool ppm_data_valid;
45
52#ifndef RssiValid
53#define RssiValid() TRUE
54#endif
55
56
57#if PERIODIC_TELEMETRY
59
60static void send_ppm(struct transport_tx *trans, struct link_device *dev)
61{
63 for (int i = 0; i < RADIO_CTL_NB; i++) {
65 }
68}
69#endif
70
85
101
112
121{
125 if (ppm_data_valid && RssiValid()) {
126 ppm_frame_available = true;
127 ppm_data_valid = false;
128 }
129 ppm_cur_pulse = 0;
130 } else {
131 ppm_data_valid = false;
132 }
133 } else {
139 ppm_data_valid = true;
140 }
141 } else {
143 ppm_data_valid = false;
144 }
145 }
146}
Main include for ABI (AirBorneInterface).
#define RADIO_CONTROL_PPM_ID
void ppm_arch_init(void)
Architecture dependant code.
Definition ppm_arch.c:90
#define USEC_OF_RC_PPM_TICKS(_v)
Definition ppm_arch.h:46
#define RC_PPM_TICKS_OF_USEC(_v)
Definition ppm_arch.h:44
uint16_t foo
Definition main_demo5.c:58
static uint32_t ppm_last_pulse_time
Definition ppm.c:43
static bool ppm_data_valid
Definition ppm.c:44
static void send_ppm(struct transport_tx *trans, struct link_device *dev)
Definition ppm.c:60
void ppm_decode_frame_width(uint32_t ppm_width)
Decode a PPM frame from last width.
Definition ppm.c:120
void ppm_init(void)
RC init function.
Definition ppm.c:71
uint16_t ppm_pulses[RADIO_CTL_NB]
Definition ppm.c:36
void ppm_decode_frame(uint32_t ppm_time)
Decode a PPM frame from global timer value.
Definition ppm.c:105
void ppm_event(void)
RC event function.
Definition ppm.c:86
volatile bool ppm_frame_available
Definition ppm.c:37
static uint8_t ppm_cur_pulse
Definition ppm.c:42
#define RssiValid()
RssiValid test macro.
Definition ppm.c:53
struct RadioControl radio_control
Generic interface for radio control modules.
uint8_t time_since_last_frame
uint8_t radio_ok_cpt
uint8_t frame_rate
uint8_t frame_cpt
#define RC_OK
uint8_t nb_channel
static const struct usb_device_descriptor dev
Definition usb_ser_hw.c:74
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
Definition telemetry.c:51
Periodic telemetry system header (includes downlink utility and generated code).
#define DefaultPeriodic
Set default periodic telemetry.
Definition telemetry.h:66
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.