Merge pull request #11198 from SteveCEvans/sce_rc2
[betaflight.git] / src / main / rx / rx_bind.c
bloba1fa029d5608c8ffaf751d7d18fc2950039d056a
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_BIND)
25 #include "rx/rx_spi_common.h"
26 #include "rx/srxl2.h"
28 #include "rx_bind.h"
30 static bool doRxBind(bool doBind)
32 switch (rxRuntimeState.rxProvider) {
33 default:
34 return false;
35 case RX_PROVIDER_SERIAL:
36 switch (rxRuntimeState.serialrxProvider) {
37 default:
38 return false;
39 #if defined(USE_SERIALRX_SRXL2)
40 case SERIALRX_SRXL2:
41 if (doBind) {
42 srxl2Bind();
45 break;
46 #endif
49 break;
50 #if defined(USE_RX_SPI)
51 case RX_PROVIDER_SPI:
52 switch (rxSpiConfig()->rx_spi_protocol) {
53 default:
54 return false;
55 #if defined(USE_RX_FRSKY_SPI)
56 #if defined(USE_RX_FRSKY_SPI_D)
57 case RX_SPI_FRSKY_D:
58 #endif
59 #if defined(USE_RX_FRSKY_SPI_X)
60 case RX_SPI_FRSKY_X:
61 case RX_SPI_FRSKY_X_LBT:
62 case RX_SPI_FRSKY_X_V2:
63 case RX_SPI_FRSKY_X_LBT_V2:
64 #endif
65 #if defined(USE_RX_REDPINE_SPI)
66 case RX_SPI_REDPINE:
67 #endif
68 #endif // USE_RX_FRSKY_SPI
69 #ifdef USE_RX_SFHSS_SPI
70 case RX_SPI_SFHSS:
71 #endif
72 #ifdef USE_RX_FLYSKY
73 case RX_SPI_A7105_FLYSKY:
74 case RX_SPI_A7105_FLYSKY_2A:
75 #endif
76 #ifdef USE_RX_SPEKTRUM
77 case RX_SPI_CYRF6936_DSM:
78 #endif
79 #ifdef USE_RX_EXPRESSLRS
80 case RX_SPI_EXPRESSLRS:
81 #endif
82 #if defined(USE_RX_FRSKY_SPI) || defined(USE_RX_SFHSS_SPI) || defined(USE_RX_FLYSKY) || defined(USE_RX_SPEKTRUM) || defined(USE_RX_EXPRESSLRS)
83 if (doBind) {
84 rxSpiBind();
87 break;
88 #endif
91 break;
92 #endif
95 return true;
98 bool startRxBind(void)
100 return doRxBind(true);
103 bool getRxBindSupported(void)
105 return doRxBind(false);
107 #endif