feat: 更新测速编码器配置

This commit is contained in:
bmy
2024-04-16 10:54:44 +08:00
parent 36ca756209
commit 2b3e70f0e9
4 changed files with 7 additions and 7 deletions

View File

@@ -53,6 +53,7 @@ void by_buzzer_init(void)
by_buzzer_add(1500); by_buzzer_add(1500);
} }
// TODO 异步写入问题,不可重入
void by_buzzer_add(uint16_t tone) void by_buzzer_add(uint16_t tone)
{ {
queue_add_element(tone); queue_add_element(tone);

View File

@@ -272,9 +272,9 @@ void EXTI15_10_IRQHandler(void)
void TIM1_UP_IRQHandler(void) void TIM1_UP_IRQHandler(void)
{ {
if (TIM_GetITStatus(TIM1, TIM_IT_Update) != RESET) { if (TIM_GetITStatus(TIM1, TIM_IT_Update) != RESET) {
TIM_ClearITPendingBit(TIM1, TIM_IT_Update);
by_buzzer_run(); by_buzzer_run();
sport_motion(); sport_motion();
TIM_ClearITPendingBit(TIM1, TIM_IT_Update);
} }
} }

View File

@@ -75,10 +75,9 @@ float sport_get_speed(void)
static float speed_now = 0; static float speed_now = 0;
static float speed_last = 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; speed_last = speed_now;
encoder_clear_count(TIM3_ENCOEDER);
encoder_clear_count(TIM5_ENCOEDER);
return speed_now; return speed_now;
@@ -88,7 +87,7 @@ float sport_get_speed(void)
void sport_motion(void) void sport_motion(void)
{ {
if (1 == in_stop) { 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) { if (0 == in_state || 2 == in_state) {
PID_SetTunings(&far_gyro_pid, an_Kp1, an_Ki1, an_Kd1); PID_SetTunings(&far_gyro_pid, an_Kp1, an_Ki1, an_Kd1);

View File

@@ -43,14 +43,14 @@ int main(void)
system_delay_init(); system_delay_init();
debug_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); ips200_init(IPS200_TYPE_SPI);
while (imu660ra_init()) while (imu660ra_init())
; ;
jj_param_eeprom_init(); jj_param_eeprom_init();
jj_bt_init(); jj_bt_init();
by_rb_init(); by_rb_init();
by_pwm_init(); // by_pwm_init();
by_buzzer_init(); by_buzzer_init();
by_frame_init(); by_frame_init();