Compilation fix
This commit is contained in:
@@ -29,6 +29,7 @@ uint8_t createCrossfireFrame(uint8_t * frame, int16_t * pulses, LuaTelemetryPack
|
|||||||
uint8_t * buf = frame;
|
uint8_t * buf = frame;
|
||||||
*buf++ = MODULE_ADDRESS;
|
*buf++ = MODULE_ADDRESS;
|
||||||
|
|
||||||
|
#if defined(LUA)
|
||||||
if (telemetryPacket->crossfire.command) {
|
if (telemetryPacket->crossfire.command) {
|
||||||
*buf++ = 2 + telemetryPacket->crossfire.length; // 1(ID) + telemetryPacket->crossfire.length + 1(CRC)
|
*buf++ = 2 + telemetryPacket->crossfire.length; // 1(ID) + telemetryPacket->crossfire.length + 1(CRC)
|
||||||
uint8_t * crc_start = buf;
|
uint8_t * crc_start = buf;
|
||||||
@@ -38,25 +39,25 @@ uint8_t createCrossfireFrame(uint8_t * frame, int16_t * pulses, LuaTelemetryPack
|
|||||||
}
|
}
|
||||||
*buf++ = crc8(crc_start, telemetryPacket->crossfire.length + 1);
|
*buf++ = crc8(crc_start, telemetryPacket->crossfire.length + 1);
|
||||||
telemetryPacket->crossfire.clear();
|
telemetryPacket->crossfire.clear();
|
||||||
|
return buf - frame;
|
||||||
}
|
}
|
||||||
else {
|
#endif
|
||||||
*buf++ = 24; // 1(ID) + 22 + 1(CRC)
|
|
||||||
uint8_t * crc_start = buf;
|
|
||||||
*buf++ = CHANNELS_ID;
|
|
||||||
uint32_t bits = 0;
|
|
||||||
uint8_t bitsavailable = 0;
|
|
||||||
for (int i=0; i<CROSSFIRE_CHANNELS_COUNT; i++) {
|
|
||||||
uint32_t val = limit(0, CROSSFIRE_CH_CENTER + (((pulses[i]) * 4) / 5), 2*CROSSFIRE_CH_CENTER);
|
|
||||||
bits |= val << bitsavailable;
|
|
||||||
bitsavailable += CROSSFIRE_CH_BITS;
|
|
||||||
while (bitsavailable >= 8) {
|
|
||||||
*buf++ = bits;
|
|
||||||
bits >>= 8;
|
|
||||||
bitsavailable -= 8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*buf++ = crc8(crc_start, 23);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
*buf++ = 24; // 1(ID) + 22 + 1(CRC)
|
||||||
|
uint8_t * crc_start = buf;
|
||||||
|
*buf++ = CHANNELS_ID;
|
||||||
|
uint32_t bits = 0;
|
||||||
|
uint8_t bitsavailable = 0;
|
||||||
|
for (int i=0; i<CROSSFIRE_CHANNELS_COUNT; i++) {
|
||||||
|
uint32_t val = limit(0, CROSSFIRE_CH_CENTER + (((pulses[i]) * 4) / 5), 2*CROSSFIRE_CH_CENTER);
|
||||||
|
bits |= val << bitsavailable;
|
||||||
|
bitsavailable += CROSSFIRE_CH_BITS;
|
||||||
|
while (bitsavailable >= 8) {
|
||||||
|
*buf++ = bits;
|
||||||
|
bits >>= 8;
|
||||||
|
bitsavailable -= 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*buf++ = crc8(crc_start, 23);
|
||||||
return buf - frame;
|
return buf - frame;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -181,7 +181,11 @@ void setupPulses(uint8_t port)
|
|||||||
case PROTO_CROSSFIRE:
|
case PROTO_CROSSFIRE:
|
||||||
if (telemetryProtocol == PROTOCOL_PULSES_CROSSFIRE && !init_needed) {
|
if (telemetryProtocol == PROTOCOL_PULSES_CROSSFIRE && !init_needed) {
|
||||||
uint8_t * crossfire = modulePulsesData[port].crossfire.pulses;
|
uint8_t * crossfire = modulePulsesData[port].crossfire.pulses;
|
||||||
|
#if defined(LUA)
|
||||||
uint8_t len = createCrossfireFrame(crossfire, &channelOutputs[g_model.moduleData[port].channelsStart], &luaOutputTelemetryPacket);
|
uint8_t len = createCrossfireFrame(crossfire, &channelOutputs[g_model.moduleData[port].channelsStart], &luaOutputTelemetryPacket);
|
||||||
|
#else
|
||||||
|
uint8_t len = createCrossfireFrame(crossfire, &channelOutputs[g_model.moduleData[port].channelsStart], NULL);
|
||||||
|
#endif
|
||||||
sportSendBuffer(crossfire, len);
|
sportSendBuffer(crossfire, len);
|
||||||
}
|
}
|
||||||
scheduleNextMixerCalculation(port, CROSSFIRE_FRAME_PERIOD);
|
scheduleNextMixerCalculation(port, CROSSFIRE_FRAME_PERIOD);
|
||||||
|
|||||||
@@ -524,6 +524,8 @@ struct LuaTelemetryPacket
|
|||||||
extern Fifo<LuaTelemetryPacket, 16> * luaInputTelemetryFifo;
|
extern Fifo<LuaTelemetryPacket, 16> * luaInputTelemetryFifo;
|
||||||
extern LuaTelemetryPacket luaOutputTelemetryPacket;
|
extern LuaTelemetryPacket luaOutputTelemetryPacket;
|
||||||
void sportSendLuaPacket(LuaTelemetryPacket & packet);
|
void sportSendLuaPacket(LuaTelemetryPacket & packet);
|
||||||
|
#else
|
||||||
|
#define LuaTelemetryPacket void
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // _FRSKY_H_
|
#endif // _FRSKY_H_
|
||||||
|
|||||||
Reference in New Issue
Block a user