Пример #1
0
// 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
// 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();
}