1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-18 05:45:31 +03:00

Fixed RX / telemetry port sharing for iBus.

This commit is contained in:
mikeller 2019-10-06 18:20:55 +13:00
parent c6452a55cc
commit 4ef9743d1b
17 changed files with 39 additions and 29 deletions

View file

@ -290,7 +290,7 @@ bool isSerialConfigValid(const serialConfig_t *serialConfigToCheck)
if ((portConfig->functionMask & FUNCTION_MSP) && (portConfig->functionMask & ALL_FUNCTIONS_SHARABLE_WITH_MSP)) { if ((portConfig->functionMask & FUNCTION_MSP) && (portConfig->functionMask & ALL_FUNCTIONS_SHARABLE_WITH_MSP)) {
// MSP & telemetry // MSP & telemetry
#ifdef USE_TELEMETRY #ifdef USE_TELEMETRY
} else if (telemetryCheckRxPortShared(portConfig)) { } else if (telemetryCheckRxPortShared(portConfig, rxConfig()->serialrx_provider)) {
// serial RX & telemetry // serial RX & telemetry
#endif #endif
} else { } else {

View file

@ -554,7 +554,7 @@ rx_spi_received_e frSkyXProcessFrame(uint8_t * const packet)
remoteToProcessIndex = 0; remoteToProcessIndex = 0;
telemetryRxBuffer[remoteToProcessId].needsProcessing = false; telemetryRxBuffer[remoteToProcessId].needsProcessing = false;
remoteProcessedId = remoteToProcessId; remoteProcessedId = remoteToProcessId;
remoteToProcessId = (remoteProcessedId + 1) % TELEMETRY_SEQUENCE_LENGTH; remoteToProcessId = (remoteToProcessId + 1) % TELEMETRY_SEQUENCE_LENGTH;
} }
} }
} }

View file

@ -220,7 +220,6 @@ bool ibusInit(const rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig)
} }
#ifdef USE_TELEMETRY #ifdef USE_TELEMETRY
// bool portShared = telemetryCheckRxPortShared(portConfig);
bool portShared = isSerialPortShared(portConfig, FUNCTION_RX_SERIAL, FUNCTION_TELEMETRY_IBUS); bool portShared = isSerialPortShared(portConfig, FUNCTION_RX_SERIAL, FUNCTION_TELEMETRY_IBUS);
#else #else
bool portShared = false; bool portShared = false;

View file

@ -181,7 +181,7 @@ bool sbusInit(const rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig)
} }
#ifdef USE_TELEMETRY #ifdef USE_TELEMETRY
bool portShared = telemetryCheckRxPortShared(portConfig); bool portShared = telemetryCheckRxPortShared(portConfig, rxRuntimeConfig->serialrxProvider);
#else #else
bool portShared = false; bool portShared = false;
#endif #endif

View file

@ -245,7 +245,7 @@ void spektrumBind(rxConfig_t *rxConfig)
switch (rxRuntimeConfig.serialrxProvider) { switch (rxRuntimeConfig.serialrxProvider) {
case SERIALRX_SRXL: case SERIALRX_SRXL:
#if defined(USE_TELEMETRY_SRXL) #if defined(USE_TELEMETRY_SRXL)
if (featureIsEnabled(FEATURE_TELEMETRY) && !telemetryCheckRxPortShared(portConfig)) { if (featureIsEnabled(FEATURE_TELEMETRY) && !telemetryCheckRxPortShared(portConfig, rxRuntimeConfig.serialrxProvider)) {
bindPin = txPin; bindPin = txPin;
} }
break; break;
@ -352,7 +352,7 @@ bool spektrumInit(const rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig
srxlEnabled = false; srxlEnabled = false;
#if defined(USE_TELEMETRY_SRXL) #if defined(USE_TELEMETRY_SRXL)
bool portShared = telemetryCheckRxPortShared(portConfig); bool portShared = telemetryCheckRxPortShared(portConfig, rxRuntimeConfig->serialrxProvider);
#else #else
bool portShared = false; bool portShared = false;
#endif #endif

View file

@ -170,7 +170,7 @@ bool sumdInit(const rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig)
} }
#ifdef USE_TELEMETRY #ifdef USE_TELEMETRY
bool portShared = telemetryCheckRxPortShared(portConfig); bool portShared = telemetryCheckRxPortShared(portConfig, rxRuntimeConfig->serialrxProvider);
#else #else
bool portShared = false; bool portShared = false;
#endif #endif

View file

@ -135,7 +135,7 @@ bool sumhInit(const rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig)
} }
#ifdef USE_TELEMETRY #ifdef USE_TELEMETRY
bool portShared = telemetryCheckRxPortShared(portConfig); bool portShared = telemetryCheckRxPortShared(portConfig, rxRuntimeConfig->serialrxProvider);
#else #else
bool portShared = false; bool portShared = false;
#endif #endif

View file

@ -303,7 +303,7 @@ bool xBusInit(const rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig)
} }
#ifdef USE_TELEMETRY #ifdef USE_TELEMETRY
bool portShared = telemetryCheckRxPortShared(portConfig); bool portShared = telemetryCheckRxPortShared(portConfig, rxRuntimeConfig->serialrxProvider);
#else #else
bool portShared = false; bool portShared = false;
#endif #endif

View file

@ -494,7 +494,7 @@ static void configureFrSkyHubTelemetryPort(void)
void checkFrSkyHubTelemetryState(void) void checkFrSkyHubTelemetryState(void)
{ {
if (telemetryState == TELEMETRY_STATE_INITIALIZED_SERIAL) { if (telemetryState == TELEMETRY_STATE_INITIALIZED_SERIAL) {
if (telemetryCheckRxPortShared(portConfig)) { if (telemetryCheckRxPortShared(portConfig, rxRuntimeConfig.serialrxProvider)) {
if (frSkyHubPort == NULL && telemetrySharedPort != NULL) { if (frSkyHubPort == NULL && telemetrySharedPort != NULL) {
frSkyHubPort = telemetrySharedPort; frSkyHubPort = telemetrySharedPort;
} }

View file

@ -289,7 +289,7 @@ void configureLtmTelemetryPort(void)
void checkLtmTelemetryState(void) void checkLtmTelemetryState(void)
{ {
if (portConfig && telemetryCheckRxPortShared(portConfig)) { if (portConfig && telemetryCheckRxPortShared(portConfig, rxRuntimeConfig.serialrxProvider)) {
if (!ltmEnabled && telemetrySharedPort != NULL) { if (!ltmEnabled && telemetrySharedPort != NULL) {
ltmPort = telemetrySharedPort; ltmPort = telemetrySharedPort;
ltmEnabled = true; ltmEnabled = true;

View file

@ -183,7 +183,7 @@ void configureMAVLinkTelemetryPort(void)
void checkMAVLinkTelemetryState(void) void checkMAVLinkTelemetryState(void)
{ {
if (portConfig && telemetryCheckRxPortShared(portConfig)) { if (portConfig && telemetryCheckRxPortShared(portConfig, rxRuntimeConfig.serialrxProvider)) {
if (!mavlinkTelemetryEnabled && telemetrySharedPort != NULL) { if (!mavlinkTelemetryEnabled && telemetrySharedPort != NULL) {
mavlinkPort = telemetrySharedPort; mavlinkPort = telemetrySharedPort;
mavlinkTelemetryEnabled = true; mavlinkTelemetryEnabled = true;

View file

@ -263,7 +263,6 @@ smartPortPayload_t *smartPortDataReceive(uint16_t c, bool *clearToSend, smartPor
checksum += c; checksum += c;
checksum = (checksum & 0xFF) + (checksum >> 8); checksum = (checksum & 0xFF) + (checksum >> 8);
if (checksum == 0xFF) { if (checksum == 0xFF) {
return (smartPortPayload_t *)&rxBuffer; return (smartPortPayload_t *)&rxBuffer;
} }
} }

View file

@ -133,24 +133,24 @@ bool telemetryDetermineEnabledState(portSharing_e portSharing)
return enabled; return enabled;
} }
bool telemetryCheckRxPortShared(const serialPortConfig_t *portConfig) bool telemetryCheckRxPortShared(const serialPortConfig_t *portConfig, const SerialRXType serialrxProvider)
{ {
if (portConfig->functionMask & FUNCTION_RX_SERIAL && portConfig->functionMask & TELEMETRY_SHAREABLE_PORT_FUNCTIONS_MASK && if (portConfig->functionMask & FUNCTION_RX_SERIAL && portConfig->functionMask & TELEMETRY_SHAREABLE_PORT_FUNCTIONS_MASK &&
(rxRuntimeConfig.serialrxProvider == SERIALRX_SPEKTRUM1024 || (serialrxProvider == SERIALRX_SPEKTRUM1024 ||
rxRuntimeConfig.serialrxProvider == SERIALRX_SPEKTRUM2048 || serialrxProvider == SERIALRX_SPEKTRUM2048 ||
rxRuntimeConfig.serialrxProvider == SERIALRX_SBUS || serialrxProvider == SERIALRX_SBUS ||
rxRuntimeConfig.serialrxProvider == SERIALRX_SUMD || serialrxProvider == SERIALRX_SUMD ||
rxRuntimeConfig.serialrxProvider == SERIALRX_SUMH || serialrxProvider == SERIALRX_SUMH ||
rxRuntimeConfig.serialrxProvider == SERIALRX_XBUS_MODE_B || serialrxProvider == SERIALRX_XBUS_MODE_B ||
rxRuntimeConfig.serialrxProvider == SERIALRX_XBUS_MODE_B_RJ01 || serialrxProvider == SERIALRX_XBUS_MODE_B_RJ01 ||
rxRuntimeConfig.serialrxProvider == SERIALRX_IBUS)) { serialrxProvider == SERIALRX_IBUS)) {
return true; return true;
} }
#ifdef USE_TELEMETRY_IBUS #ifdef USE_TELEMETRY_IBUS
if (portConfig->functionMask & FUNCTION_TELEMETRY_IBUS if (portConfig->functionMask & FUNCTION_TELEMETRY_IBUS
&& portConfig->functionMask & FUNCTION_RX_SERIAL && portConfig->functionMask & FUNCTION_RX_SERIAL
&& rxRuntimeConfig.serialrxProvider == SERIALRX_IBUS) { && serialrxProvider == SERIALRX_IBUS) {
// IBUS serial RX & telemetry // IBUS serial RX & telemetry
return true; return true;
} }

View file

@ -27,8 +27,12 @@
#pragma once #pragma once
#include "pg/pg.h"
#include "io/serial.h" #include "io/serial.h"
#include "pg/pg.h"
#include "rx/rx.h"
#include "telemetry/ibus_shared.h" #include "telemetry/ibus_shared.h"
typedef enum { typedef enum {
@ -90,7 +94,7 @@ PG_DECLARE(telemetryConfig_t, telemetryConfig);
extern serialPort_t *telemetrySharedPort; extern serialPort_t *telemetrySharedPort;
void telemetryInit(void); void telemetryInit(void);
bool telemetryCheckRxPortShared(const serialPortConfig_t *portConfig); bool telemetryCheckRxPortShared(const serialPortConfig_t *portConfig, const SerialRXType serialrxProvider);
void telemetryCheckState(void); void telemetryCheckState(void);
void telemetryProcess(uint32_t currentTime); void telemetryProcess(uint32_t currentTime);

View file

@ -29,7 +29,13 @@ extern "C" {
#include "io/serial.h" #include "io/serial.h"
#include "pg/pg.h"
#include "pg/pg_ids.h"
#include "pg/rx.h"
void serialInit(bool softserialEnabled, serialPortIdentifier_e serialPortToDisable); void serialInit(bool softserialEnabled, serialPortIdentifier_e serialPortToDisable);
PG_REGISTER(rxConfig_t, rxConfig, PG_RX_CONFIG, 0);
} }
#include "unittest_macros.h" #include "unittest_macros.h"

View file

@ -46,10 +46,12 @@ extern "C" {
} }
bool telemetryCheckRxPortShared(const serialPortConfig_t *portConfig) bool telemetryCheckRxPortShared(const serialPortConfig_t *portConfig, const SerialRXType serialrxProvider)
{ {
//TODO: implement //TODO: implement
(void) portConfig; UNUSED(portConfig);
UNUSED(serialrxProvider);
return false; return false;
} }

View file

@ -329,7 +329,7 @@ bool isSerialTransmitBufferEmpty(const serialPort_t *) { return true; }
serialPortConfig_t *findSerialPortConfig(serialPortFunction_e) {return NULL;} serialPortConfig_t *findSerialPortConfig(serialPortFunction_e) {return NULL;}
bool telemetryDetermineEnabledState(portSharing_e) {return true;} bool telemetryDetermineEnabledState(portSharing_e) {return true;}
bool telemetryCheckRxPortShared(const serialPortConfig_t *) {return true;} bool telemetryCheckRxPortShared(const serialPortConfig_t *, SerialRXType) {return true;}
bool telemetryIsSensorEnabled(sensor_e) {return true;} bool telemetryIsSensorEnabled(sensor_e) {return true;}
portSharing_e determinePortSharing(const serialPortConfig_t *, serialPortFunction_e) {return PORTSHARING_NOT_SHARED;} portSharing_e determinePortSharing(const serialPortConfig_t *, serialPortFunction_e) {return PORTSHARING_NOT_SHARED;}