mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-25 17:25:20 +03:00
Remove telemetry_*.c's dependency on mw.h/board.h.
Finally, the only dependency on mw.h/board.h is now mw.c itself.
This commit is contained in:
parent
7af9ca4fdc
commit
cb63f6e2b5
10 changed files with 96 additions and 34 deletions
|
@ -1,9 +1,16 @@
|
|||
#include "board.h"
|
||||
#include "mw.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
#include "drivers/timer_common.h"
|
||||
#include "drivers/serial_common.h"
|
||||
#include "drivers/serial_softserial.h"
|
||||
#include "serial_common.h"
|
||||
|
||||
#include "runtime_config.h"
|
||||
#include "config.h"
|
||||
|
||||
#include "telemetry_frsky.h"
|
||||
#include "telemetry_hott.h"
|
||||
|
||||
|
@ -11,14 +18,21 @@
|
|||
|
||||
static bool isTelemetryConfigurationValid = false; // flag used to avoid repeated configuration checks
|
||||
|
||||
telemetryConfig_t *telemetryConfig;
|
||||
|
||||
void useTelemetryConfig(telemetryConfig_t *telemetryConfigToUse)
|
||||
{
|
||||
telemetryConfig = telemetryConfigToUse;
|
||||
}
|
||||
|
||||
bool isTelemetryProviderFrSky(void)
|
||||
{
|
||||
return masterConfig.telemetry_provider == TELEMETRY_PROVIDER_FRSKY;
|
||||
return telemetryConfig->telemetry_provider == TELEMETRY_PROVIDER_FRSKY;
|
||||
}
|
||||
|
||||
bool isTelemetryProviderHoTT(void)
|
||||
{
|
||||
return masterConfig.telemetry_provider == TELEMETRY_PROVIDER_HOTT;
|
||||
return telemetryConfig->telemetry_provider == TELEMETRY_PROVIDER_HOTT;
|
||||
}
|
||||
|
||||
bool canUseTelemetryWithCurrentConfiguration(void)
|
||||
|
@ -28,14 +42,14 @@ bool canUseTelemetryWithCurrentConfiguration(void)
|
|||
}
|
||||
|
||||
if (!feature(FEATURE_SOFTSERIAL)) {
|
||||
if (masterConfig.telemetry_port == TELEMETRY_PORT_SOFTSERIAL_1 || masterConfig.telemetry_port == TELEMETRY_PORT_SOFTSERIAL_2) {
|
||||
if (telemetryConfig->telemetry_port == TELEMETRY_PORT_SOFTSERIAL_1 || telemetryConfig->telemetry_port == TELEMETRY_PORT_SOFTSERIAL_2) {
|
||||
// softserial feature must be enabled to use telemetry on softserial ports
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (isTelemetryProviderHoTT()) {
|
||||
if (masterConfig.telemetry_port == TELEMETRY_PORT_UART) {
|
||||
if (telemetryConfig->telemetry_port == TELEMETRY_PORT_UART) {
|
||||
// HoTT requires a serial port that supports RX/TX mode swapping
|
||||
return false;
|
||||
}
|
||||
|
@ -48,20 +62,20 @@ void initTelemetry(serialPorts_t *serialPorts)
|
|||
{
|
||||
// Force telemetry to uart when softserial disabled
|
||||
if (!feature(FEATURE_SOFTSERIAL))
|
||||
masterConfig.telemetry_port = TELEMETRY_PORT_UART;
|
||||
telemetryConfig->telemetry_port = TELEMETRY_PORT_UART;
|
||||
|
||||
#ifdef FY90Q
|
||||
// FY90Q does not support softserial
|
||||
masterConfig.telemetry_port = TELEMETRY_PORT_UART;
|
||||
telemetryConfig->telemetry_port = TELEMETRY_PORT_UART;
|
||||
serialPorts->telemport = serialPorts->mainport;
|
||||
#endif
|
||||
|
||||
isTelemetryConfigurationValid = canUseTelemetryWithCurrentConfiguration();
|
||||
|
||||
#ifndef FY90Q
|
||||
if (masterConfig.telemetry_port == TELEMETRY_PORT_SOFTSERIAL_1)
|
||||
if (telemetryConfig->telemetry_port == TELEMETRY_PORT_SOFTSERIAL_1)
|
||||
serialPorts->telemport = &(softSerialPorts[0].port);
|
||||
else if (masterConfig.telemetry_port == TELEMETRY_PORT_SOFTSERIAL_2)
|
||||
else if (telemetryConfig->telemetry_port == TELEMETRY_PORT_SOFTSERIAL_2)
|
||||
serialPorts->telemport = &(softSerialPorts[1].port);
|
||||
else
|
||||
serialPorts->telemport = serialPorts->mainport;
|
||||
|
@ -76,8 +90,8 @@ bool determineNewTelemetryEnabledState(void)
|
|||
{
|
||||
bool enabled = true;
|
||||
|
||||
if (masterConfig.telemetry_port == TELEMETRY_PORT_UART) {
|
||||
if (!masterConfig.telemetry_switch)
|
||||
if (telemetryConfig->telemetry_port == TELEMETRY_PORT_UART) {
|
||||
if (!telemetryConfig->telemetry_switch)
|
||||
enabled = f.ARMED;
|
||||
else
|
||||
enabled = rcOptions[BOXTELEMETRY];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue