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)
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/>.
24 * Created on: 25 October 2014
25 * Author: Frank26080115
33 #define SMARTPORT_MSP_TX_BUF_SIZE 256
34 #define SMARTPORT_MSP_RX_BUF_SIZE 64
38 FSSP_START_STOP
= 0x7E,
43 FSSP_DATA_FRAME
= 0x10,
44 FSSP_MSPC_FRAME_SMARTPORT
= 0x30, // MSP client frame
45 FSSP_MSPC_FRAME_FPORT
= 0x31, // MSP client frame
46 FSSP_MSPS_FRAME
= 0x32, // MSP server frame
48 // ID of sensor. Must be something that is polled by FrSky RX
49 FSSP_SENSOR_ID1
= 0x1B,
50 FSSP_SENSOR_ID2
= 0x0D,
51 FSSP_SENSOR_ID3
= 0x34,
52 FSSP_SENSOR_ID4
= 0x67
53 // there are 32 ID's polled by smartport master
54 // remaining 3 bits are crc (according to comments in openTx code)
57 typedef struct smartPortPayload_s
{
61 } __attribute__((packed
)) smartPortPayload_t
;
63 typedef void smartPortWriteFrameFn(const smartPortPayload_t
*payload
);
64 typedef bool smartPortReadyToSendFn(void);
66 bool initSmartPortTelemetry(void);
67 void checkSmartPortTelemetryState(void);
68 bool initSmartPortTelemetryExternal(smartPortWriteFrameFn
*smartPortWriteFrameExternal
);
70 void handleSmartPortTelemetry(void);
71 void processSmartPortTelemetry(smartPortPayload_t
*payload
, volatile bool *hasRequest
, const uint32_t *requestTimeout
);
73 smartPortPayload_t
*smartPortDataReceive(uint16_t c
, bool *clearToSend
, smartPortReadyToSendFn
*checkQueueEmpty
, bool withChecksum
);
76 void smartPortWriteFrameSerial(const smartPortPayload_t
*payload
, struct serialPort_s
*port
, uint16_t checksum
);
77 void smartPortSendByte(uint8_t c
, uint16_t *checksum
, struct serialPort_s
*port
);
78 bool smartPortPayloadContainsMSP(const smartPortPayload_t
*payload
);