Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
radio_control.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2006-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
27
29#include "led.h"
30
31//PRINT_CONFIG_VAR(RADIO_CONTROL_NB_CHANNEL)
32
34
35#if PERIODIC_TELEMETRY
37
38static void send_rc(struct transport_tx *trans, struct link_device *dev)
39{
40 pprz_msg_send_RC(trans, dev, AC_ID, radio_control.nb_channel, radio_control.values);
41}
42#endif
43
45{
46 uint8_t i;
47 for (i = 0; i < RADIO_CONTROL_NB_CHANNEL; i++) {
48 radio_control.values[i] = 0;
49 }
51 radio_control.time_since_last_frame = RC_REALLY_LOST_TIME;
52 radio_control.radio_ok_cpt = 0;
53 radio_control.frame_rate = 0;
54 radio_control.frame_cpt = 0;
55 radio_control.nb_channel = RADIO_CONTROL_NB_CHANNEL; // can be changed by selected RC module
56
57#if PERIODIC_TELEMETRY
59#endif
60}
61
63{
64 static uint8_t _1Hz;
65 _1Hz++;
66
67 if (_1Hz >= 60) {
68 _1Hz = 0;
69 radio_control.frame_rate = radio_control.frame_cpt;
70 radio_control.frame_cpt = 0;
71 }
72
73 if (radio_control.time_since_last_frame >= RC_REALLY_LOST_TIME) {
75 } else {
76 if (radio_control.time_since_last_frame >= RC_LOST_TIME) {
77 radio_control.status = RC_LOST;
78 radio_control.radio_ok_cpt = RC_OK_CPT;
79 }
80 radio_control.time_since_last_frame++;
81 }
82
83#if defined(RADIO_CONTROL_LED)
84 if (radio_control.status == RC_OK) {
85 LED_ON(RADIO_CONTROL_LED);
86 } else {
87 LED_OFF(RADIO_CONTROL_LED);
88 }
89#endif
90
91}
#define RADIO_CONTROL_NB_CHANNEL
#define LED_ON(i)
Definition led_hw.h:51
#define LED_OFF(i)
Definition led_hw.h:52
static struct uart_periph * dev
arch independent LED (Light Emitting Diodes) API
void radio_control_periodic_task(void)
struct RadioControl radio_control
static void send_rc(struct transport_tx *trans, struct link_device *dev)
void radio_control_init(void)
Generic interface for radio control modules.
#define RC_OK_CPT
#define RC_LOST_TIME
#define RC_REALLY_LOST
#define RC_REALLY_LOST_TIME
#define RC_OK
#define RC_LOST
int16_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint16_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 char uint8_t
Typedef defining 8 bit unsigned char type.