diff --git a/app/by_buzzer.c b/app/by_buzzer.c index 8fd4e05..1626379 100644 --- a/app/by_buzzer.c +++ b/app/by_buzzer.c @@ -53,6 +53,7 @@ void by_buzzer_init(void) by_buzzer_add(1500); } +// TODO 异步写入问题,不可重入 void by_buzzer_add(uint16_t tone) { queue_add_element(tone); diff --git a/app/isr.c b/app/isr.c index 55468c1..58315ec 100644 --- a/app/isr.c +++ b/app/isr.c @@ -272,9 +272,9 @@ void EXTI15_10_IRQHandler(void) void TIM1_UP_IRQHandler(void) { if (TIM_GetITStatus(TIM1, TIM_IT_Update) != RESET) { - TIM_ClearITPendingBit(TIM1, TIM_IT_Update); by_buzzer_run(); sport_motion(); + TIM_ClearITPendingBit(TIM1, TIM_IT_Update); } } diff --git a/app/jj_motion.c b/app/jj_motion.c index 8a12ad2..a6558a1 100644 --- a/app/jj_motion.c +++ b/app/jj_motion.c @@ -75,10 +75,9 @@ float sport_get_speed(void) static float speed_now = 0; static float speed_last = 0; - speed_now = ALPHA * (float)encoder_get_count(TIM5_ENCOEDER) + (1.0f - ALPHA) * speed_last; + speed_now = ALPHA * (float)encoder_get_count(TIM3_ENCOEDER) + (1.0f - ALPHA) * speed_last; speed_last = speed_now; - - encoder_clear_count(TIM5_ENCOEDER); + encoder_clear_count(TIM3_ENCOEDER); return speed_now; @@ -88,7 +87,7 @@ float sport_get_speed(void) void sport_motion(void) { if (1 == in_stop) { - bt_fly_flag = bt_run_flag = 0; + bt_fly_flag = bt_run_flag = 0; } if (0 == in_state || 2 == in_state) { PID_SetTunings(&far_gyro_pid, an_Kp1, an_Ki1, an_Kd1); diff --git a/app/main.c b/app/main.c index edd3f62..9aa5756 100644 --- a/app/main.c +++ b/app/main.c @@ -43,14 +43,14 @@ int main(void) system_delay_init(); debug_init(); - encoder_quad_init(TIM5_ENCOEDER, TIM5_ENCOEDER_MAP0_CH1_A0, TIM5_ENCOEDER_MAP0_CH2_A1); + encoder_quad_init(TIM3_ENCOEDER, TIM3_ENCOEDER_MAP3_CH1_C6, TIM3_ENCOEDER_MAP3_CH2_C7); ips200_init(IPS200_TYPE_SPI); while (imu660ra_init()) ; jj_param_eeprom_init(); jj_bt_init(); by_rb_init(); - by_pwm_init(); + // by_pwm_init(); by_buzzer_init(); by_frame_init();