Exemple #1
0
void Copter::loop()
{
    // wait for an INS sample
    ins.wait_for_sample();

    uint32_t timer = micros();

    // check loop time
    perf_info_check_loop_time(timer - fast_loopTimer);

    // used by PI Loops
    G_Dt                    = (float)(timer - fast_loopTimer) / 1000000.0f;
    fast_loopTimer          = timer;

    // for mainloop failure monitoring
    mainLoop_count++;

    // Execute the fast loop
    // ---------------------
    fast_loop();

    // tell the scheduler one tick has passed
    scheduler.tick();

    // run all the tasks that are due to run. Note that we only
    // have to call this once per loop, as the tasks are scheduled
    // in multiples of the main loop tick. So if they don't run on
    // the first call to the scheduler they won't run on a later
    // call until scheduler.tick() is called again
    uint32_t time_available = (timer + MAIN_LOOP_MICROS) - micros();
    scheduler.run(time_available);
}
void loop(void) {
int32_t timer = micros();

  if ((timer - fast_loopTimer) >= 10000) {
    fast_loop();
    fast_loopTimer=micros();
    }
  if ((timer - fiftyhz_loopTimer) >= 20000) {
    fiftyhz_loopTimer = timer;
    medium_loop();    
    fiftyhz_loop();
    counter_one_herz++;

  if(counter_one_herz == 50){
    super_slow_loop();    //1 Hz
    counter_one_herz = 0;
  }
}
}