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/>.
22 * Crossfire constants provided by Team Black Sheep under terms of the 2-Clause BSD License
30 #define CRSF_BAUDRATE 420000
32 enum { CRSF_SYNC_BYTE
= 0xC8 };
34 enum { CRSF_FRAME_SIZE_MAX
= 64 }; // 62 bytes frame plus 2 bytes frame header(<length><type>)
35 enum { CRSF_PAYLOAD_SIZE_MAX
= CRSF_FRAME_SIZE_MAX
- 6 };
38 CRSF_FRAMETYPE_GPS
= 0x02,
39 CRSF_FRAMETYPE_BATTERY_SENSOR
= 0x08,
40 CRSF_FRAMETYPE_LINK_STATISTICS
= 0x14,
41 CRSF_FRAMETYPE_RC_CHANNELS_PACKED
= 0x16,
42 CRSF_FRAMETYPE_SUBSET_RC_CHANNELS_PACKED
= 0x17,
43 CRSF_FRAMETYPE_LINK_STATISTICS_RX
= 0x1C,
44 CRSF_FRAMETYPE_LINK_STATISTICS_TX
= 0x1D,
45 CRSF_FRAMETYPE_ATTITUDE
= 0x1E,
46 CRSF_FRAMETYPE_FLIGHT_MODE
= 0x21,
47 // Extended Header Frames, range: 0x28 to 0x96
48 CRSF_FRAMETYPE_DEVICE_PING
= 0x28,
49 CRSF_FRAMETYPE_DEVICE_INFO
= 0x29,
50 CRSF_FRAMETYPE_PARAMETER_SETTINGS_ENTRY
= 0x2B,
51 CRSF_FRAMETYPE_PARAMETER_READ
= 0x2C,
52 CRSF_FRAMETYPE_PARAMETER_WRITE
= 0x2D,
53 CRSF_FRAMETYPE_COMMAND
= 0x32,
55 CRSF_FRAMETYPE_MSP_REQ
= 0x7A, // response request using msp sequence as command
56 CRSF_FRAMETYPE_MSP_RESP
= 0x7B, // reply with 58 byte chunked binary
57 CRSF_FRAMETYPE_MSP_WRITE
= 0x7C, // write with 8 byte chunked binary (OpenTX outbound telemetry buffer limit)
58 CRSF_FRAMETYPE_DISPLAYPORT_CMD
= 0x7D, // displayport control command
62 CRSF_COMMAND_SUBCMD_GENERAL
= 0x0A, // general command
66 CRSF_COMMAND_SUBCMD_GENERAL_CRSF_SPEED_PROPOSAL
= 0x70, // proposed new CRSF port speed
67 CRSF_COMMAND_SUBCMD_GENERAL_CRSF_SPEED_RESPONSE
= 0x71, // response to the proposed CRSF port speed
71 CRSF_DISPLAYPORT_SUBCMD_UPDATE
= 0x01, // transmit displayport buffer to remote
72 CRSF_DISPLAYPORT_SUBCMD_CLEAR
= 0X02, // clear client screen
73 CRSF_DISPLAYPORT_SUBCMD_OPEN
= 0x03, // client request to open cms menu
74 CRSF_DISPLAYPORT_SUBCMD_CLOSE
= 0x04, // client request to close cms menu
75 CRSF_DISPLAYPORT_SUBCMD_POLL
= 0x05, // client request to poll/refresh cms menu
79 CRSF_DISPLAYPORT_OPEN_ROWS_OFFSET
= 1,
80 CRSF_DISPLAYPORT_OPEN_COLS_OFFSET
= 2,
84 CRSF_FRAME_GPS_PAYLOAD_SIZE
= 15,
85 CRSF_FRAME_BATTERY_SENSOR_PAYLOAD_SIZE
= 8,
86 CRSF_FRAME_LINK_STATISTICS_PAYLOAD_SIZE
= 10,
87 CRSF_FRAME_LINK_STATISTICS_TX_PAYLOAD_SIZE
= 6,
88 CRSF_FRAME_RC_CHANNELS_PAYLOAD_SIZE
= 22, // 11 bits per channel * 16 channels = 22 bytes.
89 CRSF_FRAME_ATTITUDE_PAYLOAD_SIZE
= 6,
93 CRSF_FRAME_LENGTH_ADDRESS
= 1, // length of ADDRESS field
94 CRSF_FRAME_LENGTH_FRAMELENGTH
= 1, // length of FRAMELENGTH field
95 CRSF_FRAME_LENGTH_TYPE
= 1, // length of TYPE field
96 CRSF_FRAME_LENGTH_CRC
= 1, // length of CRC field
97 CRSF_FRAME_LENGTH_TYPE_CRC
= 2, // length of TYPE and CRC fields combined
98 CRSF_FRAME_LENGTH_EXT_TYPE_CRC
= 4, // length of Extended Dest/Origin, TYPE and CRC fields combined
99 CRSF_FRAME_LENGTH_NON_PAYLOAD
= 4, // combined length of all fields except payload
103 CRSF_FRAME_TX_MSP_FRAME_SIZE
= 58,
104 CRSF_FRAME_RX_MSP_FRAME_SIZE
= 8,
105 CRSF_FRAME_ORIGIN_DEST_SIZE
= 2,
108 // Clashes with CRSF_ADDRESS_FLIGHT_CONTROLLER
109 #define CRSF_SYNC_BYTE 0XC8
112 CRSF_ADDRESS_BROADCAST
= 0x00,
113 CRSF_ADDRESS_USB
= 0x10,
114 CRSF_ADDRESS_TBS_CORE_PNP_PRO
= 0x80,
115 CRSF_ADDRESS_RESERVED1
= 0x8A,
116 CRSF_ADDRESS_CURRENT_SENSOR
= 0xC0,
117 CRSF_ADDRESS_GPS
= 0xC2,
118 CRSF_ADDRESS_TBS_BLACKBOX
= 0xC4,
119 CRSF_ADDRESS_FLIGHT_CONTROLLER
= 0xC8,
120 CRSF_ADDRESS_RESERVED2
= 0xCA,
121 CRSF_ADDRESS_RACE_TAG
= 0xCC,
122 CRSF_ADDRESS_RADIO_TRANSMITTER
= 0xEA,
123 CRSF_ADDRESS_CRSF_RECEIVER
= 0xEC,
124 CRSF_ADDRESS_CRSF_TRANSMITTER
= 0xEE