Merge pull request #1600 from blckmn/bf_rx_crsf_1
Removed need to check for serial port, or open it
This commit is contained in:
commit
c73ccda737
|
@ -237,4 +237,9 @@ bool crsfRxInit(const rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig)
|
||||||
|
|
||||||
return serialPort != NULL;
|
return serialPort != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool crsfRxIsActive(void)
|
||||||
|
{
|
||||||
|
return serialPort != NULL;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -81,3 +81,4 @@ void crsfRxSendTelemetryData(void);
|
||||||
struct rxConfig_s;
|
struct rxConfig_s;
|
||||||
struct rxRuntimeConfig_s;
|
struct rxRuntimeConfig_s;
|
||||||
bool crsfRxInit(const struct rxConfig_s *initialRxConfig, struct rxRuntimeConfig_s *rxRuntimeConfig);
|
bool crsfRxInit(const struct rxConfig_s *initialRxConfig, struct rxRuntimeConfig_s *rxRuntimeConfig);
|
||||||
|
bool crsfRxIsActive(void);
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#ifdef TELEMETRY
|
#ifdef TELEMETRY
|
||||||
|
|
||||||
|
#include "config/feature.h"
|
||||||
#include "build/version.h"
|
#include "build/version.h"
|
||||||
|
|
||||||
#if (FC_VERSION_MAJOR == 3) // not a very good way of finding out if this is betaflight or Cleanflight
|
#if (FC_VERSION_MAJOR == 3) // not a very good way of finding out if this is betaflight or Cleanflight
|
||||||
|
@ -350,15 +351,8 @@ static void processCrsf(void)
|
||||||
void initCrsfTelemetry(void)
|
void initCrsfTelemetry(void)
|
||||||
{
|
{
|
||||||
// check if there is a serial port open for CRSF telemetry (ie opened by the CRSF RX)
|
// check if there is a serial port open for CRSF telemetry (ie opened by the CRSF RX)
|
||||||
// if so, set CRSF telemetry enabled
|
// and feature is enabled, if so, set CRSF telemetry enabled
|
||||||
crsfTelemetryEnabled = false;
|
crsfTelemetryEnabled = crsfRxIsActive() && feature(FEATURE_TELEMETRY);
|
||||||
const serialPortConfig_t *serialPortConfig = findSerialPortConfig(FUNCTION_TELEMETRY_CRSF);
|
|
||||||
if (serialPortConfig) {
|
|
||||||
const serialPort_t *serialPort = openSerialPort(serialPortConfig->identifier, FUNCTION_TELEMETRY_CRSF, NULL, CRSF_BAUDRATE, CRSF_PORT_MODE, CRSF_PORT_OPTIONS);
|
|
||||||
if (serialPort) {
|
|
||||||
crsfTelemetryEnabled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool checkCrsfTelemetryState(void)
|
bool checkCrsfTelemetryState(void)
|
||||||
|
|
Loading…
Reference in New Issue