コード例 #1
0
ファイル: mw.c プロジェクト: ledvinap/cleanflight
// Function for loop trigger
bool shouldRunLoop(uint32_t loopTime) {
	bool loopTrigger = false;

    if (masterConfig.gyroSync) {
        if (gyroSyncCheckUpdate() || (int32_t)(currentTime - (loopTime + GYRO_WATCHDOG_DELAY)) >= 0) {
            loopTrigger = true;
        }
    } else if (masterConfig.looptime == 0 || (int32_t)(currentTime - loopTime) >= 0){
        loopTrigger = true;
    }

    return loopTrigger;
}
コード例 #2
0
ファイル: mw.c プロジェクト: iforce2d/cleanflight
// Function for loop trigger
void taskMainPidLoopChecker(void) {
    // getTaskDeltaTime() returns delta time freezed at the moment of entering the scheduler. currentTime is freezed at the very same point.
    // To make busy-waiting timeout work we need to account for time spent within busy-waiting loop
    uint32_t currentDeltaTime = getTaskDeltaTime(TASK_SELF);

    if (masterConfig.gyroSync) {
        while (1) {
            if (gyroSyncCheckUpdate() || ((currentDeltaTime + (micros() - currentTime)) >= (gyro.targetLooptime + GYRO_WATCHDOG_DELAY))) {
                break;
            }
        }
    }

    taskMainPidLoop();
}