2 * This file is part of INAV.
4 * INAV 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 * INAV 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 INAV. If not, see <http://www.gnu.org/licenses/>.
25 #define SBUS2_TELEMETRY_PAYLOAD_SIZE 3
27 #define SBUS2_TELEMETRY_ITEM_SIZE 3
28 #define SBUS2_TELEMETRY_SLOTS 8
29 #define SBUS2_TELEMETRY_PAGES 4
30 #define SBUS2_SLOT_COUNT (SBUS2_TELEMETRY_PAGES * SBUS2_TELEMETRY_SLOTS)
32 #if defined(USE_TELEMETRY) && defined(USE_SBUS2_TELEMETRY)
34 // Information on SBUS2 sensors from: https://github.com/BrushlessPower/SBUS2-Telemetry/tree/master
38 typedef struct sbus2_telemetry_temp_payload_s
{
39 uint8_t tempHigh
; // temp | 0x4000; // 125c
41 } __attribute__((packed
)) sbsu2_telemetry_temp_payload_t
;
46 typedef struct sbus2_telemetry_temp200_payload_s
{
47 uint8_t tempLow
; // temp | 0x8000; // 200c
49 } __attribute__((packed
)) sbsu2_telemetry_temp200_payload_t
;
52 // (RPM / 6) max: 0xFFFF
53 typedef struct sbus2_telemetry_rpm_payload_s
{
54 uint8_t rpmHigh
; // RPM / 6, capped at 0xFFFF
56 } __attribute__((packed
)) sbsu2_telemetry_rpm_payload_t
;
58 // Voltage: 1 or 2 slots
59 // 0x8000 = rx voltage?
61 typedef struct sbus2_telemetry_voltage_payload_s
{
62 uint8_t voltageHigh
; // 2 slots // Voltage 1: value | 0x8000
63 uint8_t voltageLow
; // max input value: 0x1FFF
64 } __attribute__((packed
)) sbsu2_telemetry_voltage_payload_t
;
73 // same as voltage frame. may not need ot be capped.
75 typedef struct sbus2_telemetry_current_payload_s
{
78 } __attribute__((packed
)) sbsu2_telemetry_current_payload_t
;
80 typedef struct sbus2_telemetry_capacity_payload_s
{
83 } __attribute__((packed
)) sbsu2_telemetry_capacity_payload_t
;
93 typedef struct sbus2_telemetry_frame_s
{
98 sbsu2_telemetry_temp_payload_t temp125
;
99 sbsu2_telemetry_temp200_payload_t temp200
;
100 sbsu2_telemetry_rpm_payload_t rpm
;
101 sbsu2_telemetry_voltage_payload_t voltage
;
102 sbsu2_telemetry_current_payload_t current
;
103 sbsu2_telemetry_capacity_payload_t capacity
;
105 } __attribute__((packed
)) sbus2_telemetry_frame_t
;
107 extern const uint8_t Slot_ID
[SBUS2_SLOT_COUNT
];
108 extern sbus2_telemetry_frame_t sbusTelemetryData
[SBUS2_TELEMETRY_PAGES
][SBUS2_TELEMETRY_SLOTS
];
109 extern uint8_t sbusTelemetryDataStatus
[SBUS2_TELEMETRY_PAGES
][SBUS2_TELEMETRY_SLOTS
];
111 void handleSbus2Telemetry(timeUs_t currentTimeUs
);