[4.4.2] Remove 15 m/s limit on estimated vario (#12788)
[betaflight.git] / src / main / io / tramp_protocol.h
blob1c2938d593fb34ded8013c4c7a8424a8cadb0adb
1 /*
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)
8 * any later version.
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/>.
21 #pragma once
23 #include "drivers/serial.h"
25 #define TRAMP_SERIAL_OPTIONS SERIAL_NOT_INVERTED | SERIAL_BIDIR
26 #define TRAMP_BAUD 9600
27 #define TRAMP_PAYLOAD_LENGTH 12
29 typedef struct trampSettings_s {
30 uint16_t frequency;
31 uint16_t power;
32 uint8_t raceModeEnabled;
33 uint8_t pitModeEnabled;
34 } __attribute__((packed)) trampSettings_t;
36 typedef struct trampFrameHeader_s {
37 uint8_t syncStart;
38 uint8_t command;
39 } __attribute__((packed)) trampFrameHeader_t;
41 #define TRAMP_HEADER_LENGTH sizeof(trampFrameHeader_t)
43 typedef struct trampFrameFooter_s {
44 uint8_t crc;
45 uint8_t syncStop;
46 } __attribute__((packed)) trampFrameFooter_t;
48 typedef union trampPayload_u {
49 uint8_t buf[TRAMP_PAYLOAD_LENGTH];
50 trampSettings_t settings;
51 uint16_t frequency;
52 uint16_t power;
53 uint8_t active;
54 } trampPayload_t;
56 typedef struct trampFrame_s {
57 trampFrameHeader_t header;
58 trampPayload_t payload;
59 trampFrameFooter_t footer;
60 } __attribute__((packed)) trampFrame_t;
62 #define TRAMP_FRAME_LENGTH sizeof(trampFrame_t)
64 STATIC_ASSERT(sizeof(trampFrameHeader_t) == 2, trampInterface_headerSizeMismatch);
65 STATIC_ASSERT(sizeof(trampFrame_t) == 16, trampInterface_frameSizeMismatch);
67 void trampFrameGetSettings(trampFrame_t *frame);
68 void trampFrameSetFrequency(trampFrame_t *frame, const uint16_t frequency);
69 void trampFrameSetPower(trampFrame_t *frame, const uint16_t power);
70 void trampFrameSetActiveState(trampFrame_t *frame, const bool active);
71 bool trampParseResponseBuffer(trampSettings_t *settings, const uint8_t *buffer, size_t bufferLen);