mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 04:15:44 +03:00
Add protocol level receiver frame rate measurement for Spektrum
This commit is contained in:
parent
05418297b2
commit
cad5bdd9f1
1 changed files with 14 additions and 4 deletions
|
@ -76,17 +76,19 @@ static uint8_t telemetryBuf[SRXL_FRAME_SIZE_MAX];
|
||||||
static uint8_t telemetryBufLen = 0;
|
static uint8_t telemetryBufLen = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static timeDelta_t lastFrameDelta = 0;
|
||||||
|
|
||||||
// Receive ISR callback
|
// Receive ISR callback
|
||||||
static void spektrumDataReceive(uint16_t c, void *data)
|
static void spektrumDataReceive(uint16_t c, void *data)
|
||||||
{
|
{
|
||||||
UNUSED(data);
|
UNUSED(data);
|
||||||
|
|
||||||
uint32_t spekTime, spekTimeInterval;
|
static timeUs_t spekTimeLast = 0;
|
||||||
static uint32_t spekTimeLast = 0;
|
|
||||||
static uint8_t spekFramePosition = 0;
|
static uint8_t spekFramePosition = 0;
|
||||||
|
static timeUs_t lastFrameCompleteTimeUs = 0;
|
||||||
|
|
||||||
spekTime = micros();
|
const timeUs_t spekTime = microsISR();
|
||||||
spekTimeInterval = spekTime - spekTimeLast;
|
const timeUs_t spekTimeInterval = cmpTimeUs(spekTime, spekTimeLast);
|
||||||
spekTimeLast = spekTime;
|
spekTimeLast = spekTime;
|
||||||
|
|
||||||
if (spekTimeInterval > SPEKTRUM_NEEDED_FRAME_INTERVAL) {
|
if (spekTimeInterval > SPEKTRUM_NEEDED_FRAME_INTERVAL) {
|
||||||
|
@ -98,6 +100,8 @@ static void spektrumDataReceive(uint16_t c, void *data)
|
||||||
if (spekFramePosition < SPEK_FRAME_SIZE) {
|
if (spekFramePosition < SPEK_FRAME_SIZE) {
|
||||||
rcFrameComplete = false;
|
rcFrameComplete = false;
|
||||||
} else {
|
} else {
|
||||||
|
lastFrameDelta = cmpTimeUs(spekTime, lastFrameCompleteTimeUs);
|
||||||
|
lastFrameCompleteTimeUs = spekTime;
|
||||||
rcFrameComplete = true;
|
rcFrameComplete = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -341,6 +345,11 @@ void srxlRxWriteTelemetryData(const void *data, int len)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static timeDelta_t spektrumFrameDelta(void)
|
||||||
|
{
|
||||||
|
return lastFrameDelta;
|
||||||
|
}
|
||||||
|
|
||||||
bool spektrumInit(const rxConfig_t *rxConfig, rxRuntimeState_t *rxRuntimeState)
|
bool spektrumInit(const rxConfig_t *rxConfig, rxRuntimeState_t *rxRuntimeState)
|
||||||
{
|
{
|
||||||
rxRuntimeStatePtr = rxRuntimeState;
|
rxRuntimeStatePtr = rxRuntimeState;
|
||||||
|
@ -388,6 +397,7 @@ bool spektrumInit(const rxConfig_t *rxConfig, rxRuntimeState_t *rxRuntimeState)
|
||||||
|
|
||||||
rxRuntimeState->rcReadRawFn = spektrumReadRawRC;
|
rxRuntimeState->rcReadRawFn = spektrumReadRawRC;
|
||||||
rxRuntimeState->rcFrameStatusFn = spektrumFrameStatus;
|
rxRuntimeState->rcFrameStatusFn = spektrumFrameStatus;
|
||||||
|
rxRuntimeState->rcFrameDeltaFn = spektrumFrameDelta;
|
||||||
#if defined(USE_TELEMETRY_SRXL)
|
#if defined(USE_TELEMETRY_SRXL)
|
||||||
rxRuntimeState->rcProcessFrameFn = spektrumProcessFrame;
|
rxRuntimeState->rcProcessFrameFn = spektrumProcessFrame;
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue