Update actions to ubuntu-latest (#14114)
[betaflight.git] / src / main / rx / rx_bind.c
blob2d6904cb983c183caf14b1089060dbfab3c28701
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"
27 #include "rx/crsf.h"
29 #include "rx_bind.h"
31 static bool doRxBind(bool doBind)
33 #if !defined(USE_SERIALRX_SRXL2) && !defined(USE_RX_FRSKY_SPI) && !defined(USE_RX_SFHSS_SPI) && !defined(USE_RX_FLYSKY) && !defined(USE_RX_SPEKTRUM) && !defined(USE_RX_EXPRESSLRS) && !defined(USE_SERIALRX_CRSF)
34 UNUSED(doBind);
35 #endif
37 switch (rxRuntimeState.rxProvider) {
38 default:
39 return false;
40 case RX_PROVIDER_SERIAL:
41 switch (rxRuntimeState.serialrxProvider) {
42 default:
43 return false;
44 #if defined(USE_SERIALRX_CRSF)
45 case SERIALRX_CRSF:
46 if (doBind) {
47 crsfRxBind();
50 break;
51 #endif
52 #if defined(USE_SERIALRX_SRXL2)
53 case SERIALRX_SRXL2:
54 if (doBind) {
55 srxl2Bind();
58 break;
59 #endif
62 break;
63 #if defined(USE_RX_SPI)
64 case RX_PROVIDER_SPI:
65 switch (rxSpiConfig()->rx_spi_protocol) {
66 default:
67 return false;
68 #if defined(USE_RX_FRSKY_SPI)
69 #if defined(USE_RX_FRSKY_SPI_D)
70 case RX_SPI_FRSKY_D:
71 #endif
72 #if defined(USE_RX_FRSKY_SPI_X)
73 case RX_SPI_FRSKY_X:
74 case RX_SPI_FRSKY_X_LBT:
75 case RX_SPI_FRSKY_X_V2:
76 case RX_SPI_FRSKY_X_LBT_V2:
77 #endif
78 #if defined(USE_RX_REDPINE_SPI)
79 case RX_SPI_REDPINE:
80 #endif
81 #endif // USE_RX_FRSKY_SPI
82 #ifdef USE_RX_SFHSS_SPI
83 case RX_SPI_SFHSS:
84 #endif
85 #ifdef USE_RX_FLYSKY
86 case RX_SPI_A7105_FLYSKY:
87 case RX_SPI_A7105_FLYSKY_2A:
88 #endif
89 #ifdef USE_RX_SPEKTRUM
90 case RX_SPI_CYRF6936_DSM:
91 #endif
92 #ifdef USE_RX_EXPRESSLRS
93 case RX_SPI_EXPRESSLRS:
94 #endif
95 #if defined(USE_RX_FRSKY_SPI) || defined(USE_RX_SFHSS_SPI) || defined(USE_RX_FLYSKY) || defined(USE_RX_SPEKTRUM) || defined(USE_RX_EXPRESSLRS)
96 if (doBind) {
97 rxSpiBind();
100 break;
101 #endif
104 break;
105 #endif
108 return true;
111 bool startRxBind(void)
113 return doRxBind(true);
116 bool getRxBindSupported(void)
118 return doRxBind(false);
120 #endif