mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 04:45:24 +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:
commit
28bd628a3b
1 changed files with 7 additions and 9 deletions
|
@ -103,7 +103,7 @@ typedef union sbusFrame_u {
|
||||||
|
|
||||||
typedef struct sbusFrameData_s {
|
typedef struct sbusFrameData_s {
|
||||||
sbusFrame_t frame;
|
sbusFrame_t frame;
|
||||||
uint32_t startAtUs;
|
timeUs_t startAtUs;
|
||||||
uint8_t position;
|
uint8_t position;
|
||||||
bool done;
|
bool done;
|
||||||
} sbusFrameData_t;
|
} sbusFrameData_t;
|
||||||
|
@ -135,7 +135,6 @@ static void sbusDataReceive(uint16_t c, void *data)
|
||||||
if (sbusFrameData->position < SBUS_FRAME_SIZE) {
|
if (sbusFrameData->position < SBUS_FRAME_SIZE) {
|
||||||
sbusFrameData->done = false;
|
sbusFrameData->done = false;
|
||||||
} else {
|
} else {
|
||||||
lastRcFrameTimeUs = nowUs;
|
|
||||||
sbusFrameData->done = true;
|
sbusFrameData->done = true;
|
||||||
DEBUG_SET(DEBUG_SBUS, DEBUG_SBUS_FRAME_TIME, sbusFrameTime);
|
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);
|
const uint8_t frameStatus = sbusChannelsDecode(rxRuntimeState, &sbusFrameData->frame.frame.channels);
|
||||||
|
|
||||||
if (frameStatus != RX_FRAME_COMPLETE) {
|
if (!(frameStatus & (RX_FRAME_FAILSAFE | RX_FRAME_DROPPED))) {
|
||||||
lastRcFrameTimeUs = 0; // We received a frame but it wasn't valid new channel data
|
lastRcFrameTimeUs = sbusFrameData->startAtUs;
|
||||||
}
|
}
|
||||||
|
|
||||||
return frameStatus;
|
return frameStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
static timeUs_t sbusFrameTimeUsOrZeroFn(void)
|
static timeUs_t sbusFrameTimeUs(void)
|
||||||
{
|
{
|
||||||
const timeUs_t result = lastRcFrameTimeUs;
|
return lastRcFrameTimeUs;
|
||||||
lastRcFrameTimeUs = 0;
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool sbusInit(const rxConfig_t *rxConfig, rxRuntimeState_t *rxRuntimeState)
|
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->rcFrameStatusFn = sbusFrameStatus;
|
||||||
rxRuntimeState->rcFrameTimeUsOrZeroFn = sbusFrameTimeUsOrZeroFn;
|
rxRuntimeState->rcFrameTimeUsFn = sbusFrameTimeUs;
|
||||||
|
|
||||||
const serialPortConfig_t *portConfig = findSerialPortConfig(FUNCTION_RX_SERIAL);
|
const serialPortConfig_t *portConfig = findSerialPortConfig(FUNCTION_RX_SERIAL);
|
||||||
if (!portConfig) {
|
if (!portConfig) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue