Fixed CRSF RF mode indication on link loss.
[betaflight.git] / src / main / rx / crsf.h
blob6430e93f28fb052cc003532bf9e9d1d108a5b156
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 #pragma once
23 #include "rx/crsf_protocol.h"
26 #define CRSF_PORT_OPTIONS (SERIAL_STOPBITS_1 | SERIAL_PARITY_NO)
27 #define CRSF_PORT_MODE MODE_RXTX
29 #define CRSF_MAX_CHANNEL 16
31 #define CRSF_RSSI_MIN (-130)
32 #define CRSF_RSSI_MAX 0
33 #define CRSF_SNR_MIN (-30)
34 #define CRSF_SNR_MAX 20
36 /* For documentation purposes
37 typedef enum {
38 CRSF_RF_MODE_4_FPS = 0,
39 CRSF_RF_MODE_50_FPS,
40 CRSF_RF_MODE_150_FPS,
41 } crsfRfMode_e;
44 typedef struct crsfFrameDef_s {
45 uint8_t deviceAddress;
46 uint8_t frameLength;
47 uint8_t type;
48 uint8_t payload[CRSF_PAYLOAD_SIZE_MAX + 1]; // +1 for CRC at end of payload
49 } crsfFrameDef_t;
51 typedef union crsfFrame_u {
52 uint8_t bytes[CRSF_FRAME_SIZE_MAX];
53 crsfFrameDef_t frame;
54 } crsfFrame_t;
56 void crsfRxWriteTelemetryData(const void *data, int len);
57 void crsfRxSendTelemetryData(void);
59 struct rxConfig_s;
60 struct rxRuntimeState_s;
61 bool crsfRxInit(const struct rxConfig_s *initialRxConfig, struct rxRuntimeState_s *rxRuntimeState);
62 bool crsfRxIsActive(void);