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:
commit
9e99ad1ab3
1 changed files with 16 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue