Paparazzi UAS  v6.2_unstable
Paparazzi is a free software Unmanned Aircraft System.
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 
60 struct RadioControl {
68 };
69 
70 extern 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 
82 static 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 
103 extern void radio_control_init(void);
104 extern void radio_control_periodic_task(void);
105 
106 #endif /* RADIO_CONTROL_H */
RadioControl::radio_ok_cpt
uint8_t radio_ok_cpt
Definition: radio_control.h:63
radio_control_get
static pprz_t radio_control_get(uint8_t idx)
Get a radio control channel value.
Definition: radio_control.h:94
uint8_t
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98
radio_control_periodic_task
void radio_control_periodic_task(void)
Definition: radio_control.c:62
RadioControl::time_since_last_frame
uint8_t time_since_last_frame
Definition: radio_control.h:62
RadioControl::nb_channel
uint8_t nb_channel
Definition: radio_control.h:66
paparazzi.h
idx
static uint32_t idx
Definition: nps_radio_control_spektrum.c:105
RadioControl::frame_rate
uint8_t frame_rate
Definition: radio_control.h:64
radio_control
struct RadioControl radio_control
Definition: radio_control.c:33
pprz_t
int16_t pprz_t
Definition: paparazzi.h:6
RadioControl::status
uint8_t status
Definition: radio_control.h:61
RadioControl::frame_cpt
uint8_t frame_cpt
Definition: radio_control.h:65
RadioControl
Definition: radio_control.h:60
radio_control_init
void radio_control_init(void)
Definition: radio_control.c:44
radio_control_set
static void radio_control_set(uint8_t idx, pprz_t value)
Set a radio control channel value.
Definition: radio_control.h:82
RADIO_CONTROL_NB_CHANNEL
#define RADIO_CONTROL_NB_CHANNEL
Definition: radio_control.h:56
RadioControl::values
pprz_t values[RADIO_CONTROL_NB_CHANNEL]
Definition: radio_control.h:67