Esempio n. 1
0
static inline void autopilot_main_periodic( void ) {
  static uint8_t _cnt = 0;

  /* read analog baro */
  analog_periodic_task();
  altimeter_periodic_task();

  /* read imu */
  imu_periodic_task();

  /* run control loops */
  autopilot_periodic();
  /* set actuators     */
  autopilot_set_actuators();

  /* Run the following tasks 10x times slower than the periodic rate */
  _cnt++;
  if (_cnt >= 10)
    _cnt = 0;
  switch (_cnt)
  {
    case 0:
        rc_periodic_task();
        if (rc_status == RC_OK) {
            led_on(LED_RC);
        } else {
            led_off(LED_RC);
            autopilot_set_mode(AP_MODE_FAILSAFE);
        }
        break;
    case 1:
        comm_periodic_task(COMM_TELEMETRY);
#if !HARDWARE_ENABLED_GPS
        comm_periodic_task(COMM_0);
#endif
        break;
    case 2:
        fms_periodic_task();
        break;
#if BOMB_ENABLED
    case 3:
        bomb_periodic_task();
        break;
#endif
  }

  /* flash leds... */
  led_periodic_task();

  if (ahrs_status == STATUS_INITIALIZING) {
    RunOnceEvery(50, {
      led_toggle(LED_AHRS);
    });
Esempio n. 2
0
static inline void main_periodic_task( void ) {
    analog_periodic_task();
    altimeter_periodic_task();
    comm_periodic_task(COMM_1);

    RunOnceEvery(250, {
        int32_t alt = altimeter_get_altitude();
        MESSAGE_SEND_ALTIMETER(COMM_1,
            &alt,
            &altimeter_system_status,
            &altimeter_calibration_offset,
            &altimeter_calibration_raw);
    });