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)
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/>.
26 #define GHST_RX_BAUDRATE 420000
28 #define GHST_TX_BAUDRATE_FAST 400000
29 #define GHST_TX_BAUDRATE_SLOW 115200
30 #define GHST_BYTE_TIME_FAST_US ((1000000/GHST_TX_BAUDRATE_FAST)*10) // 10 bit words (8 data, 1 start, 1 stop)
31 #define GHST_BYTE_TIME_SLOW_US ((1000000/GHST_TX_BAUDRATE_SLOW)*10)
32 #define GHST_UART_WORDLENGTH UART_WORDLENGTH_8B
35 GHST_ADDR_RADIO
= 0x80,
36 GHST_ADDR_TX_MODULE_SYM
= 0x81, // symmetrical, 400k pulses, 400k telemetry
37 GHST_ADDR_TX_MODULE_ASYM
= 0x88, // asymmetrical, 400k pulses, 115k telemetry
39 GHST_ADDR_GOGGLES
= 0x83,
40 GHST_ADDR_QUANTUM_TEE1
= 0x84, // phase 2
41 GHST_ADDR_QUANTUM_TEE2
= 0x85,
42 GHST_ADDR_QUANTUM_GW1
= 0x86,
43 GHST_ADDR_5G_CLK
= 0x87, // phase 3
48 // frame types 0x10 - 0x1f always include 4 primary channels, plus either 4 aux channels,
49 // or other type-specific data. Expect types 0x14-0x1f to be added in the future, and even though
50 // not explicitly supported, the 4 primary channels should always be extracted.
51 GHST_UL_RC_CHANS_HS4_FIRST
= 0x10, // First frame type including 4 primary channels
52 GHST_UL_RC_CHANS_HS4_5TO8
= 0x10, // primary 4 channel, plus CH5-8
53 GHST_UL_RC_CHANS_HS4_9TO12
= 0x11, // primary 4 channel, plus CH9-12
54 GHST_UL_RC_CHANS_HS4_13TO16
= 0x12, // primary 4 channel, plus CH13-16
55 GHST_UL_RC_CHANS_HS4_RSSI
= 0x13, // primary 4 channel, plus RSSI, LQ, RF Mode, and Tx Power
56 GHST_UL_RC_CHANS_HS4_LAST
= 0x1f // Last frame type including 4 primary channels
59 #define GHST_UL_RC_CHANS_FRAME_COUNT (GHST_UL_RC_CHANS_HS4_13TO16 - GHST_UL_RC_CHANS_HS4_5TO8 + 1) // CH1-16
60 #define GHST_UL_RC_TOTAL_FRAME_COUNT (GHST_UL_RC_CHANS_HS4_LAST - GHST_UL_RC_CHANS_HS4_FIRST + 1) // Include service frames - RSSI etc
61 #define GHST_UL_RC_CHANS_SIZE 12 // 1 (type) + 10 (data) + 1 (crc)
64 GHST_DL_OPENTX_SYNC
= 0x20,
65 GHST_DL_LINK_STAT
= 0x21,
66 GHST_DL_VTX_STAT
= 0x22,
67 GHST_DL_PACK_STAT
= 0x23, // Battery (Pack) Status
68 GHST_DL_GPS_PRIMARY
= 0x25, // Primary GPS data (position)
69 GHST_DL_GPS_SECONDARY
= 0x26 // Secondary GPS data (auxiliary)
72 #define GHST_RC_CTR_VAL_12BIT 0x7C0 // servo center for 12 bit values (0x3e0 << 1)
73 #define GHST_RC_CTR_VAL_8BIT 0x7C // servo center for 8 bit values
75 #define GHST_FRAME_SIZE 14 // including addr, type, len, crc, and payload
77 #define GHST_PAYLOAD_SIZE_MAX 14
79 #define GHST_FRAME_SIZE_MAX 24
81 #define GPS_FLAGS_FIX 0x01
82 #define GPS_FLAGS_FIX_HOME 0x02
84 typedef struct ghstFrameDef_s
{
88 uint8_t payload
[GHST_PAYLOAD_SIZE_MAX
+ 1]; // CRC adds 1
91 typedef union ghstFrame_u
{
92 uint8_t bytes
[GHST_FRAME_SIZE
];
97 /* Pulses payload (channel data), for 4x 12-bit channels */
98 typedef struct ghstPayloadServo4_s
{
99 // 48 bits, or 6 bytes
100 unsigned int ch1
: 12;
101 unsigned int ch2
: 12;
102 unsigned int ch3
: 12;
103 unsigned int ch4
: 12;
104 } __attribute__ ((__packed__
)) ghstPayloadServo4_t
;
106 /* Pulses payload (channel data). Includes 4x high speed control channels, plus 4 channels from CH5-CH12 */
107 typedef struct ghstPayloadPulses_s
{
108 // 80 bits, or 10 bytes
109 ghstPayloadServo4_t ch1to4
;
115 } __attribute__ ((__packed__
)) ghstPayloadPulses_t
;
117 /* Pulses payload (channel data), with RSSI/LQ, and other related data */
118 typedef struct ghstPayloadPulsesRSSI_s
{
119 // 80 bits, or 10 bytes
120 ghstPayloadServo4_t ch1to4
;
122 unsigned int lq
: 8; // 0-100
123 unsigned int rssi
: 8; // 0 - 128 sign inverted, dBm
124 unsigned int rfProtocol
: 8;
125 signed int txPwrdBm
: 8; // tx power in dBm, use lookup table to map to published mW values
126 } __attribute__ ((__packed__
)) ghstPayloadPulsesRSSI_t
;