NinjaFlight
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
rx.h
Go to the documentation of this file.
1 /*
2  * This file is part of Ninjaflight.
3  *
4  * Copyright: collective.
5  * Cleanup: Martin Schröder <mkschreder.uk@gmail.com>
6  * Original source from Cleanflight.
7  *
8  * Ninjaflight is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * Ninjaflight is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with Ninjaflight. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #pragma once
23 
25 #define RX_MAX_MAPPABLE_RX_INPUTS 8
26 #define RX_MAX_SUPPORTED_RC_CHANNELS (18)
28 #define RX_NON_AUX_CHANNEL_COUNT 4
30 
31 #define RSSI_SCALE_MIN 1
32 #define RSSI_SCALE_MAX 255
33 #define RSSI_SCALE_DEFAULT 30
34 
35 #define PWM_RANGE_ZERO 0 // FIXME should all usages of this be changed to use PWM_RANGE_MIN?
36 #define PWM_RANGE_MIN 1000
37 #define PWM_RANGE_MAX 2000
38 #define PWM_RANGE_MIDDLE (PWM_RANGE_MIN + ((PWM_RANGE_MAX - PWM_RANGE_MIN) / 2))
39 
40 #define PWM_PULSE_MIN 750 // minimum PWM pulse width which is considered valid
41 #define PWM_PULSE_MAX 2250 // maximum PWM pulse width which is considered valid
42 
43 #define RXFAIL_STEP_TO_CHANNEL_VALUE(step) (PWM_PULSE_MIN + 25 * step)
44 #define CHANNEL_VALUE_TO_RXFAIL_STEP(channelValue) ((constrain(channelValue, PWM_PULSE_MIN, PWM_PULSE_MAX) - PWM_PULSE_MIN) / 25)
45 #define MAX_RXFAIL_RANGE_STEP ((PWM_PULSE_MAX - PWM_PULSE_MIN) / 25)
46 
47 typedef enum {
53 
54 typedef enum rc_alias {
55  ROLL = 0,
57  YAW,
67 } rc_alias_e;
68 
70  uint8_t mode; // See rxFailsafeChannelMode_e
71  uint8_t step;
72 } __attribute__((packed)) ;
73 
75  uint16_t min;
76  uint16_t max;
77 } __attribute__((packed)) ;
78 
82 } __attribute__((packed)) ;
83 
84 struct rx_config {
87  uint8_t sbus_inversion;
89  uint8_t rssi_channel;
90  uint8_t rssi_scale;
91  uint8_t rssi_ppm_invert;
92  uint8_t rcSmoothing;
93  uint16_t midrc;
94  uint16_t mincheck;
95  uint16_t maxcheck;
96 
97  uint16_t rx_min_usec;
98  uint16_t rx_max_usec;
99 } __attribute__((packed)) ;
100 
102 void rx_config_set_mapping(struct rx_config *self, const char *input);
103 char rx_config_channel_letter(uint8_t ch);
104 
105 
Definition: rx.h:79
Definition: rx.h:65
Definition: rx.h:56
uint16_t maxcheck
maximum rc end
Definition: rx.h:95
uint8_t rcmap[RX_MAX_MAPPABLE_RX_INPUTS]
mapping of radio channels to internal RPYTA+ order
Definition: rx.h:85
uint8_t rcSmoothing
Enable/Disable RC filtering.
Definition: rx.h:92
uint8_t spektrum_sat_bind
number of bind pulses for Spektrum satellite receivers
Definition: rx.h:88
Definition: rx.h:58
Definition: rx.h:69
void rx_config_set_mapping(struct rx_config *self, const char *input)
Configures the rx using the specified channel layout and config. (channel layout example: AETR1234) ...
Definition: rx.c:14
uint16_t max
Definition: rx.h:76
Definition: failsafe.h:46
Definition: rx.h:51
Definition: rx.h:49
Definition: rx.h:66
uint8_t rssi_ppm_invert
if set then rssi signal is treated such that high value means low rssi
Definition: rx.h:91
Definition: rx.h:59
uint8_t rssi_scale
scale of the rssi signal. Range [RSSI_SCALE_MIN;RSSI_SCALE_MAX]
Definition: rx.h:90
uint16_t midrc
Some radios have not a neutral point centered on 1500. can be changed here.
Definition: rx.h:93
uint16_t rx_min_usec
minimum value of rx pulse from receiver (below this point we consider signal being corrupt) ...
Definition: rx.h:97
uint8_t input
Definition: mixer.h:13
#define RX_NON_AUX_CHANNEL_COUNT
number of channels that are treated as "essential" for basic control
Definition: rx.h:29
#define RX_MAX_MAPPABLE_RX_INPUTS
maximum number of inputs that we can remap
Definition: rx.h:25
uint16_t rx_max_usec
maximum value of rx pulse from receiver (above this point the signal is invalid and will trigger fail...
Definition: rx.h:98
enum rc_alias rc_alias_e
Definition: rx.h:57
Definition: rx.h:74
Definition: rx.h:60
struct rx_failsafe_chan_config __attribute__((packed))
uint8_t step
Definition: rx.h:71
rc_alias
Definition: rx.h:54
Definition: rx.h:50
uint8_t mode
Definition: rx.h:70
uint16_t min
Definition: rx.h:75
uint8_t rssi_channel
rssi channel number
Definition: rx.h:89
Definition: rx.h:63
Definition: rx.h:64
uint16_t mincheck
minimum rc end
Definition: rx.h:94
#define RX_MAX_SUPPORTED_RC_CHANNELS
maximum supported channels when calling rx_get_channel
Definition: rx.h:27
struct rx_channel_range_config range[RX_NON_AUX_CHANNEL_COUNT]
Definition: rx.h:80
Definition: rx.h:84
Definition: rx.h:48
char rx_config_channel_letter(uint8_t ch)
Definition: rx.c:9
Definition: rx.h:55
uint8_t sbus_inversion
default sbus (Futaba, FrSKY) is inverted. Support for uninverted OpenLRS (and modified FrSKY) receive...
Definition: rx.h:87
rxFailsafeChannelMode_e
Definition: rx.h:47
uint8_t serialrx_provider
type of UART-based receiver (0 = spek 10, 1 = spek 11, 2 = sbus). Must be enabled by FEATURE_RX_SERIA...
Definition: rx.h:86
Definition: rx.h:62
Definition: rx.h:61