Example #1
0
static inline void handle_rc_frame( void ) {
  #ifndef RADIO_CONTROL_NO_MODESET
  fbw_mode = FBW_MODE_OF_PPRZ(radio_control.values[RADIO_MODE]);
  #endif
  if (fbw_mode == FBW_MODE_MANUAL)
    SetCommandsFromRC(commands, radio_control.values);
}
Example #2
0
static inline void handle_rc_frame(void)
{
    fbw_mode = FBW_MODE_OF_PPRZ(radio_control.values[RADIO_MODE]);
    if (fbw_mode == FBW_MODE_MANUAL) {
        SetCommandsFromRC(commands, radio_control.values);
        fbw_new_actuators = 1;
    }
}
void event_task_fbw( void) {
#ifdef RADIO_CONTROL
  if (ppm_valid) {
    ppm_valid = FALSE;
    radio_control_event_task();
    if (rc_values_contains_avg_channels) {
      fbw_mode = FBW_MODE_OF_PPRZ(rc_values[RADIO_MODE]);
    }
    if (fbw_mode == FBW_MODE_MANUAL)
      SetCommandsFromRC(commands);
#ifdef CTL_GRZ
    if (fbw_mode == FBW_MODE_MANUAL)
      ctl_grz_set_setpoints_rate();
/*     else if (fbw_mode == FBW_MODE_AUTO) { */
/*       SetCommandsFromRC(commands); */
/*     } */
#endif /* CTL_GRZ */
  }
#endif


#ifdef INTER_MCU
#ifdef MCU_SPI_LINK
  if (spi_message_received) {
    /* Got a message on SPI. */
    spi_message_received = FALSE;

    /* Sets link_mcu_received */
    /* Sets inter_mcu_received_ap if checksum is ok */
    link_mcu_event_task();
  }
#endif /* MCU_SPI_LINK */

  if (inter_mcu_received_ap) {
    inter_mcu_received_ap = FALSE;
    inter_mcu_event_task();
    if (fbw_mode == FBW_MODE_AUTO) {
      SetCommands(ap_state->commands);
    }
#ifdef SINGLE_MCU
    inter_mcu_fill_fbw_state();
#endif /**Else the buffer is filled even if the last receive was not correct */
  }

#ifdef MCU_SPI_LINK
  if (link_mcu_received) {
    link_mcu_received = FALSE;
    inter_mcu_fill_fbw_state(); /** Prepares the next message for AP */
    link_mcu_restart(); /** Prepares the next SPI communication */
  }
#endif /* MCU_SPI_LINK */
#endif /* INTER_MCU */

#ifdef LINK_IMU
  if (spi_message_received) {
    /* Got a message on SPI. */
    spi_message_received = FALSE;
    link_imu_event_task();
    EstimatorSetAtt(link_imu_state.eulers[AXIS_X], link_imu_state.eulers[AXIS_Z],  link_imu_state.eulers[AXIS_Y]);
#ifdef CTL_GRZ
    ctl_grz_set_measures(); 
#endif /* CTL_GRZ */
  }
#endif /* LINK_IMU */
}