Set blackbox file handler to NULL after closing file
[inav.git] / src / main / rx / srxl2_types.h
blobd5edce381bc15033b2ed9c72485e6bdce7dcff69
1 #pragma once
3 #define PACKED __attribute__((packed))
5 typedef enum {
6 Disabled,
7 ListenForActivity,
8 SendHandshake,
9 ListenForHandshake,
10 Running
11 } Srxl2State;
13 typedef enum {
14 Handshake = 0x21,
15 BindInfo = 0x41,
16 ParameterConfiguration = 0x50,
17 SignalQuality = 0x55,
18 TelemetrySensorData = 0x80,
19 ControlData = 0xCD,
20 } Srxl2PacketType;
22 typedef struct {
23 uint8_t id;
24 uint8_t packetType;
25 uint8_t length;
26 } PACKED Srxl2Header;
28 typedef struct {
29 uint8_t sourceDeviceId;
30 uint8_t destinationDeviceId;
31 uint8_t priority;
32 uint8_t baudSupported;
33 uint8_t info;
34 uint32_t uniqueId;
35 } PACKED Srxl2HandshakeSubHeader;
37 typedef struct {
38 uint8_t command;
39 uint8_t replyId;
40 } PACKED Srxl2ControlDataSubHeader;
42 typedef enum {
43 ChannelData = 0x00,
44 FailsafeChannelData = 0x01,
45 VTXData = 0x02,
46 } Srxl2ControlDataCommand;
48 typedef struct {
49 int8_t rssi;
50 uint16_t frameLosses;
51 union {
52 //struct {
53 // uint8_t channels_0_7;
54 // uint8_t channels_8_15;
55 // uint8_t channels_16_23;
56 // uint8_t channels_24_31;
57 //} u8;
58 uint8_t u8[4];
59 uint32_t u32;
60 } channelMask;
61 } PACKED Srxl2ChannelDataHeader;
63 typedef enum {
64 NoDevice = 0,
65 RemoteReceiver = 1,
66 Receiver = 2,
67 FlightController = 3,
68 ESC = 4,
69 Reserved = 5,
70 SRXLServo = 6,
71 SRXLServo_2 = 7,
72 VTX = 8,
73 } Srxl2DeviceType;
75 typedef enum {
76 FlightControllerDefault = 0x30,
77 FlightControllerMax = 0x3F,
78 Broadcast = 0xFF,
79 } Srxl2DeviceId;
81 typedef struct {
82 Srxl2Header header;
83 Srxl2HandshakeSubHeader payload;
84 uint8_t crcHigh;
85 uint8_t crcLow;
86 } PACKED Srxl2HandshakeFrame;
88 typedef enum {
89 EnterBindMode = 0xEB,
90 RequestBindStatus = 0xB5,
91 BoundDataReport = 0xDB,
92 SetBindInfo = 0x5B,
93 } Srxl2BindRequest;
95 typedef enum {
96 NotBound = 0x0,
97 DSM2_1024_22ms = 0x01,
98 DSM2_1024_MC24 = 0x02,
99 DMS2_2048_11ms = 0x12,
100 DMSX_22ms = 0xA2,
101 DMSX_11ms = 0xB2,
102 Surface_DSM2_16_5ms = 0x63,
103 DSMR_11ms_22ms = 0xE2,
104 DSMR_5_5ms = 0xE4,
105 } Srxl2BindType;
107 // Bit masks for Options byte
108 #define SRXL_BIND_OPT_NONE (0x00)
109 #define SRXL_BIND_OPT_TELEM_TX_ENABLE (0x01) // Set if this device should be enabled as the current telemetry device to tx over RF
110 #define SRXL_BIND_OPT_BIND_TX_ENABLE (0x02) // Set if this device should reply to a bind request with a Discover packet over RF
112 typedef struct {
113 uint8_t request;
114 uint8_t deviceId;
115 uint8_t bindType;
116 uint8_t options;
117 uint64_t guid;
118 uint32_t uid;
119 } PACKED Srxl2BindInfoPayload;
121 typedef struct {
122 Srxl2Header header;
123 Srxl2BindInfoPayload payload;
124 uint8_t crcHigh;
125 uint8_t crcLow;
126 } PACKED Srxl2BindInfoFrame;
128 // VTX Data
129 typedef struct {
130 uint8_t band; // VTX Band (0 = Fatshark, 1 = Raceband, 2 = E, 3 = B, 4 = A)
131 uint8_t channel; // VTX Channel (0-7)
132 uint8_t pit; // Pit/Race mode (0 = Race, 1 = Pit). Race = (normal operating) mode. Pit = (reduced power) mode.
133 uint8_t power; // VTX Power (0 = Off, 1 = 1mw to 14mW, 2 = 15mW to 25mW, 3 = 26mW to 99mW, 4 = 100mW to 299mW, 5 = 300mW to 600mW, 6 = 601mW+, 7 = manual control)
134 uint16_t powerDec; // VTX Power as a decimal 1mw/unit
135 uint8_t region; // Region (0 = USA, 1 = EU)
136 } PACKED Srxl2VtxData;
138 #undef PACKED