Remove dead code
[inav.git] / src / main / telemetry / sbus2.h
blob10e5b35ece04817b22b86b3a2154d41775a2d33d
1 /*
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/>.
19 #pragma once
21 #include <stdint.h>
23 #include "platform.h"
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_DELAY_MAX (MIN(350u, (SBUS2_SLOT_TIME / 2u)))
42 #define SBUS2_SLOT_COUNT (SBUS2_TELEMETRY_PAGES * SBUS2_TELEMETRY_SLOTS)
44 #if defined(USE_TELEMETRY) && defined(USE_TELEMETRY_SBUS2)
46 // Information on SBUS2 sensors from: https://github.com/BrushlessPower/SBUS2-Telemetry/tree/master
47 typedef struct sbus2_telemetry_frame_s {
48 uint8_t slotId;
49 union
51 uint8_t data[2];
52 uint16_t u16;
53 } payload;
54 } __attribute__((packed)) sbus2_telemetry_frame_t;
57 STATIC_ASSERT(sizeof(sbus2_telemetry_frame_t) == 3, sbus2_telemetry_size);
59 extern const uint8_t sbus2SlotIds[SBUS2_SLOT_COUNT];
60 extern sbus2_telemetry_frame_t sbusTelemetryData[SBUS2_SLOT_COUNT];
61 extern uint8_t sbusTelemetryDataUsed[SBUS2_SLOT_COUNT];
63 // refresh telemetry buffers
64 void handleSbus2Telemetry(timeUs_t currentTimeUs);
66 // time critical, send sbus2 data
67 void taskSendSbus2Telemetry(timeUs_t currentTimeUs);
69 uint8_t sbus2GetTelemetrySlot(timeUs_t elapsed);
70 void sbus2IncrementTelemetrySlot(timeUs_t now);
72 #endif