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
radio_control.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2006 Pascal Brisset, Antoine Drouin
3 * 2021 Gautier Hattenberger <gautier.hattenberger@enac.fr>
4 *
5 * This file is part of paparazzi.
6 *
7 * paparazzi is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * paparazzi is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with paparazzi; see the file COPYING. If not, see
19 * <http://www.gnu.org/licenses/>.
20 *
21 */
22
28#ifndef RADIO_CONTROL_H
29#define RADIO_CONTROL_H
30
31#include "generated/airframe.h"
32#include "paparazzi.h"
33
34/* timeouts - for now assumes 60Hz periodic */
35#ifndef RC_AVG_PERIOD
36#define RC_AVG_PERIOD 8 /* TODO remove if IIR filter is used */
37#endif
38#ifndef RC_LOST_TIME
39#define RC_LOST_TIME 30 /* 500ms with a 60Hz timer */
40#endif
41#ifndef RC_REALLY_LOST_TIME
42#define RC_REALLY_LOST_TIME 60 /* ~1s */
43#endif
44/* Number of valid frames before going back to RC OK */
45#ifndef RC_OK_CPT
46#define RC_OK_CPT 15
47#endif
48
49#define RC_OK 0
50#define RC_LOST 1
51#define RC_REALLY_LOST 2
52
53// if not redefined, use default number of channels
54// value should be large enough for all implementation by default
55#ifndef RADIO_CONTROL_NB_CHANNEL
56#define RADIO_CONTROL_NB_CHANNEL 32
57#endif
58
59
69
70extern struct RadioControl radio_control;
71
72// For easy access in command_laws
73#define RadioControlValues(_chan) radio_control.values[_chan]
74
75// Test is radio is reall lost
76#define RadioControlIsLost() (radio_control.status == RC_REALLY_LOST)
77
82static inline void radio_control_set(uint8_t idx, pprz_t value)
83{
85 // Bound value ???
86 radio_control.values[idx] = value;
87 }
88}
89
95{
97 return radio_control.values[idx];
98 }
99 return 0;
100}
101
102
103extern void radio_control_init(void);
104extern void radio_control_periodic_task(void);
105
106#endif /* RADIO_CONTROL_H */
static uint32_t idx
int16_t pprz_t
Definition paparazzi.h:6
uint8_t time_since_last_frame
#define RADIO_CONTROL_NB_CHANNEL
void radio_control_periodic_task(void)
pprz_t values[RADIO_CONTROL_NB_CHANNEL]
uint8_t radio_ok_cpt
struct RadioControl radio_control
static pprz_t radio_control_get(uint8_t idx)
Get a radio control channel value.
static void radio_control_set(uint8_t idx, pprz_t value)
Set a radio control channel value.
uint8_t frame_rate
uint8_t frame_cpt
uint8_t nb_channel
void radio_control_init(void)
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.