vtx: fix VTX_SETTINGS_POWER_COUNT and add dummy entries to saPowerNames
[inav.git] / src / main / rx / sbus_channels.h
bloba0276ac005c2fd2cc2df5f9820cef4103679a052
1 /*
2 * This file is part of Cleanflight.
4 * Cleanflight is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Cleanflight is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
18 #pragma once
20 #include <stdint.h>
21 #include "rx/rx.h"
23 #define SBUS_MAX_CHANNEL 34
25 #define SBUS_FLAG_CHANNEL_DG1 (1 << 0)
26 #define SBUS_FLAG_CHANNEL_DG2 (1 << 1)
27 #define SBUS_FLAG_SIGNAL_LOSS (1 << 2)
28 #define SBUS_FLAG_FAILSAFE_ACTIVE (1 << 3)
30 #define SBUS_CHANNEL_DATA_LENGTH sizeof(sbusChannels_t)
31 #define SBUS_FRAME_SIZE (SBUS_CHANNEL_DATA_LENGTH + 2)
33 #define SBUS_FRAME_BEGIN_BYTE ((uint8_t)0x0F)
34 #define SBUS2_HIGHFRAME_BEGIN_BYTE ((uint8_t)0x2F)
36 #define SBUS_BAUDRATE 100000
37 #define SBUS_BAUDRATE_FAST 200000
39 #if !defined(SBUS_PORT_OPTIONS)
40 #define SBUS_PORT_OPTIONS (SERIAL_STOPBITS_2 | SERIAL_PARITY_EVEN)
41 #endif
43 typedef struct sbusChannels_s {
44 // 176 bits of data (11 bits per channel * 16 channels) = 22 bytes.
45 unsigned int chan0 : 11;
46 unsigned int chan1 : 11;
47 unsigned int chan2 : 11;
48 unsigned int chan3 : 11;
49 unsigned int chan4 : 11;
50 unsigned int chan5 : 11;
51 unsigned int chan6 : 11;
52 unsigned int chan7 : 11;
53 unsigned int chan8 : 11;
54 unsigned int chan9 : 11;
55 unsigned int chan10 : 11;
56 unsigned int chan11 : 11;
57 unsigned int chan12 : 11;
58 unsigned int chan13 : 11;
59 unsigned int chan14 : 11;
60 unsigned int chan15 : 11;
61 uint8_t flags;
62 } __attribute__((__packed__)) sbusChannels_t;
64 typedef struct sbusFrame_s {
65 uint8_t syncByte;
66 sbusChannels_t channels;
67 /**
68 * The endByte is 0x00 on FrSky and some futaba RX's, on Some SBUS2 RX's the value indicates the telemetry byte that is sent after every 4th sbus frame.
70 * See https://github.com/cleanflight/cleanflight/issues/590#issuecomment-101027349
71 * and
72 * https://github.com/cleanflight/cleanflight/issues/590#issuecomment-101706023
74 uint8_t endByte;
75 } __attribute__ ((__packed__)) sbusFrame_t;
78 uint16_t sbusDecodeChannelValue(uint16_t sbusValue, bool safeValuesOnly);
79 uint16_t sbusEncodeChannelValue(uint16_t rcValue);
81 uint8_t sbusChannelsDecode(rxRuntimeConfig_t *rxRuntimeConfig, const sbusChannels_t *channels);
82 uint8_t sbus26ChannelsDecode(rxRuntimeConfig_t *rxRuntimeConfig, const sbusChannels_t *channels, bool highChannels);
84 void sbusChannelsInit(rxRuntimeConfig_t *rxRuntimeConfig);