Эх сурвалжийг харах

autohold beep单独定时器

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui 3 жил өмнө
parent
commit
6f47d880a3

+ 2 - 2
Applications/bsp/mc_irqs.c

@@ -155,14 +155,14 @@ void EXTI4_IRQHandler(void)
 {
 	if(RESET != exti_interrupt_flag_get(EXTI_4)){
 		exti_interrupt_flag_clear(EXTI_4);
-		MC_Brake_IRQHandler();
+		//MC_Brake_IRQHandler();
 	}	
 }
 
 void EXTI5_9_IRQHandler(void){
 	if(RESET != exti_interrupt_flag_get(EXTI_5)){
 		exti_interrupt_flag_clear(EXTI_5);
-		MC_Brake_IRQHandler();
+		//MC_Brake_IRQHandler();
 	}
 	if(RESET != exti_interrupt_flag_get(EXTI_6)){
 		exti_interrupt_flag_clear(EXTI_6);

+ 8 - 3
Applications/foc/motor/motor.c

@@ -24,6 +24,8 @@
 static bool mc_is_hwbrake(void);
 static void _pwm_brake_prot_timer_handler(shark_timer_t *);
 static shark_timer_t _brake_prot_timer = TIMER_INIT(_brake_prot_timer, _pwm_brake_prot_timer_handler);
+static void _autohold_beep_timer_handler(shark_timer_t *);
+static shark_timer_t _autohold_beep_timer = TIMER_INIT(_autohold_beep_timer, _autohold_beep_timer_handler);
 
 
 static motor_t motor = {
@@ -436,9 +438,8 @@ bool mc_auto_hold(bool hold) {
 		PMSM_FOC_SetErrCode(FOC_Throttle_Err);
 		return false;
 	}
-	motor.b_auto_hold = hold;
-
 	u32 mask = cpu_enter_critical();
+	motor.b_auto_hold = hold;
 	if (!PMSM_FOC_Is_Start()) {
 		PMSM_FOC_Start(motor.mode);
 		PMSM_FOC_AutoHold(hold);
@@ -605,6 +606,10 @@ static bool mc_run_stall_process(u8 run_mode) {
 }
 
 #endif
+static void _autohold_beep_timer_handler(shark_timer_t *t) {
+	gpio_beep(60);
+}
+
 static void mc_autohold_process(void) {
 	if (PMSM_FOC_AutoHoldding() && !mc_throttle_released()) {
 		mc_auto_hold(false);
@@ -615,7 +620,7 @@ static void mc_autohold_process(void) {
 		}else {
 			if (get_delta_ms(motor.n_autohold_time) >= CONFIG_AUTOHOLD_DETECT_TIME) {
 				mc_auto_hold(true);
-				gpio_beep(50);
+				shark_timer_post(&_autohold_beep_timer, 0);
 			}
 		}
 	}else {