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 #include "common/time.h"
26 #include "common/utils.h"
28 #define SBUS2_TELEMETRY_PAYLOAD_SIZE 3
30 #define SBUS2_TELEMETRY_ITEM_SIZE 3
31 #define SBUS2_TELEMETRY_SLOTS 8
32 #define SBUS2_TELEMETRY_PAGES 4
34 #define SBUS2_DEADTIME MS2US(2)
35 #define SBUS2_SLOT_TIME 650u
37 #define SBUS2_TRANSMIT_TIME ((8 + 1 + 2 + 1 + 1) * 3 * 10) // 8e2, 100000 baud + star and stop bits
38 #define SBUS2_SLOT_DELAY 200
40 #define SBUS2_SLOT_COUNT (SBUS2_TELEMETRY_PAGES * SBUS2_TELEMETRY_SLOTS)
42 #if defined(USE_TELEMETRY) && defined(USE_TELEMETRY_SBUS2)
44 // Information on SBUS2 sensors from: https://github.com/BrushlessPower/SBUS2-Telemetry/tree/master
45 typedef struct sbus2_telemetry_frame_s
{
52 } __attribute__((packed
)) sbus2_telemetry_frame_t
;
55 STATIC_ASSERT(sizeof(sbus2_telemetry_frame_t
) == 3, sbus2_telemetry_size
);
57 extern const uint8_t sbus2SlotIds
[SBUS2_SLOT_COUNT
];
58 extern sbus2_telemetry_frame_t sbusTelemetryData
[SBUS2_SLOT_COUNT
];
59 extern uint8_t sbusTelemetryDataUsed
[SBUS2_SLOT_COUNT
];
61 // refresh telemetry buffers
62 void handleSbus2Telemetry(timeUs_t currentTimeUs
);
64 // time critical, send sbus2 data
65 void taskSendSbus2Telemetry(timeUs_t currentTimeUs
);
67 uint8_t sbus2GetTelemetrySlot(timeUs_t elapsed
);
68 void sbus2IncrementTelemetrySlot(timeUs_t now
);