4 * Created on: 25 October 2014
5 * Author: Frank26080115
13 #include "common/time.h"
15 #define SMARTPORT_MSP_TX_BUF_SIZE 256
16 #define SMARTPORT_MSP_RX_BUF_SIZE 64
20 FSSP_START_STOP
= 0x7E,
25 FSSP_DATA_FRAME
= 0x10,
26 FSSP_MSPC_FRAME_SMARTPORT
= 0x30, // MSP client frame
27 FSSP_MSPC_FRAME_FPORT
= 0x31, // MSP client frame
28 FSSP_MSPS_FRAME
= 0x32, // MSP server frame
30 // ID of sensor. Must be something that is polled by FrSky RX
31 FSSP_SENSOR_ID1
= 0x1B,
32 FSSP_SENSOR_ID2
= 0x0D,
33 FSSP_SENSOR_ID3
= 0x34,
34 FSSP_SENSOR_ID4
= 0x67
35 // there are 32 ID's polled by smartport master
36 // remaining 3 bits are crc (according to comments in openTx code)
39 typedef struct smartPortPayload_s
{
43 } __attribute__((packed
)) smartPortPayload_t
;
45 typedef void smartPortWriteFrameFn(const smartPortPayload_t
*payload
);
46 typedef bool smartPortCheckQueueEmptyFn(void);
48 bool initSmartPortTelemetry(void);
49 void checkSmartPortTelemetryState(void);
50 bool initSmartPortTelemetryExternal(smartPortWriteFrameFn
*smartPortWriteFrameExternal
);
52 void handleSmartPortTelemetry(void);
53 void processSmartPortTelemetry(smartPortPayload_t
*payload
, volatile bool *hasRequest
, const uint32_t *requestTimeout
);
55 smartPortPayload_t
*smartPortDataReceive(uint16_t c
, bool *clearToSend
, smartPortCheckQueueEmptyFn
*checkQueueEmpty
, bool withChecksum
);
58 void smartPortWriteFrameSerial(const smartPortPayload_t
*payload
, struct serialPort_s
*port
, uint16_t checksum
);
59 void smartPortSendByte(uint8_t c
, uint16_t *checksum
, struct serialPort_s
*port
);
60 bool smartPortPayloadContainsMSP(const smartPortPayload_t
*payload
);