Merge pull request #1343 from sherlockflight/msp-rx-loss-detect

Fix RX_MSP oscillation, > 8 channel support
This commit is contained in:
Dominic Clifton 2015-09-26 01:36:23 +01:00
commit 21c0927efa
4 changed files with 27 additions and 10 deletions

View File

@ -1310,9 +1310,13 @@ static bool processInCommand(void)
if (channelCount > MAX_SUPPORTED_RC_CHANNEL_COUNT) {
headSerialError(0);
} else {
for (i = 0; i < channelCount; i++)
rcData[i] = read16();
rxMspFrameRecieve();
uint16_t frame[MAX_SUPPORTED_RC_CHANNEL_COUNT];
for (i = 0; i < channelCount; i++) {
frame[i] = read16();
}
rxMspFrameReceive(frame, channelCount);
}
}
break;

View File

@ -31,16 +31,26 @@
#include "rx/rx.h"
#include "rx/msp.h"
static uint16_t mspFrame[MAX_SUPPORTED_RC_CHANNEL_COUNT];
static bool rxMspFrameDone = false;
static uint16_t rxMspReadRawRC(rxRuntimeConfig_t *rxRuntimeConfigPtr, uint8_t chan)
{
UNUSED(rxRuntimeConfigPtr);
return rcData[chan];
return mspFrame[chan];
}
void rxMspFrameRecieve(void)
void rxMspFrameReceive(uint16_t *frame, int channelCount)
{
for (int i = 0; i < channelCount; i++) {
mspFrame[i] = frame[i];
}
// Any channels not provided will be reset to zero
for (int i = channelCount; i < MAX_SUPPORTED_RC_CHANNEL_COUNT; i++) {
mspFrame[i] = 0;
}
rxMspFrameDone = true;
}
@ -57,7 +67,7 @@ bool rxMspFrameComplete(void)
void rxMspInit(rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig, rcReadRawDataPtr *callback)
{
UNUSED(rxConfig);
rxRuntimeConfig->channelCount = 8; // Limited to 8 channels due to MSP_SET_RAW_RC command.
rxRuntimeConfig->channelCount = MAX_SUPPORTED_RC_CHANNEL_COUNT;
if (callback)
*callback = rxMspReadRawRC;
}

View File

@ -18,4 +18,4 @@
#pragma once
bool rxMspFrameComplete(void);
void rxMspFrameRecieve(void);
void rxMspFrameReceive(uint16_t *frame, int channelCount);

View File

@ -83,6 +83,7 @@ int16_t rcData[MAX_SUPPORTED_RC_CHANNEL_COUNT]; // interval [1000;2000]
#define DELAY_50_HZ (1000000 / 50)
#define DELAY_10_HZ (1000000 / 10)
#define DELAY_5_HZ (1000000 / 5)
#define SKIP_RC_ON_SUSPEND_PERIOD 1500000 // 1.5 second period in usec (call frequency independent)
#define SKIP_RC_SAMPLES_ON_RESUME 2 // flush 2 samples to drop wrong measurements (timing independent)
@ -297,16 +298,18 @@ void updateRx(uint32_t currentTime)
if (frameStatus & SERIAL_RX_FRAME_COMPLETE) {
rxDataReceived = true;
rxSignalReceived = (frameStatus & SERIAL_RX_FRAME_FAILSAFE) == 0;
needRxSignalBefore = currentTime + DELAY_10_HZ;
}
}
#endif
if (feature(FEATURE_RX_MSP)) {
rxDataReceived = rxMspFrameComplete();
}
if (feature(FEATURE_RX_SERIAL | FEATURE_RX_MSP) && rxDataReceived) {
needRxSignalBefore = currentTime + DELAY_10_HZ;
if (rxDataReceived) {
rxSignalReceived = true;
needRxSignalBefore = currentTime + DELAY_5_HZ;
}
}
if (feature(FEATURE_RX_PPM)) {