Compilation fixes
This commit is contained in:
@@ -122,6 +122,20 @@ uint8_t getRequiredProtocol(uint8_t port)
|
||||
return required_protocol;
|
||||
}
|
||||
|
||||
void setupPulsesPXX(uint8_t port)
|
||||
{
|
||||
#if defined(INTMODULE_USART) && defined(EXTMODULE_USART)
|
||||
modulePulsesData[port].pxx_uart.setupFrame(port);
|
||||
#elif !defined(INTMODULE_USART) && !defined(EXTMODULE_USART)
|
||||
modulePulsesData[port].pxx.setupFrame(port);
|
||||
#else
|
||||
if (IS_UART_MODULE(port))
|
||||
modulePulsesData[port].pxx_uart.setupFrame(port);
|
||||
else
|
||||
modulePulsesData[port].pxx.setupFrame(port);
|
||||
#endif
|
||||
}
|
||||
|
||||
void setupPulses(uint8_t port)
|
||||
{
|
||||
bool init_needed = false;
|
||||
@@ -177,7 +191,7 @@ void setupPulses(uint8_t port)
|
||||
// Set up output data here
|
||||
switch (required_protocol) {
|
||||
case PROTO_PXX:
|
||||
modulePulsesData[port].pxx.setupFrame(port);
|
||||
setupPulsesPXX(port);
|
||||
scheduleNextMixerCalculation(port, PXX_PERIOD);
|
||||
break;
|
||||
|
||||
|
||||
@@ -21,20 +21,15 @@
|
||||
#ifndef _PULSES_ARM_H_
|
||||
#define _PULSES_ARM_H_
|
||||
|
||||
#include "pulses/pxx2.h"
|
||||
#include "pulses/pxx1.h"
|
||||
|
||||
#if NUM_MODULES == 2
|
||||
#define MODULES_INIT(...) __VA_ARGS__, __VA_ARGS__
|
||||
#else
|
||||
#define MODULES_INIT(...) __VA_ARGS__
|
||||
#endif
|
||||
|
||||
#if defined(PCBX12S) && PCBREV < 13
|
||||
#define pulse_duration_t uint32_t
|
||||
#define trainer_pulse_duration_t uint16_t
|
||||
#else
|
||||
#define pulse_duration_t uint16_t
|
||||
#define trainer_pulse_duration_t uint16_t
|
||||
#endif
|
||||
|
||||
extern uint8_t s_current_protocol[NUM_MODULES];
|
||||
extern uint8_t s_pulses_paused;
|
||||
extern uint16_t failsafeCounter[NUM_MODULES];
|
||||
@@ -44,18 +39,6 @@ template<class T> struct PpmPulsesData {
|
||||
T * ptr;
|
||||
};
|
||||
|
||||
#if defined(PPM_PIN_SERIAL)
|
||||
PACK(struct PxxSerialPulsesData {
|
||||
uint8_t pulses[64];
|
||||
uint8_t * ptr;
|
||||
uint16_t pcmValue;
|
||||
uint16_t pcmCrc;
|
||||
uint32_t pcmOnesCount;
|
||||
uint16_t serialByte;
|
||||
uint16_t serialBitCount;
|
||||
});
|
||||
#endif
|
||||
|
||||
#if defined(PPM_PIN_SERIAL)
|
||||
PACK(struct Dsm2SerialPulsesData {
|
||||
uint8_t pulses[64];
|
||||
@@ -74,15 +57,6 @@ PACK(struct Dsm2TimerPulsesData {
|
||||
});
|
||||
#endif
|
||||
|
||||
#if defined(INTMODULE_USART) || defined(EXTMODULE_USART) || defined(PXX2)
|
||||
PACK(struct PxxUartPulsesData {
|
||||
uint8_t pulses[64];
|
||||
uint8_t * ptr;
|
||||
uint16_t pcmCrc;
|
||||
uint16_t _alignment;
|
||||
});
|
||||
#endif
|
||||
|
||||
#define PPM_PERIOD_HALF_US(module) ((g_model.moduleData[module].ppm.frameLength * 5 + 225) * 200) /*half us*/
|
||||
#define PPM_PERIOD(module) (PPM_PERIOD_HALF_US(module) / 2000) /*ms*/
|
||||
#define DSM2_BAUDRATE 125000
|
||||
@@ -93,48 +67,22 @@ PACK(struct PxxUartPulsesData {
|
||||
#define MULTIMODULE_BAUDRATE 100000
|
||||
#define MULTIMODULE_PERIOD 7 /*ms*/
|
||||
|
||||
#if !defined(INTMODULE_USART) || !defined(EXTMODULE_USART)
|
||||
/* PXX uses 20 bytes (as of Rev 1.1 document) with 8 changes per byte + stop bit ~= 162 max pulses */
|
||||
/* DSM2 uses 2 header + 12 channel bytes, with max 10 changes (8n2) per byte + 16 bits trailer ~= 156 max pulses */
|
||||
/* Multimodule uses 3 bytes header + 22 channel bytes with max 11 changes per byte (8e2) + 16 bits trailer ~= 291 max pulses */
|
||||
/* Multimodule reuses some of the DSM2 function and structs since the protocols are similar enough */
|
||||
/* sbus is 1 byte header, 22 channel bytes (11bit * 16ch) + 1 byte flags */
|
||||
|
||||
#if defined(PXX_FREQUENCY_HIGH)
|
||||
#error "Pulses array needs to be increased (PXX_FREQUENCY=HIGH)"
|
||||
#endif
|
||||
|
||||
PACK(struct PxxTimerPulsesData {
|
||||
pulse_duration_t pulses[200];
|
||||
pulse_duration_t * ptr;
|
||||
uint16_t rest;
|
||||
uint16_t pcmCrc;
|
||||
uint32_t pcmOnesCount;
|
||||
});
|
||||
#endif
|
||||
|
||||
#if !defined(BOOT)
|
||||
#include "pulses/pxx2.h"
|
||||
#include "pulses/pxx1.h"
|
||||
#endif
|
||||
|
||||
#define CROSSFIRE_FRAME_MAXLEN 64
|
||||
PACK(struct CrossfirePulsesData {
|
||||
uint8_t pulses[CROSSFIRE_FRAME_MAXLEN];
|
||||
});
|
||||
|
||||
union ModulePulsesData {
|
||||
#if defined(INTMODULE_USART) || defined(EXTMODULE_USART) && !defined(BOOT)
|
||||
#if defined(INTMODULE_USART) || defined(EXTMODULE_USART)
|
||||
UartPxxPulses pxx_uart;
|
||||
#endif
|
||||
#if defined(BOOT)
|
||||
#elif defined(PPM_PIN_SERIAL)
|
||||
#if defined(PPM_PIN_SERIAL)
|
||||
SerialPxxPulses pxx;
|
||||
#elif !defined(INTMODULE_USART) || !defined(EXTMODULE_USART)
|
||||
PwmPxxPulses pxx;
|
||||
#endif
|
||||
|
||||
#if defined(PXX2) && !defined(BOOT)
|
||||
#if defined(PXX2)
|
||||
Pxx2Pulses pxx2;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -178,4 +178,6 @@ void PxxPulses<PxxTransport>::addExtraFlags(uint8_t port)
|
||||
}
|
||||
|
||||
template class PxxPulses<StandardPxxTransport<PwmPxxBitTransport> >;
|
||||
template class PxxPulses<StandardPxxTransport<SerialPxxBitTransport> >;
|
||||
template class PxxPulses<Pxx2Transport>;
|
||||
template class PxxPulses<UartPxxTransport>;
|
||||
|
||||
+17
-4
@@ -37,6 +37,17 @@
|
||||
#define PXX_PERIOD 9/*ms*/
|
||||
#endif
|
||||
|
||||
#if defined(PXX_FREQUENCY_HIGH) && (!defined(INTMODULE_USART) || !defined(EXTMODULE_USART))
|
||||
/* PXX uses 20 bytes (as of Rev 1.1 document) with 8 changes per byte + stop bit ~= 162 max pulses */
|
||||
/* DSM2 uses 2 header + 12 channel bytes, with max 10 changes (8n2) per byte + 16 bits trailer ~= 156 max pulses */
|
||||
/* Multimodule uses 3 bytes header + 22 channel bytes with max 11 changes per byte (8e2) + 16 bits trailer ~= 291 max pulses */
|
||||
/* Multimodule reuses some of the DSM2 function and structs since the protocols are similar enough */
|
||||
/* sbus is 1 byte header, 22 channel bytes (11bit * 16ch) + 1 byte flags */
|
||||
|
||||
#error "Pulses array needs to be increased (PXX_FREQUENCY=HIGH)"
|
||||
#endif
|
||||
|
||||
|
||||
#define PXX_PERIOD_HALF_US (PXX_PERIOD * 2000)
|
||||
|
||||
class PxxCrcMixin {
|
||||
@@ -60,7 +71,6 @@ class SerialPxxBitTransport: public DataBuffer<uint8_t, 64> {
|
||||
protected:
|
||||
uint8_t byte;
|
||||
uint8_t bits_count;
|
||||
uint8_t padding[2];
|
||||
|
||||
void initFrame()
|
||||
{
|
||||
@@ -102,7 +112,6 @@ class SerialPxxBitTransport: public DataBuffer<uint8_t, 64> {
|
||||
class PwmPxxBitTransport: public PulsesBuffer<pulse_duration_t, 200> {
|
||||
protected:
|
||||
uint16_t rest;
|
||||
uint8_t padding[2];
|
||||
|
||||
void initFrame()
|
||||
{
|
||||
@@ -125,10 +134,9 @@ class PwmPxxBitTransport: public PulsesBuffer<pulse_duration_t, 200> {
|
||||
};
|
||||
|
||||
template <class BitTransport>
|
||||
class StandardPxxTransport: public PxxCrcMixin, public BitTransport {
|
||||
class StandardPxxTransport: public BitTransport, public PxxCrcMixin {
|
||||
protected:
|
||||
uint8_t ones_count;
|
||||
uint8_t padding[3];
|
||||
|
||||
void initFrame()
|
||||
{
|
||||
@@ -174,6 +182,11 @@ class UartPxxTransport: public DataBuffer<uint8_t, 64>, public PxxCrcMixin {
|
||||
addWithByteStuffing(byte);
|
||||
}
|
||||
|
||||
void addByteWithoutCrc(uint8_t byte)
|
||||
{
|
||||
*ptr++ = byte;
|
||||
}
|
||||
|
||||
void addWithByteStuffing(uint8_t byte)
|
||||
{
|
||||
if (0x7E == byte) {
|
||||
|
||||
@@ -57,7 +57,7 @@ void Pxx1Pulses<PxxTransport>::add8ChannelsFrame(uint8_t port, uint8_t sendUpper
|
||||
template <class PxxTransport>
|
||||
void Pxx1Pulses<PxxTransport>::setupFrame(uint8_t port)
|
||||
{
|
||||
PxxPulses<PxxTransport>::initFrame();
|
||||
PxxTransport::initBuffer();
|
||||
|
||||
#if defined(PXX_FREQUENCY_HIGH)
|
||||
add8ChannelsFrame(port, 0);
|
||||
@@ -75,3 +75,5 @@ void Pxx1Pulses<PxxTransport>::setupFrame(uint8_t port)
|
||||
}
|
||||
|
||||
template class Pxx1Pulses<StandardPxxTransport<PwmPxxBitTransport> >;
|
||||
template class Pxx1Pulses<StandardPxxTransport<SerialPxxBitTransport> >;
|
||||
template class Pxx1Pulses<UartPxxTransport>;
|
||||
|
||||
@@ -47,7 +47,7 @@ class Pxx2Pulses: public PxxPulses<Pxx2Transport> {
|
||||
|
||||
void initFrame()
|
||||
{
|
||||
ptr = data;
|
||||
Pxx2Transport::initBuffer();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user