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;