#include "soft_timer.h" #include "auto_pilot.h" #include "control_attitude.h" #include "control_rate.h" #include "control_throttle.h" #include "flight_mode.h" #include "hard_system_timer.h" #include "pilot_navigation.h" #include "soft_imu.h" #include "soft_motor_output.h" #include "soft_port_uart4.h" #include "soft_rc_input.h" #include "soft_time.h" #include "ver_config.h" void system_timer_initial(void) { system_timer_init(); } unsigned short hz_counts = 0; volatile bool hz_400_flag = false, hz_200_flag = false, hz_100_flag = false, hz_50_flag = false, hz_20_flag = false, hz_10_flag = false, hz_5_flag = false, hz_2_flag = false, hz_1_flag = false; void timer_hookfunction(void) { hz_counts++; hz_400_flag = true; // 只能用if 不能用else if // 200HZ中断 if (hz_counts % 2 == 0) { hz_200_flag = true; } // 100HZ中断 if (hz_counts % 4 == 0) { hz_100_flag = true; } // 50HZ中断 if (hz_counts % 8 == 0) { // 获取平滑的目标航向, 因为SD卡的延迟, 需要放到此中断来做 hz_50_flag = true; get_target_yaw_by_flight_mode(flight_mode, 0.02f); } // 20HZ中断 if (hz_counts % 20 == 0) { hz_20_flag = true; } // 10HZ中断 if (hz_counts % 40 == 0) { hz_10_flag = true; } // 5HZ中断 if (hz_counts % 80 == 0) { hz_5_flag = true; } if (hz_counts % 200 == 0) { hz_2_flag = true; } // 1HZ中断 if (hz_counts % 400 == 0) { hz_1_flag = true; hz_counts = 0; } }