1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-15 20:35:33 +03:00

Merge pull request #9288 from etracer65/frame_rate_calc_srxl2

Add protocol level receiver frame rate measurement for SRXL2
This commit is contained in:
Michael Keller 2019-12-27 18:17:38 +13:00 committed by GitHub
commit 9e99ad1ab3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -112,6 +112,8 @@ static bool telemetryRequested = false;
static uint8_t telemetryFrame[22];
static timeUs_t lastRcFrameTimeUs = 0;
uint8_t globalResult = 0;
/* handshake protocol
@ -423,6 +425,12 @@ static uint8_t srxl2FrameStatus(rxRuntimeState_t *rxRuntimeState)
result |= RX_FRAME_PROCESSING_REQUIRED;
}
if (result == RX_FRAME_COMPLETE || result == (RX_FRAME_COMPLETE | RX_FRAME_PROCESSING_REQUIRED)) {
lastRcFrameTimeUs = lastIdleTimestamp;
} else {
lastRcFrameTimeUs = 0; // We received a frame but it wasn't valid new channel data
}
return result;
}
@ -472,6 +480,13 @@ void srxl2RxWriteData(const void *data, int len)
writeBufferIdx = len;
}
static timeUs_t srxl2FrameTimeUs(void)
{
const timeUs_t result = lastRcFrameTimeUs;
lastRcFrameTimeUs = 0;
return result;
}
bool srxl2RxInit(const rxConfig_t *rxConfig, rxRuntimeState_t *rxRuntimeState)
{
static uint16_t channelData[SRXL2_MAX_CHANNELS];
@ -488,6 +503,7 @@ bool srxl2RxInit(const rxConfig_t *rxConfig, rxRuntimeState_t *rxRuntimeState)
rxRuntimeState->rcReadRawFn = srxl2ReadRawRC;
rxRuntimeState->rcFrameStatusFn = srxl2FrameStatus;
rxRuntimeState->rcFrameTimeUsFn = srxl2FrameTimeUs;
rxRuntimeState->rcProcessFrameFn = srxl2ProcessFrame;
const serialPortConfig_t *portConfig = findSerialPortConfig(FUNCTION_RX_SERIAL);