[Crossfire] Upstream link development started
This commit is contained in:
@@ -192,6 +192,21 @@ void processCrossfireTelemetryFrame()
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
#if defined(LUA)
|
||||
default:
|
||||
if (luaInputTelemetryFifo) {
|
||||
LuaTelemetryPacket luaPacket;
|
||||
luaPacket.crossfire.command = id;
|
||||
luaPacket.crossfire.length = telemetryRxBuffer[1]-2;
|
||||
for (int i=0; i<min<int>(sizeof(luaPacket.crossfire.data), luaPacket.crossfire.length); i++) {
|
||||
luaPacket.crossfire.data[i] = telemetryRxBuffer[3+i];
|
||||
}
|
||||
luaInputTelemetryFifo->push(luaPacket);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
// Device address
|
||||
#define BROADCAST_ADDRESS 0x00
|
||||
#define MODULE_ADDRESS 0xEE
|
||||
|
||||
// Frame id
|
||||
#define GPS_ID 0x02
|
||||
@@ -31,6 +32,9 @@
|
||||
#define CHANNELS_ID 0x16
|
||||
#define ATTITUDE_ID 0x1E
|
||||
#define FLIGHT_MODE_ID 0x21
|
||||
#define PING_DEVICES_ID 0x28
|
||||
#define DEVICE_INFO_ID 0x29
|
||||
#define REQUEST_SETTINGS_ID 0x2A
|
||||
|
||||
void processCrossfireTelemetryData(uint8_t data);
|
||||
void crossfireSetDefault(int index, uint8_t id, uint8_t subId);
|
||||
|
||||
+32
-21
@@ -422,7 +422,7 @@ void frskyDProcessPacket(uint8_t *packet);
|
||||
void processSportPacket(uint8_t * packet);
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
void sportFirmwareUpdate(ModuleIndex module, const char *filename);
|
||||
void sportFirmwareUpdate(ModuleIndex module, const char * filename);
|
||||
#endif
|
||||
void telemetryWakeup();
|
||||
void telemetryReset();
|
||||
@@ -487,27 +487,38 @@ void processFrskyTelemetryData(uint8_t data);
|
||||
#if defined(LUA)
|
||||
struct LuaTelemetryPacket
|
||||
{
|
||||
LuaTelemetryPacket() { };
|
||||
LuaTelemetryPacket(uint8_t physicalId, uint8_t primId, uint16_t dataId, uint32_t value):
|
||||
physicalId(physicalId),
|
||||
primId(primId),
|
||||
dataId(dataId),
|
||||
value(value)
|
||||
{
|
||||
}
|
||||
LuaTelemetryPacket()
|
||||
{
|
||||
}
|
||||
|
||||
PACK(struct {
|
||||
uint8_t physicalId;
|
||||
union {
|
||||
PACK(struct {
|
||||
uint8_t primId;
|
||||
uint16_t dataId;
|
||||
uint32_t value;
|
||||
uint8_t crc;
|
||||
});
|
||||
uint8_t raw[8];
|
||||
};
|
||||
});
|
||||
union {
|
||||
struct {
|
||||
uint8_t physicalId;
|
||||
union {
|
||||
struct {
|
||||
uint8_t primId;
|
||||
uint16_t dataId;
|
||||
uint32_t value;
|
||||
uint8_t crc;
|
||||
};
|
||||
uint8_t raw[8];
|
||||
};
|
||||
void clear()
|
||||
{
|
||||
physicalId = 0x7E;
|
||||
}
|
||||
} sport;
|
||||
|
||||
struct {
|
||||
uint8_t command;
|
||||
uint8_t length;
|
||||
uint8_t data[8];
|
||||
void clear()
|
||||
{
|
||||
command = 0x00;
|
||||
}
|
||||
} crossfire;
|
||||
};
|
||||
};
|
||||
|
||||
extern Fifo<LuaTelemetryPacket, 16> * luaInputTelemetryFifo;
|
||||
|
||||
@@ -201,14 +201,14 @@ void sportSendLuaPacket(LuaTelemetryPacket & packet)
|
||||
|
||||
uint16_t crc = 0;
|
||||
for (uint8_t i=0; i<7; i++) {
|
||||
if (packet.raw[i] == 0x7E || packet.raw[i] == 0x7D) {
|
||||
if (packet.sport.raw[i] == 0x7E || packet.sport.raw[i] == 0x7D) {
|
||||
*ptr++ = 0x7D;
|
||||
*ptr++ = 0x20 ^ packet.raw[i];
|
||||
*ptr++ = 0x20 ^ packet.sport.raw[i];
|
||||
}
|
||||
else {
|
||||
*ptr++ = packet.raw[i];
|
||||
*ptr++ = packet.sport.raw[i];
|
||||
}
|
||||
crc += packet.raw[i]; //0-1FF
|
||||
crc += packet.sport.raw[i]; //0-1FF
|
||||
crc += crc >> 8; //0-100
|
||||
crc &= 0x00ff;
|
||||
}
|
||||
@@ -313,7 +313,12 @@ void processSportPacket(uint8_t * packet)
|
||||
else if (id >= DIY_FIRST_ID && id <= DIY_LAST_ID) {
|
||||
#if defined(LUA)
|
||||
if (luaInputTelemetryFifo) {
|
||||
luaInputTelemetryFifo->push(LuaTelemetryPacket(physicalId, primId, id, data));
|
||||
LuaTelemetryPacket luaPacket;
|
||||
luaPacket.sport.physicalId = physicalId;
|
||||
luaPacket.sport.primId = primId;
|
||||
luaPacket.sport.dataId = id;
|
||||
luaPacket.sport.value = data;
|
||||
luaInputTelemetryFifo->push(luaPacket);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -326,7 +331,12 @@ void processSportPacket(uint8_t * packet)
|
||||
#if defined(LUA)
|
||||
else if (primId == 0x32) {
|
||||
if (luaInputTelemetryFifo) {
|
||||
luaInputTelemetryFifo->push(LuaTelemetryPacket(physicalId, primId, id, data));
|
||||
LuaTelemetryPacket luaPacket;
|
||||
luaPacket.sport.physicalId = physicalId;
|
||||
luaPacket.sport.primId = primId;
|
||||
luaPacket.sport.dataId = id;
|
||||
luaPacket.sport.value = data;
|
||||
luaInputTelemetryFifo->push(luaPacket);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -543,7 +553,7 @@ bool sportUpdateEnd()
|
||||
return sportWaitState(SPORT_COMPLETE, 2000);
|
||||
}
|
||||
|
||||
void sportFirmwareUpdate(ModuleIndex module, const char *filename)
|
||||
void sportFirmwareUpdate(ModuleIndex module, const char * filename)
|
||||
{
|
||||
bool result = sportUpdatePowerOn(module);
|
||||
if (result)
|
||||
|
||||
@@ -421,6 +421,7 @@ void telemetryInit(uint8_t protocol)
|
||||
#if defined(CROSSFIRE)
|
||||
else if (protocol == PROTOCOL_PULSES_CROSSFIRE) {
|
||||
telemetryPortInit(CROSSFIRE_BAUDRATE);
|
||||
luaOutputTelemetryPacket.crossfire.clear();
|
||||
telemetryPortSetDirectionOutput();
|
||||
}
|
||||
#endif
|
||||
@@ -430,6 +431,7 @@ void telemetryInit(uint8_t protocol)
|
||||
}
|
||||
else {
|
||||
telemetryPortInit(FRSKY_SPORT_BAUDRATE);
|
||||
luaOutputTelemetryPacket.sport.clear();
|
||||
}
|
||||
|
||||
#if defined(REVX) && !defined(SIMU)
|
||||
@@ -455,5 +457,5 @@ NOINLINE uint8_t getRssiAlarmValue(uint8_t alarm)
|
||||
|
||||
#if defined(LUA)
|
||||
Fifo<LuaTelemetryPacket, 16> * luaInputTelemetryFifo = NULL;
|
||||
LuaTelemetryPacket luaOutputTelemetryPacket = { 0x7E, 0x0, 0x0, 0x0 };
|
||||
LuaTelemetryPacket luaOutputTelemetryPacket;
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user