Compilation fix

This commit is contained in:
Bertrand Songis
2016-06-12 13:41:50 +02:00
parent 4226b7c89b
commit 21075d5a4c
3 changed files with 25 additions and 18 deletions
+19 -18
View File
@@ -29,6 +29,7 @@ uint8_t createCrossfireFrame(uint8_t * frame, int16_t * pulses, LuaTelemetryPack
uint8_t * buf = frame;
*buf++ = MODULE_ADDRESS;
#if defined(LUA)
if (telemetryPacket->crossfire.command) {
*buf++ = 2 + telemetryPacket->crossfire.length; // 1(ID) + telemetryPacket->crossfire.length + 1(CRC)
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);
telemetryPacket->crossfire.clear();
return buf - frame;
}
else {
*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);
}
#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);
return buf - frame;
}
+4
View File
@@ -181,7 +181,11 @@ void setupPulses(uint8_t port)
case PROTO_CROSSFIRE:
if (telemetryProtocol == PROTOCOL_PULSES_CROSSFIRE && !init_needed) {
uint8_t * crossfire = modulePulsesData[port].crossfire.pulses;
#if defined(LUA)
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);
}
scheduleNextMixerCalculation(port, CROSSFIRE_FRAME_PERIOD);
+2
View File
@@ -524,6 +524,8 @@ struct LuaTelemetryPacket
extern Fifo<LuaTelemetryPacket, 16> * luaInputTelemetryFifo;
extern LuaTelemetryPacket luaOutputTelemetryPacket;
void sportSendLuaPacket(LuaTelemetryPacket & packet);
#else
#define LuaTelemetryPacket void
#endif
#endif // _FRSKY_H_