Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
cc2500_rx.h
Go to the documentation of this file.
1 #include "cc2500_compat.h"
2 
3 // CAUTION: LARGE PARTS OF THIS FILE ARE COMMENTED OUT!
4 // betaflight/src/main/rx/rx.h @ 4e8249e
5 /*
6  * This file is part of Cleanflight and Betaflight.
7  *
8  * Cleanflight and Betaflight are free software. You can redistribute
9  * this software and/or modify this software under the terms of the
10  * GNU General Public License as published by the Free Software
11  * Foundation, either version 3 of the License, or (at your option)
12  * any later version.
13  *
14  * Cleanflight and Betaflight are distributed in the hope that they
15  * will be useful, but WITHOUT ANY WARRANTY; without even the implied
16  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17  * See the GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this software.
21  *
22  * If not, see <http://www.gnu.org/licenses/>.
23  */
24 
25 #pragma once
26 
27 //#include "common/time.h"
28 //
29 //#include "pg/pg.h"
30 //#include "pg/rx.h"
31 //
32 //#include "drivers/io_types.h"
33 //
34 //#define STICK_CHANNEL_COUNT 4
35 //
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 //#define DEFAULT_SERVO_MIN 1000
48 //#define DEFAULT_SERVO_MIDDLE 1500
49 //#define DEFAULT_SERVO_MAX 2000
50 
51 typedef enum {
53  RX_FRAME_COMPLETE = (1 << 0),
54  RX_FRAME_FAILSAFE = (1 << 1),
56  RX_FRAME_DROPPED = (1 << 3)
58 
59 typedef enum {
74 } SerialRXType;
75 
76 //#define MAX_SUPPORTED_RC_PPM_CHANNEL_COUNT 12
77 //#define MAX_SUPPORTED_RC_PARALLEL_PWM_CHANNEL_COUNT 8
78 #define MAX_SUPPORTED_RC_CHANNEL_COUNT 18
79 
80 #define NON_AUX_CHANNEL_COUNT 4
81 #define MAX_AUX_CHANNEL_COUNT (MAX_SUPPORTED_RC_CHANNEL_COUNT - NON_AUX_CHANNEL_COUNT)
82 
83 //#if MAX_SUPPORTED_RC_PARALLEL_PWM_CHANNEL_COUNT > MAX_SUPPORTED_RC_PPM_CHANNEL_COUNT
84 //#define MAX_SUPPORTED_RX_PARALLEL_PWM_OR_PPM_CHANNEL_COUNT MAX_SUPPORTED_RC_PARALLEL_PWM_CHANNEL_COUNT
85 //#else
86 //#define MAX_SUPPORTED_RX_PARALLEL_PWM_OR_PPM_CHANNEL_COUNT MAX_SUPPORTED_RC_PPM_CHANNEL_COUNT
87 //#endif
88 //
89 //extern const char rcChannelLetters[];
90 //
91 //extern int16_t rcData[MAX_SUPPORTED_RC_CHANNEL_COUNT]; // interval [1000;2000]
92 //
93 //#define RSSI_SCALE_MIN 1
94 //#define RSSI_SCALE_MAX 255
95 //
96 //#define RSSI_SCALE_DEFAULT 100
97 //
98 //typedef enum {
99 // RX_FAILSAFE_MODE_AUTO = 0,
100 // RX_FAILSAFE_MODE_HOLD,
101 // RX_FAILSAFE_MODE_SET,
102 // RX_FAILSAFE_MODE_INVALID
103 //} rxFailsafeChannelMode_e;
104 //
105 //#define RX_FAILSAFE_MODE_COUNT 3
106 //
107 //typedef enum {
108 // RX_FAILSAFE_TYPE_FLIGHT = 0,
109 // RX_FAILSAFE_TYPE_AUX
110 //} rxFailsafeChannelType_e;
111 //
112 //#define RX_FAILSAFE_TYPE_COUNT 2
113 //
114 //typedef struct rxFailsafeChannelConfig_s {
115 // uint8_t mode; // See rxFailsafeChannelMode_e
116 // uint8_t step;
117 //} rxFailsafeChannelConfig_t;
118 //
119 //PG_DECLARE_ARRAY(rxFailsafeChannelConfig_t, MAX_SUPPORTED_RC_CHANNEL_COUNT, rxFailsafeChannelConfigs);
120 //
121 //typedef struct rxChannelRangeConfig_s {
122 // uint16_t min;
123 // uint16_t max;
124 //} rxChannelRangeConfig_t;
125 //
126 //PG_DECLARE_ARRAY(rxChannelRangeConfig_t, NON_AUX_CHANNEL_COUNT, rxChannelRangeConfigs);
127 
128 struct rxRuntimeConfig_s;
129 typedef uint16_t (*rcReadRawDataFnPtr)(const struct rxRuntimeConfig_s *rxRuntimeConfig, uint8_t chan); // used by receiver driver to return channel data
132 
133 typedef enum {
140 } rxProvider_t;
141 
142 typedef struct rxRuntimeConfig_s {
145  uint8_t channelCount; // number of RC channels as reported by current input driver
151  void *frameData;
153 
154 typedef enum {
162 } rssiSource_e;
163 
164 extern rssiSource_e rssiSource;
165 
166 //typedef enum {
167 // LQ_SOURCE_NONE = 0,
168 // LQ_SOURCE_RX_PROTOCOL_CRSF,
169 //} linkQualitySource_e;
170 //
171 //extern linkQualitySource_e linkQualitySource;
172 
174 
175 void rxInit(void);
176 //bool rxUpdateCheck(timeUs_t currentTimeUs, timeDelta_t currentDeltaTimeUs);
177 //bool rxIsReceivingSignal(void);
178 //bool rxAreFlightChannelsValid(void);
179 //bool calculateRxChannelsAndUpdateFailsafe(timeUs_t currentTimeUs);
180 //
181 //struct rxConfig_s;
182 //
183 //void parseRcChannels(const char *input, struct rxConfig_s *rxConfig);
184 //
185 //#define RSSI_MAX_VALUE 1023
186 
187 void setRssiDirect(uint16_t newRssi, rssiSource_e source);
188 void setRssi(uint16_t rssiValue, rssiSource_e source);
189 //void setRssiMsp(uint8_t newMspRssi);
190 //void updateRSSI(timeUs_t currentTimeUs);
191 //uint16_t getRssi(void);
192 //uint8_t getRssiPercent(void);
193 //bool isRssiConfigured(void);
194 //
195 //#define LINK_QUALITY_MAX_VALUE 1023
196 //
197 //uint16_t rxGetLinkQuality(void);
198 //void setLinkQualityDirect(uint16_t linkqualityValue);
199 //uint16_t rxGetLinkQualityPercent(void);
200 //
201 //uint8_t getRssiDbm(void);
202 //void setRssiDbm(uint8_t newRssiDbm, rssiSource_e source);
203 //void setRssiDbmDirect(uint8_t newRssiDbm, rssiSource_e source);
204 //
205 //void resetAllRxChannelRangeConfigurations(rxChannelRangeConfig_t *rxChannelRangeConfig);
206 //
207 //void suspendRxPwmPpmSignal(void);
208 //void resumeRxPwmPpmSignal(void);
209 //
210 //uint16_t rxGetRefreshRate(void);
211 
struct rxRuntimeConfig_s rxRuntimeConfig_t
void setRssi(uint16_t rssiValue, rssiSource_e source)
Definition: cc2500_rx.c:723
void rxInit(void)
!TODO remove this extern, only needed once for channelCount
Definition: cc2500_rx.c:263
rxProvider_t rxProvider
Definition: cc2500_rx.h:143
rxFrameState_e
Definition: cc2500_rx.h:51
@ RX_FRAME_FAILSAFE
Definition: cc2500_rx.h:54
@ RX_FRAME_PENDING
Definition: cc2500_rx.h:52
@ RX_FRAME_COMPLETE
Definition: cc2500_rx.h:53
@ RX_FRAME_DROPPED
Definition: cc2500_rx.h:56
@ RX_FRAME_PROCESSING_REQUIRED
Definition: cc2500_rx.h:55
rssiSource_e
Definition: cc2500_rx.h:154
@ RSSI_SOURCE_MSP
Definition: cc2500_rx.h:159
@ RSSI_SOURCE_ADC
Definition: cc2500_rx.h:156
@ RSSI_SOURCE_RX_CHANNEL
Definition: cc2500_rx.h:157
@ RSSI_SOURCE_RX_PROTOCOL
Definition: cc2500_rx.h:158
@ RSSI_SOURCE_FRAME_ERRORS
Definition: cc2500_rx.h:160
@ RSSI_SOURCE_RX_PROTOCOL_CRSF
Definition: cc2500_rx.h:161
@ RSSI_SOURCE_NONE
Definition: cc2500_rx.h:155
uint8_t(* rcFrameStatusFnPtr)(struct rxRuntimeConfig_s *rxRuntimeConfig)
Definition: cc2500_rx.h:130
rcFrameStatusFnPtr rcFrameStatusFn
Definition: cc2500_rx.h:148
uint16_t(* rcReadRawDataFnPtr)(const struct rxRuntimeConfig_s *rxRuntimeConfig, uint8_t chan)
Definition: cc2500_rx.h:129
uint8_t channelCount
Definition: cc2500_rx.h:145
rxProvider_t
Definition: cc2500_rx.h:133
@ RX_PROVIDER_PARALLEL_PWM
Definition: cc2500_rx.h:135
@ RX_PROVIDER_PPM
Definition: cc2500_rx.h:136
@ RX_PROVIDER_SERIAL
Definition: cc2500_rx.h:137
@ RX_PROVIDER_MSP
Definition: cc2500_rx.h:138
@ RX_PROVIDER_SPI
Definition: cc2500_rx.h:139
@ RX_PROVIDER_NONE
Definition: cc2500_rx.h:134
bool(* rcProcessFrameFnPtr)(const struct rxRuntimeConfig_s *rxRuntimeConfig)
Definition: cc2500_rx.h:131
SerialRXType
Definition: cc2500_rx.h:59
@ SERIALRX_SBUS
Definition: cc2500_rx.h:62
@ SERIALRX_IBUS
Definition: cc2500_rx.h:67
@ SERIALRX_SPEKTRUM2048
Definition: cc2500_rx.h:61
@ SERIALRX_SPEKTRUM1024
Definition: cc2500_rx.h:60
@ SERIALRX_SRXL2
Definition: cc2500_rx.h:73
@ SERIALRX_SUMH
Definition: cc2500_rx.h:64
@ SERIALRX_XBUS_MODE_B_RJ01
Definition: cc2500_rx.h:66
@ SERIALRX_SRXL
Definition: cc2500_rx.h:70
@ SERIALRX_XBUS_MODE_B
Definition: cc2500_rx.h:65
@ SERIALRX_FPORT
Definition: cc2500_rx.h:72
@ SERIALRX_CRSF
Definition: cc2500_rx.h:69
@ SERIALRX_SUMD
Definition: cc2500_rx.h:63
@ SERIALRX_JETIEXBUS
Definition: cc2500_rx.h:68
@ SERIALRX_TARGET_CUSTOM
Definition: cc2500_rx.h:71
SerialRXType serialrxProvider
Definition: cc2500_rx.h:144
uint16_t rxRefreshRate
Definition: cc2500_rx.h:146
void setRssiDirect(uint16_t newRssi, rssiSource_e source)
Definition: cc2500_rx.c:700
rcProcessFrameFnPtr rcProcessFrameFn
Definition: cc2500_rx.h:149
rssiSource_e rssiSource
Definition: cc2500_rx.c:100
rxRuntimeConfig_t rxRuntimeConfig
Definition: cc2500_rx.c:131
rcReadRawDataFnPtr rcReadRawFn
Definition: cc2500_rx.h:147
uint16_t * channelData
Definition: cc2500_rx.h:150
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
Definition: vl53l1_types.h:88
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98