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

Merge pull request #9565 from mikeller/switch_sbus_to_generic_frame_time

Switched SBus to use the generic last frame time function.
This commit is contained in:
Michael Keller 2020-03-10 00:31:27 +13:00 committed by GitHub
commit 28bd628a3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -103,7 +103,7 @@ typedef union sbusFrame_u {
typedef struct sbusFrameData_s {
sbusFrame_t frame;
uint32_t startAtUs;
timeUs_t startAtUs;
uint8_t position;
bool done;
} sbusFrameData_t;
@ -135,7 +135,6 @@ static void sbusDataReceive(uint16_t c, void *data)
if (sbusFrameData->position < SBUS_FRAME_SIZE) {
sbusFrameData->done = false;
} else {
lastRcFrameTimeUs = nowUs;
sbusFrameData->done = true;
DEBUG_SET(DEBUG_SBUS, DEBUG_SBUS_FRAME_TIME, sbusFrameTime);
}
@ -154,17 +153,16 @@ static uint8_t sbusFrameStatus(rxRuntimeState_t *rxRuntimeState)
const uint8_t frameStatus = sbusChannelsDecode(rxRuntimeState, &sbusFrameData->frame.frame.channels);
if (frameStatus != RX_FRAME_COMPLETE) {
lastRcFrameTimeUs = 0; // We received a frame but it wasn't valid new channel data
if (!(frameStatus & (RX_FRAME_FAILSAFE | RX_FRAME_DROPPED))) {
lastRcFrameTimeUs = sbusFrameData->startAtUs;
}
return frameStatus;
}
static timeUs_t sbusFrameTimeUsOrZeroFn(void)
static timeUs_t sbusFrameTimeUs(void)
{
const timeUs_t result = lastRcFrameTimeUs;
lastRcFrameTimeUs = 0;
return result;
return lastRcFrameTimeUs;
}
bool sbusInit(const rxConfig_t *rxConfig, rxRuntimeState_t *rxRuntimeState)
@ -188,7 +186,7 @@ bool sbusInit(const rxConfig_t *rxConfig, rxRuntimeState_t *rxRuntimeState)
}
rxRuntimeState->rcFrameStatusFn = sbusFrameStatus;
rxRuntimeState->rcFrameTimeUsOrZeroFn = sbusFrameTimeUsOrZeroFn;
rxRuntimeState->rcFrameTimeUsFn = sbusFrameTimeUs;
const serialPortConfig_t *portConfig = findSerialPortConfig(FUNCTION_RX_SERIAL);
if (!portConfig) {