예제 #1
0
/********** INIT *************************************************************/
void init_fbw( void ) {

  mcu_init();

  electrical_init();

#ifdef ACTUATORS
  actuators_init();
  /* Load the failsafe defaults */
  SetCommands(commands_failsafe);
  fbw_new_actuators = 1;
#endif
#ifdef RADIO_CONTROL
  radio_control_init();
#endif
#ifdef INTER_MCU
  inter_mcu_init();
#endif
#ifdef MCU_SPI_LINK
  link_mcu_restart();
#endif

  fbw_mode = FBW_MODE_FAILSAFE;

  /**** start timers for periodic functions *****/
  fbw_periodic_tid = sys_time_register_timer((1./60.), NULL);
  electrical_tid = sys_time_register_timer(0.1, NULL);

#ifndef SINGLE_MCU
  mcu_int_enable();
#endif
}
예제 #2
0
STATIC_INLINE void main_init(void)
{
  // fbw_init
  fbw_mode = FBW_MODE_FAILSAFE;

  mcu_init();

  actuators_init();

  electrical_init();

#if USE_MOTOR_MIXING
  motor_mixing_init();
#endif

  radio_control_init();

  modules_init();

  mcu_int_enable();

  intermcu_init();

  // register the timers for the periodic functions
  main_periodic_tid = sys_time_register_timer((1. / PERIODIC_FREQUENCY), NULL);
  modules_tid = sys_time_register_timer(1. / MODULES_FREQUENCY, NULL);
  radio_control_tid = sys_time_register_timer((1. / 60.), NULL);
  electrical_tid = sys_time_register_timer(0.1, NULL);
  telemetry_tid = sys_time_register_timer((1. / 20.), NULL);
}
예제 #3
0
/********** INIT *************************************************************/
void init_fbw(void)
{
    mcu_init();

#if !(DISABLE_ELECTRICAL)
    electrical_init();
#endif

#ifdef ACTUATORS
    actuators_init();
    /* Load the failsafe defaults */
    SetCommands(commands_failsafe);
    fbw_new_actuators = 1;
#endif /* ACTUATORS */

#ifdef RADIO_CONTROL
    radio_control_init();
#endif /* RADIO_CONTROL */

#ifdef INTER_MCU
    inter_mcu_init();
#endif /* INTER_MCU */

#if defined MCU_SPI_LINK || defined MCU_CAN_LINK
    link_mcu_init();
#endif /* MCU_SPI_LINK || MCU_CAN_LINK */

#ifdef MCU_SPI_LINK
    link_mcu_restart();
#endif /* MCU_SPI_LINK */

    fbw_mode = FBW_MODE_FAILSAFE;

    /**** start timers for periodic functions *****/
    fbw_periodic_tid = sys_time_register_timer((1. / 60.), NULL);
    electrical_tid = sys_time_register_timer(0.1, NULL);

#ifndef SINGLE_MCU
    mcu_int_enable();
#endif

#if PERIODIC_TELEMETRY
    register_periodic_telemetry(DefaultPeriodic, PPRZ_MSG_ID_FBW_STATUS, send_fbw_status);
    register_periodic_telemetry(DefaultPeriodic, PPRZ_MSG_ID_COMMANDS, send_commands);

#ifdef ACTUATORS
    register_periodic_telemetry(DefaultPeriodic, PPRZ_MSG_ID_ACTUATORS, send_actuators);
#endif /* ACTUATORS */

#ifdef RADIO_CONTROL
    register_periodic_telemetry(DefaultPeriodic, PPRZ_MSG_ID_RC, send_rc);
#endif /* RADIO_CONTROL */

#endif /* PERIODIC_TELEMETRY */

}
예제 #4
0
static inline void main_init(void)
{
  mcu_init();
  sys_time_register_timer((1. / PERIODIC_FREQUENCY), NULL);
  downlink_init();
  ActuatorsPwmInit();
}
예제 #5
0
static inline void main_init(void)
{
  mcu_init();
  sys_time_register_timer((1. / PERIODIC_FREQUENCY), NULL);
  uart0_init_tx();
  mcu_int_enable();
}
예제 #6
0
static inline void main_init( void ) {
  mcu_init();
  sys_time_register_timer((1./PERIODIC_FREQUENCY), NULL);
  main_init_hw();
  main_enable_hw();

}
예제 #7
0
static inline void main_init(void)
{
  mcu_init();
  sys_time_register_timer((0.5 / PERIODIC_FREQUENCY), NULL);
  downlink_init();
  ppz_can_init(main_on_can_msg);
}
예제 #8
0
static inline void main_init(void)
{
  mcu_init();
  sys_time_register_timer((1. / PERIODIC_FREQUENCY), NULL);

  stateInit();
  actuators_init();

  imu_init();
#if USE_AHRS_ALIGNER
  ahrs_aligner_init();
#endif
  ahrs_init();

  settings_init();

  mcu_int_enable();

  downlink_init();

  register_periodic_telemetry(DefaultPeriodic, PPRZ_MSG_ID_AUTOPILOT_VERSION, send_autopilot_version);
  register_periodic_telemetry(DefaultPeriodic, PPRZ_MSG_ID_ALIVE, send_alive);
  register_periodic_telemetry(DefaultPeriodic, PPRZ_MSG_ID_COMMANDS, send_commands);
  register_periodic_telemetry(DefaultPeriodic, PPRZ_MSG_ID_ACTUATORS, send_actuators);

  // send body_to_imu from here for now
  AbiSendMsgBODY_TO_IMU_QUAT(1, orientationGetQuat_f(&imu.body_to_imu));
}
예제 #9
0
static inline void main_init(void)
{
  mcu_init();
  sys_time_register_timer((1. / 100), NULL);
  downlink_init();
  adc_init();

#ifdef ADC_0
  adc_buf_channel(ADC_0, &buf_adc[0], ADC_NB_SAMPLES);
#endif
#ifdef ADC_1
  adc_buf_channel(ADC_1, &buf_adc[1], ADC_NB_SAMPLES);
#endif
#ifdef ADC_2
  adc_buf_channel(ADC_2, &buf_adc[2], ADC_NB_SAMPLES);
#endif
#ifdef ADC_3
  adc_buf_channel(ADC_3, &buf_adc[3], ADC_NB_SAMPLES);
#endif
#ifdef ADC_4
  adc_buf_channel(ADC_4, &buf_adc[4], ADC_NB_SAMPLES);
#endif
#ifdef ADC_5
  adc_buf_channel(ADC_5, &buf_adc[5], ADC_NB_SAMPLES);
#endif
#ifdef ADC_6
  adc_buf_channel(ADC_6, &buf_adc[6], ADC_NB_SAMPLES);
#endif
#ifdef ADC_7
  adc_buf_channel(ADC_7, &buf_adc[7], ADC_NB_SAMPLES);
#endif

  mcu_int_enable();
}
예제 #10
0
int main(void)
{

  mcu_init();
  sys_time_register_timer((1. / PERIODIC_FREQUENCY), NULL);

  /* Init GPIO for rx pins */
  gpio_setup_input_pullup(A_RX_PORT, A_RX_PIN);
  gpio_setup_input_pullup(B_RX_PORT, B_RX_PIN);

  /* Init GPIO for tx pins */
  gpio_setup_output(A_TX_PORT, A_TX_PIN);
  gpio_setup_output(B_TX_PORT, B_TX_PIN);

  gpio_clear(A_TX_PORT, A_TX_PIN);

  /* */
  while (1) {
    if (sys_time_check_and_ack_timer(0)) {
      main_periodic();
    }
    main_event();
  }

  return 0;
}
예제 #11
0
int main(void) {

  mcu_init();
  sys_time_register_timer((1./PERIODIC_FREQUENCY), NULL);

  /* init RCC */
  rcc_peripheral_enable_clock(&RCC_APB2ENR, A_PERIPH);
  // rccp_perihperal_enable_clock(&RCC_APB2ENR, B_PERIPH);

  /* Init GPIO for rx pins */
  gpio_set(A_RX_PORT, A_RX_PIN);
  gpio_set_mode(A_RX_PORT, GPIO_MODE_INPUT,
          GPIO_CNF_INPUT_PULL_UPDOWN, A_RX_PIN);
  gpio_set(B_RX_PORT, B_RX_PIN);
  gpio_set_mode(B_RX_PORT, GPIO_MODE_INPUT,
          GPIO_CNF_INPUT_PULL_UPDOWN, B_RX_PIN);

  /* Init GPIO for tx pins */
  gpio_set_mode(A_RX_PORT, GPIO_MODE_OUTPUT_50_MHZ,
          GPIO_CNF_OUTPUT_PUSHPULL, A_TX_PIN);
  gpio_set_mode(B_RX_PORT, GPIO_MODE_OUTPUT_50_MHZ,
          GPIO_CNF_OUTPUT_PUSHPULL, B_TX_PIN);

  gpio_clear(A_TX_PORT, A_TX_PIN);

  /* */
  while (1) {
    if (sys_time_check_and_ack_timer(0))
      main_periodic();
    main_event();
  }

  return 0;
}
예제 #12
0
static inline void main_init(void)
{
  mcu_init();
  sys_time_register_timer((1. / PERIODIC_FREQUENCY), NULL);
  downlink_init();
  pprz_dl_init();
}
예제 #13
0
/********** INIT *************************************************************/
void init_fbw( void ) {

  mcu_init();

#if !(DISABLE_ELECTRICAL)
  electrical_init();
#endif

#ifdef ACTUATORS
  actuators_init();
  /* Load the failsafe defaults */
  SetCommands(commands_failsafe);
  fbw_new_actuators = 1;
#endif
#ifdef RADIO_CONTROL
  radio_control_init();
#endif
#ifdef INTER_MCU
  inter_mcu_init();
#endif
#ifdef MCU_SPI_LINK
  link_mcu_init();
  link_mcu_restart();
#endif

  fbw_mode = FBW_MODE_FAILSAFE;

  /**** start timers for periodic functions *****/
  fbw_periodic_tid = sys_time_register_timer((1./60.), NULL);
  electrical_tid = sys_time_register_timer(0.1, NULL);

#ifndef SINGLE_MCU
  mcu_int_enable();
#endif

#if DOWNLINK
  register_periodic_telemetry(&telemetry_Fbw, "FBW_STATUS", send_fbw_status);
  register_periodic_telemetry(&telemetry_Fbw, "COMMANDS", send_commands);
#ifdef ACTUATORS
  register_periodic_telemetry(&telemetry_Fbw, "ACTUATORS", send_actuators);
#endif
#ifdef RADIO_CONTROL
  register_periodic_telemetry(&telemetry_Fbw, "RC", send_rc);
#endif
#endif

}
예제 #14
0
static inline void main_init( void ) {
  mcu_init();
  sys_time_register_timer((1./PERIODIC_FREQUENCY), NULL);
  main_init_hw();

  gyro_ready_for_read = FALSE;

}
예제 #15
0
void intermcu_init(void)
{
    pprz_transport_init(&intermcu_transport);
#ifdef BOARD_PX4IO
    px4bl_tid = sys_time_register_timer(20.0, NULL);
#endif

}
예제 #16
0
int main(void) {

  mcu_init();
  unsigned int tmr_02 = sys_time_register_timer(0.2, NULL);
  unsigned int tmr_03 = sys_time_register_timer(0.3, NULL);
  sys_time_register_timer(0.5, main_periodic_05);

  while(1) {
    if (sys_time_check_and_ack_timer(tmr_02))
      main_periodic_02();
    if (sys_time_check_and_ack_timer(tmr_03))
      main_periodic_03();
    main_event();
  }

  return 0;
}
예제 #17
0
static void checkPx4RebootCommand(uint8_t b)
{
  if (intermcu.stable_px4_baud == CHANGING_BAUD && sys_time_check_and_ack_timer(px4bl_tid)) {
    //to prevent a short intermcu comm loss, give some time to changing the baud
    sys_time_cancel_timer(px4bl_tid);
    intermcu.stable_px4_baud = PPRZ_BAUD;
  } else if (intermcu.stable_px4_baud == PX4_BAUD) {

    if (sys_time_check_and_ack_timer(px4bl_tid)) {
      //time out the possibility to reboot to the px4 bootloader, to prevent unwanted restarts during flight
      sys_time_cancel_timer(px4bl_tid);
      //for unknown reasons, 1500000 baud does not work reliably after prolonged times.
      //I suspect a temperature related issue, combined with the fbw f1 crystal which is out of specs
      //After a initial period on 1500000, revert to 230400
      //We still start at 1500000 to remain compatible with original PX4 firmware. (which always runs at 1500000)
      uart_periph_set_baudrate(intermcu.device->periph, B230400);
      intermcu.stable_px4_baud = CHANGING_BAUD;
      px4bl_tid = sys_time_register_timer(1.0, NULL);
      return;
    }

#ifdef SYS_TIME_LED
    LED_ON(SYS_TIME_LED);
#endif

    if (b == px4RebootSequence[px4RebootSequenceCount]) {
      px4RebootSequenceCount++;
    } else {
      px4RebootSequenceCount = 0;
    }

    if (px4RebootSequenceCount >= 6) { // 6 = length of rebootSequence + 1
      px4RebootSequenceCount = 0; // should not be necessary...

      //send some magic back
      //this is the same as the Pixhawk IO code would send
      intermcu.device->put_byte(intermcu.device->periph, 0, 0x00);
      intermcu.device->put_byte(intermcu.device->periph, 0, 0xe5);
      intermcu.device->put_byte(intermcu.device->periph, 0, 0x32);
      intermcu.device->put_byte(intermcu.device->periph, 0, 0x0a);
      intermcu.device->put_byte(intermcu.device->periph, 0,
                                0x66); // dummy byte, seems to be necessary otherwise one byte is missing at the fmu side...

      while (((struct uart_periph *)(intermcu.device->periph))->tx_running) {
        // tx_running is volatile now, so LED_TOGGLE not necessary anymore
#ifdef SYS_TIME_LED
        LED_TOGGLE(SYS_TIME_LED);
#endif
      }

#ifdef SYS_TIME_LED
      LED_OFF(SYS_TIME_LED);
#endif
      scb_reset_system();
    }
  }
}
예제 #18
0
static inline void main_init( void ) {
    mcu_init();
    sys_time_register_timer((1./PERIODIC_FREQUENCY), NULL);
    adc_init();
    adc_buf_channel(0, &adc0_buf, 8);
    adc_buf_channel(1, &adc1_buf, 3);
    adc_buf_channel(2, &adc2_buf, 3);
    adc_buf_channel(3, &adc3_buf, 3);
}
예제 #19
0
static inline void main_init(void)
{
  mcu_init();
  mcu_int_enable();

  sys_time_register_timer((1. / 50), NULL);
  downlink_init();
  lis302dl_spi_init(&lis302, &(LIS302DL_SPI_DEV), LIS302DL_SPI_SLAVE_IDX);
}
예제 #20
0
파일: main.c 프로젝트: hulatang/paparazzi
STATIC_INLINE void main_init( void ) {

  mcu_init();

  electrical_init();

  stateInit();

  actuators_init();
#if USE_MOTOR_MIXING
  motor_mixing_init();
#endif

  radio_control_init();

  air_data_init();
#if USE_BARO_BOARD
  baro_init();
#endif
  imu_init();
#if USE_IMU_FLOAT
  imu_float_init();
#endif
  ahrs_aligner_init();
  ahrs_init();

  ins_init();

#if USE_GPS
  gps_init();
#endif

  autopilot_init();

  modules_init();

  settings_init();

  mcu_int_enable();

#if DATALINK == XBEE
  xbee_init();
#endif

#if DATALINK == UDP
  udp_init();
#endif

  // register the timers for the periodic functions
  main_periodic_tid = sys_time_register_timer((1./PERIODIC_FREQUENCY), NULL);
  modules_tid = sys_time_register_timer(1./MODULES_FREQUENCY, NULL);
  radio_control_tid = sys_time_register_timer((1./60.), NULL);
  failsafe_tid = sys_time_register_timer(0.05, NULL);
  electrical_tid = sys_time_register_timer(0.1, NULL);
  telemetry_tid = sys_time_register_timer((1./TELEMETRY_FREQUENCY), NULL);
#if USE_BARO_BOARD
  baro_tid = sys_time_register_timer(1./BARO_PERIODIC_FREQUENCY, NULL);
#endif
}
예제 #21
0
파일: test_baro.c 프로젝트: GatiB/paparazzi
static inline void main_init( void ) {
  mcu_init();
  sys_time_register_timer((1./PERIODIC_FREQUENCY), NULL);
  baro_init();

  //  DEBUG_SERVO1_INIT();
  //  DEBUG_SERVO2_INIT();


}
예제 #22
0
static inline void main_init(void)
{
  mcu_init();
  sys_time_register_timer((1. / PERIODIC_FREQUENCY), NULL);

  LED_ON(4);
  ami601_init();
  downlink_init();
  mcu_int_enable();
}
예제 #23
0
static inline void main_init( void ) {
    mcu_init();
    sys_time_register_timer((1./PERIODIC_FREQUENCY), NULL);
    adc_init();
    adc_buf_channel(0, &adc0_buf, 8);
    adc_buf_channel(1, &adc1_buf, 3);
    adc_buf_channel(2, &adc2_buf, 3);
    adc_buf_channel(3, &adc3_buf, 3);
    adc_buf_channel(ADC_CHANNEL_VSUPPLY, &vsupply_buf, DEFAULT_AV_NB_SAMPLE);
}
예제 #24
0
STATIC_INLINE void main_init( void ) {

  mcu_init();

  electrical_init();

  stateInit();

  actuators_init();
#if USE_MOTOR_MIXING
 // motor_mixing_init();
 // servo_mixing_init();
  set_servo_init();
#endif

  radio_control_init();

  baro_init();
  imu_init();
  autopilot_init();
  nav_init();
  guidance_h_init();
  guidance_v_init();
  stabilization_init();

  ahrs_aligner_init();
  ahrs_init();

  ins_init();

#if USE_GPS
  gps_init();
#endif

  modules_init();

  settings_init();

  mcu_int_enable();

#if DATALINK == XBEE
  xbee_init();
#endif

#if DATALINK == UDP
  udp_init();
#endif

  // register the timers for the periodic functions
  main_periodic_tid = sys_time_register_timer((1./PERIODIC_FREQUENCY), NULL);
  modules_tid = sys_time_register_timer(1./MODULES_FREQUENCY, NULL);
  radio_control_tid = sys_time_register_timer((1./60.), NULL);
  failsafe_tid = sys_time_register_timer(0.05, NULL);
  electrical_tid = sys_time_register_timer(0.1, NULL);
  baro_tid = sys_time_register_timer(1./BARO_PERIODIC_FREQUENCY, NULL);
  telemetry_tid = sys_time_register_timer((1./TELEMETRY_FREQUENCY), NULL);
}
예제 #25
0
static inline void main_init(void)
{
  mcu_init();
  sys_time_register_timer((1. / PERIODIC_FREQUENCY), NULL);
  settings_init();

  mcu_int_enable();

#if DOWNLINK
  downlink_init();
#endif
}
예제 #26
0
void intermcu_init(void)
{
  pprz_transport_init(&intermcu.transport);

#if USE_GPS
  AbiBindMsgGPS(IMCU_GPS_ID, &gps_ev, gps_cb);
#endif

#ifdef BOARD_PX4IO
  px4bl_tid = sys_time_register_timer(10.0, NULL);
#endif
}
예제 #27
0
static inline void main_init(void)
{
  mcu_init();
  downlink_init();

  actuators_init();
#if USE_MOTOR_MIXING
  motor_mixing_init();
#endif

  radio_control_init();

  mcu_int_enable();
  main_periodic_tid = sys_time_register_timer((1. / PERIODIC_FREQUENCY), NULL);
  radio_control_tid = sys_time_register_timer((1. / 60.), NULL);

  // just to make it usable in a standard rotorcraft airframe file
  // with <call fun="motor_mixing_run(autopilot_motors_on,FALSE,values)"/>
  // in the command_laws section
  autopilot_motors_on = true;
}
예제 #28
0
/********** INIT *************************************************************/
void init_fbw( void ) //fbw初始化
{

  mcu_init();//mcu初始化,如:led,uart,i2c,vocm,spi,dac

#if !(DISABLE_ELECTRICAL)
  electrical_init();//供电初始化
#endif

#ifdef ACTUATORS
  actuators_init();//执行器初始化
  /* Load the failsafe defaults */
  SetCommands(commands_failsafe);
  fbw_new_actuators = 1;
#endif
#ifdef RADIO_CONTROL
  radio_control_init();//无线电台初始化
#endif
#ifdef INTER_MCU
  inter_mcu_init();
#endif
#ifdef MCU_SPI_LINK
  link_mcu_init();
  link_mcu_restart();
#endif

  fbw_mode = FBW_MODE_FAILSAFE;

  command_roll_trim = COMMAND_ROLL_TRIM;
  command_pitch_trim = COMMAND_PITCH_TRIM;


  /**** start timers for periodic functions *****/
  fbw_periodic_tid = sys_time_register_timer((1./60.), NULL);
  electrical_tid = sys_time_register_timer(0.1, NULL);

#ifndef SINGLE_MCU
  mcu_int_enable();
#endif
}
예제 #29
0
static inline void main_init(void)
{
  mcu_init();
  sys_time_register_timer((1. / PERIODIC_FREQUENCY), NULL);
  imu_init();
#if USE_AHRS_ALIGNER
  ahrs_aligner_init();
#endif
  ahrs_init();
  downlink_init();

  mcu_int_enable();
}
예제 #30
0
파일: test_ahrs.c 프로젝트: AxSt/paparazzi
static inline void main_init( void ) {

  mcu_init();
  sys_time_register_timer((1./PERIODIC_FREQUENCY), NULL);
  imu_init();
  ahrs_aligner_init();
  ahrs_init();

  DEBUG_SERVO1_INIT();
  //  DEBUG_SERVO2_INIT();

  mcu_int_enable();
}