This commit is contained in:
Raphael Coeffic
2022-03-20 16:22:14 +01:00
parent da59fca1bc
commit 530d395204
66 changed files with 1267 additions and 1081 deletions
+1 -11
View File
@@ -293,17 +293,7 @@ void processCrossfireTelemetryData(uint8_t data, uint8_t module)
uint8_t * rxBuffer = getTelemetryRxBuffer(module);
uint8_t &rxBufferCount = getTelemetryRxBufferCount(module);
#if defined(AUX_SERIAL)
if (g_eeGeneral.auxSerialMode == UART_MODE_TELEMETRY_MIRROR) {
auxSerialPutc(data);
}
#endif
#if defined(AUX2_SERIAL)
if (g_eeGeneral.aux2SerialMode == UART_MODE_TELEMETRY_MIRROR) {
aux2SerialPutc(data);
}
#endif
telemetryMirrorSend(data);
if (rxBufferCount == 0 && data != RADIO_ADDRESS && data != UART_SYNC) {
TRACE("[XF] address 0x%02X error", data);
+1
View File
@@ -116,6 +116,7 @@ const uint8_t CROSSFIRE_FRAME_PERIODS[] = {
4,
4,
4,
4,
};
#if SPORT_MAX_BAUDRATE < 400000
// index 0 (115200) is the default 0 value
+1 -11
View File
@@ -24,17 +24,7 @@
void processFrskyTelemetryData(uint8_t data)
{
#if defined(AUX_SERIAL)
if (g_eeGeneral.auxSerialMode == UART_MODE_TELEMETRY_MIRROR) {
auxSerialPutc(data);
}
#endif
#if defined(AUX2_SERIAL)
if (g_eeGeneral.aux2SerialMode == UART_MODE_TELEMETRY_MIRROR) {
aux2SerialPutc(data);
}
#endif
telemetryMirrorSend(data);
if (pushFrskyTelemetryData(data)) {
if (IS_FRSKY_SPORT_PROTOCOL()) {
+1 -11
View File
@@ -322,17 +322,7 @@ void processGhostTelemetryFrame()
void processGhostTelemetryData(uint8_t data)
{
#if defined(AUX_SERIAL)
if (g_eeGeneral.auxSerialMode == UART_MODE_TELEMETRY_MIRROR) {
auxSerialPutc(data);
}
#endif
#if defined(AUX2_SERIAL)
if (g_eeGeneral.aux2SerialMode == UART_MODE_TELEMETRY_MIRROR) {
aux2SerialPutc(data);
}
#endif
telemetryMirrorSend(data);
if (telemetryRxBufferCount == 0 && data != GHST_ADDR_RADIO) {
TRACE("[GH] address 0x%02X error", data);
+3 -13
View File
@@ -257,7 +257,7 @@ static void processMultiSyncPacket(const uint8_t * data, uint8_t module)
status.update(refreshRate, inputLag);
#if defined(DEBUG)
serialPrint("MP ADJ: R %d, L %04d", refreshRate, inputLag);
dbgSerialPrint("MP ADJ: R %d, L %04d", refreshRate, inputLag);
#endif
}
@@ -351,18 +351,8 @@ static void processMultiTelemetryPaket(const uint8_t * packet, uint8_t module)
uint8_t len = packet[1];
const uint8_t * data = packet + 2;
#if defined(AUX_SERIAL)
if (g_eeGeneral.auxSerialMode == UART_MODE_TELEMETRY_MIRROR) {
for (uint8_t c = 0; c < len + 2; c++)
auxSerialPutc(packet[c]);
}
#endif
#if defined(AUX2_SERIAL)
if (g_eeGeneral.aux2SerialMode == UART_MODE_TELEMETRY_MIRROR) {
for (uint8_t c = 0; c < len + 2; c++)
aux2SerialPutc(packet[c]);
}
#endif
for (uint8_t c = 0; c < len + 2; c++)
telemetryMirrorSend(packet[c]);
// Switch type
switch (type) {
+46 -3
View File
@@ -42,8 +42,8 @@ TelemetryData telemetryData;
uint8_t telemetryProtocol = 255;
#if defined(INTERNAL_MODULE_SERIAL_TELEMETRY)
uint8_t intTelemetryRxBuffer[TELEMETRY_RX_PACKET_SIZE];
uint8_t intTelemetryRxBufferCount;
static uint8_t intTelemetryRxBuffer[TELEMETRY_RX_PACKET_SIZE];
static uint8_t intTelemetryRxBufferCount;
#endif
uint8_t * getTelemetryRxBuffer(uint8_t moduleIdx)
@@ -64,6 +64,48 @@ uint8_t &getTelemetryRxBufferCount(uint8_t moduleIdx)
return telemetryRxBufferCount;
}
static int (*_telemetryGetByte)(void*, uint8_t*) = nullptr;
static void* _telemetryGetByteCtx = nullptr;
void telemetrySetGetByte(void* ctx, int (*fct)(void*, uint8_t*))
{
_telemetryGetByte = nullptr;
_telemetryGetByteCtx = ctx;
_telemetryGetByte = fct;
}
static bool telemetryGetByte(uint8_t* data)
{
auto _getByte = _telemetryGetByte;
auto _ctx = _telemetryGetByteCtx;
if (_getByte) {
return _getByte(_ctx, data);
}
return sportGetByte(data);
}
static void (*telemetryMirrorSendByte)(void*, uint8_t) = nullptr;
static void* telemetryMirrorSendByteCtx = nullptr;
void telemetrySetMirrorCb(void* ctx, void (*fct)(void*, uint8_t))
{
telemetryMirrorSendByte = nullptr;
telemetryMirrorSendByteCtx = ctx;
telemetryMirrorSendByte = fct;
}
void telemetryMirrorSend(uint8_t data)
{
auto _sendByte = telemetryMirrorSendByte;
auto _ctx = telemetryMirrorSendByteCtx;
if (_sendByte) {
_sendByte(_ctx, data);
}
}
void processTelemetryData(uint8_t data)
{
#if defined(CROSSFIRE)
@@ -427,7 +469,8 @@ void telemetryInit(uint8_t protocol)
#if defined(AUX_SERIAL)
else if (protocol == PROTOCOL_TELEMETRY_FRSKY_D_SECONDARY) {
telemetryPortInit(0, TELEMETRY_SERIAL_DEFAULT);
auxSerialTelemetryInit(PROTOCOL_TELEMETRY_FRSKY_D_SECONDARY);
// Note: this is done in initSerialPorts()
//auxSerialTelemetryInit(PROTOCOL_TELEMETRY_FRSKY_D_SECONDARY);
}
#endif
+8 -1
View File
@@ -75,10 +75,17 @@ constexpr uint8_t TELEMETRY_TIMEOUT10ms = 100; // 1 second
extern uint8_t telemetryRxBuffer[TELEMETRY_RX_PACKET_SIZE];
extern uint8_t telemetryRxBufferCount;
//TODO: use module scoped buffers instead
uint8_t* getTelemetryRxBuffer(uint8_t moduleIdx);
uint8_t& getTelemetryRxBufferCount(uint8_t moduleIdx);
// Set alternative telemetry input
void telemetrySetGetByte(void* ctx, int (*fct)(void*, uint8_t*));
// Set telemetry mirror callback
void telemetrySetMirrorCb(void* ctx, void (*fct)(void*, uint8_t));
// Mirror telemetry byte
void telemetryMirrorSend(uint8_t data);
#define TELEMETRY_AVERAGE_COUNT 3