11 #define UNUSED(x) (void)(x)
19 #define FSSP_DATAID_DOWNLINK 0x5015
20 #define FSSP_DATAID_UPLINK 0x5016
157 FSSP_DATAID_ACCX = 0x0700 ,
158 FSSP_DATAID_ACCY = 0x0710 ,
159 FSSP_DATAID_ACCZ = 0x0720 ,
181 #define MAX_DATAIDS 18
241 static uint8_t smartPortRxBytes = 0;
242 static bool skipUntilStart =
true;
243 static bool awaitingSensorId =
false;
244 static bool byteStuffing =
false;
248 *clearToSend =
false;
249 smartPortRxBytes = 0;
250 awaitingSensorId =
true;
251 skipUntilStart =
false;
254 }
else if (skipUntilStart) {
258 if (awaitingSensorId) {
259 awaitingSensorId =
false;
263 skipUntilStart =
true;
267 skipUntilStart =
true;
274 }
else if (byteStuffing) {
276 byteStuffing =
false;
280 rxBuffer[smartPortRxBytes++] = (
uint8_t)c;
284 skipUntilStart =
true;
289 skipUntilStart =
true;
347 #define ADD_SENSOR(dataId) frSkyDataIdTableInfo.table[frSkyDataIdTableInfo.index++] = dataId
348 #define ADD_ESC_SENSOR(dataId) frSkyEscDataIdTableInfo.table[frSkyEscDataIdTableInfo.index++] = dataId
359 #if defined(USE_ADC_INTERNAL)
366 #ifdef USE_ESC_SENSOR_TELEMETRY
377 #ifdef USE_ESC_SENSOR_TELEMETRY
439 #ifdef USE_ESC_SENSOR_TELEMETRY
440 frSkyEscDataIdTableInfo.index = 0;
455 frSkyEscDataIdTableInfo.size = frSkyEscDataIdTableInfo.index;
456 frSkyEscDataIdTableInfo.index = 0;
535 static uint8_t smartPortIdCycleCnt = 0;
538 static uint8_t skipRequests = 0;
539 #ifdef USE_ESC_SENSOR_TELEMETRY
540 static uint8_t smartPortIdOffset = 0;
543 #if defined(USE_MSP_OVER_TELEMETRY)
546 }
else if (payload && smartPortPayloadContainsMSP(payload)) {
551 smartPortMspReplyPending = handleMspFrame(frameStart, SMARTPORT_MSP_PAYLOAD_SIZE, &skipRequests);
558 *clearToSend =
false;
570 while (doRun && *clearToSend && !skipRequests) {
572 if (requestTimeout) {
574 *clearToSend =
false;
582 #if defined(USE_MSP_OVER_TELEMETRY)
583 if (smartPortMspReplyPending) {
584 smartPortMspReplyPending = sendMspReply(SMARTPORT_MSP_PAYLOAD_SIZE, &smartPortSendMspResponse);
585 *clearToSend =
false;
594 #ifdef USE_ESC_SENSOR_TELEMETRY
595 if (smartPortIdCycleCnt >= ESC_SENSOR_PERIOD) {
597 tableInfo = &frSkyEscDataIdTableInfo;
598 if (tableInfo->
index == tableInfo->
size) {
599 tableInfo->
index = 0;
600 smartPortIdCycleCnt = 0;
602 if (smartPortIdOffset == getMotorCount() + 1) {
603 smartPortIdOffset = 0;
607 if (smartPortIdCycleCnt < ESC_SENSOR_PERIOD) {
611 if (tableInfo->
index == tableInfo->
size) {
612 tableInfo->
index = 0;
614 #ifdef USE_ESC_SENSOR_TELEMETRY
618 #ifdef USE_ESC_SENSOR_TELEMETRY
619 if (smartPortIdCycleCnt >= ESC_SENSOR_PERIOD) {
620 id += smartPortIdOffset;
623 smartPortIdCycleCnt++;
631 #ifdef USE_ESC_SENSOR_TELEMETRY
632 escSensorData_t *escData;
643 *clearToSend =
false;
645 #ifdef USE_ESC_SENSOR_TELEMETRY
655 if (escData != NULL) {
657 *clearToSend =
false;
663 *clearToSend =
false;
665 #ifdef USE_ESC_SENSOR_TELEMETRY
675 if (escData != NULL) {
677 *clearToSend =
false;
681 escData = getEscSensorData(ESC_SENSOR_COMBINED);
682 if (escData != NULL) {
684 *clearToSend =
false;
696 if (escData != NULL) {
698 *clearToSend =
false;
702 escData = getEscSensorData(ESC_SENSOR_COMBINED);
703 if (escData != NULL) {
705 *clearToSend =
false;
717 if (escData != NULL) {
719 *clearToSend =
false;
725 *clearToSend =
false;
729 *clearToSend =
false;
733 *clearToSend =
false;
737 *clearToSend =
false;
740 case FSSP_DATAID_ACCX :
742 *clearToSend =
false;
744 case FSSP_DATAID_ACCY :
746 *clearToSend =
false;
748 case FSSP_DATAID_ACCZ :
750 *clearToSend =
false;
761 tmpi = t1Cnt * 10000;
793 *clearToSend =
false;
799 uint16_t hdop = constrain(scaleRange(gpsSol.hdop, 100, 550, 9, 0), 0, 9) * 100;
800 smartPortSendPackage(
id, (STATE(GPS_FIX) ? 1000 : 0) + (STATE(GPS_FIX_HOME) ? 2000 : 0) + hdop + gpsSol.numSat);
801 *clearToSend =
false;
804 *clearToSend =
false;
836 *clearToSend =
false;
840 #if defined(USE_ADC_INTERNAL)
843 *clearToSend =
false;
848 if (STATE(GPS_FIX)) {
851 uint32_t tmpui = gpsSol.groundSpeed * 1944 / 100;
853 *clearToSend =
false;
857 if (STATE(GPS_FIX)) {
862 if (tableInfo->
index & 1) {
863 tmpui = abs(gpsSol.llh.lon);
864 tmpui = (tmpui + tmpui / 2) / 25 | 0x80000000;
865 if (gpsSol.llh.lon < 0) tmpui |= 0x40000000;
868 tmpui = abs(gpsSol.llh.lat);
869 tmpui = (tmpui + tmpui / 2) / 25;
870 if (gpsSol.llh.lat < 0) tmpui |= 0x40000000;
873 *clearToSend =
false;
877 if (STATE(GPS_FIX)) {
879 *clearToSend =
false;
883 if (STATE(GPS_FIX)) {
885 *clearToSend =
false;
893 *clearToSend =
false;
900 *clearToSend =
false;
struct pidProfile_s * currentPidProfile
controlRateConfig_t * currentControlRateProfile
#define isAmperageConfigured()
#define getEstimatedAltitudeCm()
#define featureIsEnabled(mask)
#define isBatteryVoltageConfigured()
#define isArmingDisabled()
#define getBatteryCellCount()
static timeDelta_t cmpTimeUs(timeUs_t a, timeUs_t b)
#define getBatteryVoltage()
#define getEstimatedVario()
const telemetryConfig_t * telemetryConfig(void)
bool telemetryIsSensorEnabled(sensor_e sensor)
static frSkyTableInfo_t frSkyDataIdTableInfo
bool initSmartPortTelemetryExternal(smartPortWriteFrameFn *smartPortWriteFrameExternal)
static uint16_t frSkyDataIdTable[MAX_DATAIDS]
smartPortPayload_t * smartPortDataReceive(uint16_t c, bool *clearToSend, smartPortCheckQueueEmptyFn *checkQueueEmpty, bool useChecksum)
#define ADD_ESC_SENSOR(dataId)
#define ADD_SENSOR(dataId)
smartPortUplinkFn * smartPortUplink
smartPortDownlinkFn * smartPortDownlink
#define FSSP_DATAID_DOWNLINK
#define FSSP_DATAID_UPLINK
@ TELEMETRY_STATE_INITIALIZED_SERIAL
@ TELEMETRY_STATE_UNINITIALIZED
@ TELEMETRY_STATE_INITIALIZED_EXTERNAL
static void smartPortSendPackage(uint16_t id, uint32_t val)
void processSmartPortTelemetry(smartPortPayload_t *payload, volatile bool *clearToSend, const timeUs_t *requestTimeout)
static uint8_t telemetryState
struct frSkyTableInfo_s frSkyTableInfo_t
static smartPortWriteFrameFn * smartPortWriteFrame
static void initSmartPortSensors(void)
void smartPortWriteFrameFn(const smartPortPayload_t *payload)
bool smartPortDownlinkFn(uint32_t *data)
struct smartPortPayload_s smartPortPayload_t
void smartPortUplinkFn(struct smartPortPayload_s *payload)
bool smartPortCheckQueueEmptyFn(void)
Common code for AP and FBW telemetry.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
int int32_t
Typedef defining 32 bit int type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.