Пример #1
0
void updateRx(uint32_t currentTime)
{
    rxDataReceived = false;
    shouldCheckPulse = true;

    if (rxSignalReceived) {
        if (((int32_t)(currentTime - needRxSignalBefore) >= 0)) {
            rxSignalReceived = false;
#ifdef DEBUG_RX_SIGNAL_LOSS
            debug[0]++;
#endif
        }
    }

#ifdef SERIAL_RX
    if (feature(FEATURE_RX_SERIAL)) {
        uint8_t frameStatus = serialRxFrameStatus(rxConfig);

        if (frameStatus & SERIAL_RX_FRAME_COMPLETE) {
            rxDataReceived = true;
            rxSignalReceived = (frameStatus & SERIAL_RX_FRAME_FAILSAFE) == 0;
            if (rxSignalReceived && feature(FEATURE_FAILSAFE)) {
                shouldCheckPulse = false;

                failsafeOnValidDataReceived();
            }
        } else {
            shouldCheckPulse = false;
        }
    }
#endif

    if (feature(FEATURE_RX_MSP)) {
        rxDataReceived = rxMspFrameComplete();
        if (rxDataReceived) {

            if (feature(FEATURE_FAILSAFE)) {
                failsafeOnValidDataReceived();
            }
        }
    }

    if ((feature(FEATURE_RX_SERIAL | FEATURE_RX_MSP) && rxDataReceived)
         || feature(FEATURE_RX_PARALLEL_PWM)) {
        needRxSignalBefore = currentTime + DELAY_10_HZ;
    }

    if (feature(FEATURE_RX_PPM)) {
        if (isPPMDataBeingReceived()) {
            rxSignalReceived = true;
            needRxSignalBefore = currentTime + DELAY_10_HZ;
            resetPPMDataReceivedState();
        }
        shouldCheckPulse = rxSignalReceived;
    }
}
Пример #2
0
void updateRx(uint32_t currentTime)
{
    resetRxSignalReceivedFlagIfNeeded(currentTime);

    if (isRxDataDriven()) {
        rxDataReceived = false;
    }


#ifdef SERIAL_RX
    if (feature(FEATURE_RX_SERIAL)) {
        uint8_t frameStatus = serialRxFrameStatus();

        if (frameStatus & SERIAL_RX_FRAME_COMPLETE) {
            rxDataReceived = true;
            rxIsInFailsafeMode = (frameStatus & SERIAL_RX_FRAME_FAILSAFE) != 0;
            rxSignalReceived = !rxIsInFailsafeMode;
            needRxSignalBefore = currentTime + DELAY_10_HZ;
        }
    }
#endif

    if (feature(FEATURE_RX_MSP)) {
        rxDataReceived = rxMspFrameComplete();

        if (rxDataReceived) {
            rxSignalReceived = true;
            rxIsInFailsafeMode = false;
            needRxSignalBefore = currentTime + DELAY_5_HZ;
        }
    }

    if (feature(FEATURE_RX_PPM)) {
        if (isPPMDataBeingReceived()) {
            rxSignalReceivedNotDataDriven = true;
            rxIsInFailsafeModeNotDataDriven = false;
            needRxSignalBefore = currentTime + DELAY_10_HZ;
            resetPPMDataReceivedState();
        }
    }

    if (feature(FEATURE_RX_PARALLEL_PWM)) {
        if (isPWMDataBeingReceived()) {
            rxSignalReceivedNotDataDriven = true;
            rxIsInFailsafeModeNotDataDriven = false;
            needRxSignalBefore = currentTime + DELAY_10_HZ;
        }
    }

}