/********** INIT *************************************************************/ void init_fbw( void ) { mcu_init(); sys_time_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; #ifndef SINGLE_MCU mcu_int_enable(); #endif }
/** Main initialization */ STATIC_INLINE void main_init(void) { // Set startup mode to Failsafe 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. / 10.), NULL); }
/********** 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 }
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 }
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); }
/********** 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 */ }
/********** 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 }
STATIC_INLINE void main_init( void ) { #ifndef NO_FUCKING_STARTUP_DELAY #ifndef RADIO_CONTROL_SPEKTRUM_PRIMARY_PORT /* IF THIS IS NEEDED SOME PERHIPHERAL THEN PLEASE MOVE IT THERE */ for (uint32_t startup_counter=0; startup_counter<2000000; startup_counter++){ __asm("nop"); } #endif #endif mcu_init(); sys_time_init(); electrical_init(); actuators_init(); radio_control_init(); #if DATALINK == XBEE xbee_init(); #endif baro_init(); imu_init(); autopilot_init(); nav_init(); guidance_h_init(); guidance_v_init(); stabilization_init(); ahrs_aligner_init(); ahrs_init(); ins_init(); #ifdef USE_GPS gps_init(); #endif modules_init(); settings_init(); mcu_int_enable(); }
STATIC_INLINE void main_init( void ) { mcu_init(); electrical_init(); actuators_init(); radio_control_init(); #if DATALINK == XBEE xbee_init(); #endif imu_init(); autopilot_init(); nav_init(); guidance_h_init(); guidance_v_init(); stabilization_init(); ahrs_aligner_init(); ahrs_init(); baro_init(); ins_init(); #if USE_GPS gps_init(); #endif modules_init(); settings_init(); mcu_int_enable(); // register the timers for the periodic functions main_periodic_tid = sys_time_register_timer((1./PERIODIC_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(0.02, NULL); telemetry_tid = sys_time_register_timer((1./60.), NULL); }
/********** 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 }
STATIC_INLINE void main_init(void) { mcu_init(); electrical_init(); stateInit(); actuators_init(); #if USE_MOTOR_MIXING motor_mixing_init(); #endif radio_control_init(); #if USE_BARO_BOARD baro_init(); #endif #if USE_IMU imu_init(); #endif #if USE_AHRS_ALIGNER ahrs_aligner_init(); #endif #if USE_AHRS ahrs_init(); #endif ins_init(); #if USE_GPS gps_init(); #endif autopilot_init(); modules_init(); settings_init(); mcu_int_enable(); #if DOWNLINK downlink_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 #if USE_IMU // send body_to_imu from here for now AbiSendMsgBODY_TO_IMU_QUAT(1, orientationGetQuat_f(&imu.body_to_imu)); #endif // Do a failsafe check first failsafe_check(); }
STATIC_INLINE void main_init(void) { mcu_init(); #if defined(PPRZ_TRIG_INT_COMPR_FLASH) pprz_trig_int_init(); #endif electrical_init(); stateInit(); #ifndef INTER_MCU_AP actuators_init(); #else intermcu_init(); #endif #if USE_MOTOR_MIXING motor_mixing_init(); #endif #ifndef INTER_MCU_AP radio_control_init(); #endif #if USE_BARO_BOARD baro_init(); #endif #if USE_AHRS_ALIGNER ahrs_aligner_init(); #endif #if USE_AHRS ahrs_init(); #endif autopilot_init(); modules_init(); /* temporary hack: * Since INS is now a module, LTP_DEF is not yet initialized when autopilot_init is called * This led to the problem that global waypoints were not "localized", * so as a stop-gap measure we localize them all (again) here.. */ waypoints_localize_all(); settings_init(); mcu_int_enable(); #if DOWNLINK downlink_init(); #endif #ifdef INTER_MCU_AP intermcu_init(); #endif // register the timers for the periodic functions main_periodic_tid = sys_time_register_timer((1. / PERIODIC_FREQUENCY), NULL); #if PERIODIC_FREQUENCY != MODULES_FREQUENCY modules_tid = sys_time_register_timer(1. / MODULES_FREQUENCY, NULL); #endif 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 #if USE_IMU // send body_to_imu from here for now AbiSendMsgBODY_TO_IMU_QUAT(1, orientationGetQuat_f(&imu.body_to_imu)); #endif // Do a failsafe check first failsafe_check(); }