Merge remote-tracking branch 'origin/master' into mmosca-mavlinkrc
[inav.git] / src / main / rx / jetiexbus.h
blobd23999e9b008cc8a3fc7fd7120e56f64149ac875
1 /*
2 * This file is part of Cleanflight.
4 * Cleanflight 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 * Cleanflight 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 Cleanflight. If not, see <http://www.gnu.org/licenses/>.
18 #pragma once
20 #define EXBUS_HEADER_LEN 6
21 #define EXBUS_CRC_LEN 2
22 #define EXBUS_OVERHEAD (EXBUS_HEADER_LEN + EXBUS_CRC_LEN)
23 #define EXBUS_MAX_CHANNEL_FRAME_SIZE (EXBUS_HEADER_LEN + JETIEXBUS_CHANNEL_COUNT*2 + EXBUS_CRC_LEN)
24 #define EXBUS_MAX_REQUEST_FRAME_SIZE 9
26 #define EXBUS_EX_REQUEST (0x3A)
28 enum exBusHeader_e {
29 EXBUS_HEADER_SYNC = 0,
30 EXBUS_HEADER_REQ,
31 EXBUS_HEADER_MSG_LEN,
32 EXBUS_HEADER_PACKET_ID,
33 EXBUS_HEADER_DATA_ID,
34 EXBUS_HEADER_SUBLEN,
35 EXBUS_HEADER_DATA
38 enum {
39 EXBUS_STATE_ZERO = 0,
40 EXBUS_STATE_IN_PROGRESS,
41 EXBUS_STATE_RECEIVED,
42 EXBUS_STATE_PROCESSED
45 extern uint8_t jetiExBusRequestState;
46 extern uint32_t jetiTimeStampRequest;
47 extern uint8_t jetiExBusRequestFrame[EXBUS_MAX_REQUEST_FRAME_SIZE];
48 struct serialPort_s;
49 extern struct serialPort_s *jetiExBusPort;
51 uint16_t jetiExBusCalcCRC16(uint8_t *pt, uint8_t msgLen);
52 bool jetiExBusInit(const rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig);