Add Winbond W25Q512J support (#14036)
[betaflight.git] / src / main / pg / rx.c
blob824118e4edf13864c1f24b693edacac2c5b95520
1 /*
2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
8 * any later version.
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
21 #include "platform.h"
23 #if defined(USE_RX_PWM) || defined(USE_RX_PPM) || defined(USE_SERIALRX) || defined(USE_RX_MSP) || defined(USE_RX_SPI)
25 #include "pg/pg.h"
26 #include "pg/pg_ids.h"
27 #include "rx.h"
29 #include "config/config_reset.h"
31 #include "drivers/io.h"
32 #include "fc/rc.h"
33 #include "fc/rc_controls.h"
34 #include "rx/rx.h"
35 #include "rx/rx_spi.h"
37 #ifndef SERIALRX_PROVIDER
39 #if defined(USE_SERIALRX_CRSF)
40 #define SERIALRX_PROVIDER SERIALRX_CRSF
41 #elif defined(USE_SERIALRX_GHST)
42 #define SERIALRX_PROVIDER SERIALRX_GHST
43 #elif defined(USE_SERIALRX_IBUS)
44 #define SERIALRX_PROVIDER SERIALRX_IBUS
45 #elif defined(USE_SERIALRX_SBUS)
46 #define SERIALRX_PROVIDER SERIALRX_SBUS
47 #elif defined(USE_SERIALRX_SPEKTRUM)
48 #if defined(USE_TELEMETRY_SRXL)
49 #define SERIALRX_PROVIDER SERIALRX_SRXL
50 #else
51 #define SERIALRX_PROVIDER SERIALRX_SPEKTRUM2048
52 #endif
53 #elif defined(USE_SERIALRX_FPORT)
54 #define SERIALRX_PROVIDER SERIALRX_FPORT
55 #elif defined(USE_SERIALRX_XBUS)
56 #define SERIALRX_PROVIDER SERIALRX_XBUS_MODE_B
57 #elif defined(USE_SERIALRX_SRXL2)
58 #define SERIALRX_PROVIDER SERIALRX_SRXL2
59 #elif defined(USE_SERIALRX_JETIEXBUS)
60 #define SERIALRX_PROVIDER SERIALRX_JETIEXBUS
61 #elif defined(USE_SERIALRX_SUMD)
62 #define SERIALRX_PROVIDER SERIALRX_SUMD
63 #elif defined(USE_SERIALRX_SUMH)
64 #define SERIALRX_PROVIDER SERIALRX_SUMH
65 #else
66 #define SERIALRX_PROVIDER SERIALRX_NONE
67 #endif
69 #endif
71 #ifndef SERIALRX_HALFDUPLEX
72 #if (defined(USE_SERIALRX_FPORT) || defined(USE_SERIALRX_SRXL2)) && !(defined(USE_SERIALRX_CRSF) && defined(USE_SERIALRX_GHST) && defined(USE_SERIALRX_IBUS) && defined(USE_SERIALRX_SBUS) && defined(USE_SERIALRX_SPEKTRUM) && defined(USE_SERIALRX_XBUS))
73 #define SERIALRX_HALFDUPLEX 1
74 #else
75 #define SERIALRX_HALFDUPLEX 0
76 #endif
77 #endif
79 PG_REGISTER_WITH_RESET_FN(rxConfig_t, rxConfig, PG_RX_CONFIG, 4);
80 void pgResetFn_rxConfig(rxConfig_t *rxConfig)
82 RESET_CONFIG_2(rxConfig_t, rxConfig,
83 .halfDuplex = SERIALRX_HALFDUPLEX,
84 .serialrx_provider = SERIALRX_PROVIDER,
85 .serialrx_inverted = 0,
86 .spektrum_bind_pin_override_ioTag = IO_TAG(SPEKTRUM_BIND_PIN),
87 .spektrum_bind_plug_ioTag = IO_TAG(BINDPLUG_PIN),
88 .spektrum_sat_bind = 0,
89 .spektrum_sat_bind_autoreset = 1,
90 .midrc = RX_MID_USEC,
91 .mincheck = 1050,
92 .maxcheck = 1900,
93 .rx_min_usec = RX_MIN_USEC, // any of first 4 channels below this value will trigger rx loss detection
94 .rx_max_usec = RX_MAX_USEC, // any of first 4 channels above this value will trigger rx loss detection
95 .rssi_src_frame_errors = false,
96 .rssi_channel = 0,
97 .rssi_scale = RSSI_SCALE_DEFAULT,
98 .rssi_offset = 0,
99 .rssi_invert = 0,
100 .rssi_src_frame_lpf_period = 30,
101 .rssi_smoothing = 125,
102 .fpvCamAngleDegrees = 0,
103 .airModeActivateThreshold = 25,
104 .max_aux_channel = DEFAULT_AUX_CHANNEL_COUNT,
105 .rc_smoothing_mode = 1,
106 .rc_smoothing_setpoint_cutoff = 0,
107 .rc_smoothing_feedforward_cutoff = 0,
108 .rc_smoothing_throttle_cutoff = 0,
109 .rc_smoothing_debug_axis = ROLL,
110 .rc_smoothing_auto_factor_rpy = 30,
111 .rc_smoothing_auto_factor_throttle = 30,
112 .srxl2_unit_id = 1,
113 .srxl2_baud_fast = true,
114 .sbus_baud_fast = false,
115 .msp_override_channels_mask = 0,
116 .crsf_use_negotiated_baud = false,
119 #ifdef RX_CHANNELS_TAER
120 parseRcChannels("TAER1234", rxConfig);
121 #else
122 parseRcChannels("AETR1234", rxConfig);
123 #endif
126 #endif