[X-Lite] Next round of changes (#5847)
* [X-Lite] PXX is now sent every 4ms * New option PXX_FREQUENCY (HIGH / LOW) * [X-Lite] It now sends 16 channels per 4ms
This commit is contained in:
@@ -85,6 +85,10 @@ void uartPutPcmByte(uint8_t port, uint8_t byte)
|
||||
void uartInitPcmArray(uint8_t port)
|
||||
{
|
||||
modulePulsesData[port].pxx_uart.ptr = modulePulsesData[port].pxx_uart.pulses;
|
||||
}
|
||||
|
||||
void uartInitPcmCrc(uint8_t port)
|
||||
{
|
||||
modulePulsesData[port].pxx_uart.pcmCrc = 0;
|
||||
}
|
||||
|
||||
@@ -159,7 +163,6 @@ void pxxPutPcmBit(uint8_t port, uint8_t bit)
|
||||
pxxPutPcmPart(port, 0);
|
||||
modulePulsesData[port].pxx.pcmOnesCount = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void pxxPutPcmByte(uint8_t port, uint8_t byte)
|
||||
@@ -179,10 +182,15 @@ void pxxInitPcmArray(uint8_t port)
|
||||
#else
|
||||
modulePulsesData[port].pxx.rest = 18000;
|
||||
#endif
|
||||
modulePulsesData[port].pxx.pcmCrc = 0;
|
||||
|
||||
modulePulsesData[port].pxx.pcmOnesCount = 0;
|
||||
}
|
||||
|
||||
void pxxInitPcmCrc(uint8_t port)
|
||||
{
|
||||
modulePulsesData[port].pxx.pcmCrc = 0;
|
||||
}
|
||||
|
||||
void pxxPutPcmHead(uint8_t port)
|
||||
{
|
||||
// send 7E, do not CRC
|
||||
@@ -213,6 +221,14 @@ inline void initPcmArray(uint8_t port)
|
||||
pxxInitPcmArray(port);
|
||||
}
|
||||
|
||||
inline void initPcmCrc(uint8_t port)
|
||||
{
|
||||
if (IS_UART_MODULE(port))
|
||||
uartInitPcmCrc(port);
|
||||
else
|
||||
pxxInitPcmCrc(port);
|
||||
}
|
||||
|
||||
inline void putPcmHead(uint8_t port)
|
||||
{
|
||||
if (IS_UART_MODULE(port))
|
||||
@@ -248,6 +264,11 @@ inline void initPcmArray(uint8_t port)
|
||||
pxxInitPcmArray(port);
|
||||
}
|
||||
|
||||
inline void initPcmCrc(uint8_t port)
|
||||
{
|
||||
pxxInitPcmCrc(port);
|
||||
}
|
||||
|
||||
inline void putPcmHead(uint8_t port)
|
||||
{
|
||||
pxxPutPcmHead(port);
|
||||
@@ -269,11 +290,11 @@ inline void putPcmTail(uint8_t port)
|
||||
}
|
||||
#endif
|
||||
|
||||
void setupPulsesPXX(uint8_t port)
|
||||
inline void setupFramePXX(uint8_t port, uint8_t sendUpperChannels)
|
||||
{
|
||||
uint16_t pulseValue=0, pulseValueLow=0;
|
||||
|
||||
initPcmArray(port);
|
||||
initPcmCrc(port);
|
||||
|
||||
/* Sync */
|
||||
putPcmHead(port);
|
||||
@@ -304,12 +325,7 @@ void setupPulsesPXX(uint8_t port)
|
||||
/* FLAG2 */
|
||||
putPcmByte(port, 0);
|
||||
|
||||
/* PPM */
|
||||
static uint8_t pass[NUM_MODULES] = { MODULES_INIT(0) };
|
||||
int sendUpperChannels = 0;
|
||||
if (pass[port]++ & 0x01) {
|
||||
sendUpperChannels = g_model.moduleData[port].channelsCount;
|
||||
}
|
||||
/* CHANNELS */
|
||||
for (int i=0; i<8; i++) {
|
||||
if (flag1 & PXX_SEND_FAILSAFE) {
|
||||
if (g_model.moduleData[port].failsafeMode == FAILSAFE_HOLD) {
|
||||
@@ -405,3 +421,22 @@ void setupPulsesPXX(uint8_t port)
|
||||
|
||||
putPcmTail(port);
|
||||
}
|
||||
|
||||
void setupPulsesPXX(uint8_t port)
|
||||
{
|
||||
initPcmArray(port);
|
||||
|
||||
#if defined(PXX_FREQUENCY_HIGH)
|
||||
setupFramePXX(port, 0);
|
||||
if (NUM_CHANNELS(port) > 8) {
|
||||
setupFramePXX(port, 8);
|
||||
}
|
||||
#else
|
||||
static uint8_t pass[NUM_MODULES] = { MODULES_INIT(0) };
|
||||
uint8_t sendUpperChannels = 0;
|
||||
if (pass[port]++ & 0x01) {
|
||||
sendUpperChannels = g_model.moduleData[port].channelsCount;
|
||||
}
|
||||
setupFramePXX(port, sendUpperChannels);
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user