Explorar el Código

加入前刹处理,目前只要有一路刹车就认为有刹车信号

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui hace 3 años
padre
commit
5822c0d2af

+ 1 - 0
Applications/app/app.c

@@ -100,6 +100,7 @@ static u32 _app_report_task(void *p) {
 		sys_debug("Slow: %d - %d\n", g_meas_MCTask.intval_time, g_meas_MCTask.exec_time);
 		sys_debug("Fast: %d - %d, err: %d-%d\n", g_meas_foc.intval_time, g_meas_foc.exec_time, g_meas_foc.intval_hi_err, g_meas_foc.intval_low_err);
 		sys_debug("acc vol %d, mos2 %d\n", get_acc_vol(), get_mos_temp2());
+		sys_debug("throttle %f\n", get_throttle_float());
 		//encoder_log();
 		//err_code_log();
 	}

+ 19 - 0
Applications/bsp/gpio.c

@@ -66,6 +66,16 @@ void mc_brk_gpio_init(void) {
 	exti_interrupt_flag_clear(GPIO_BRAKE_EXTI);
 	exti_interrupt_enable(GPIO_BRAKE_EXTI);	
 #endif
+#ifdef GPIO_BRAKE1_IN_GROUP
+	rcu_periph_clock_enable(GPIO_BRAKE1_IN_RCU);
+	gpio_init(GPIO_BRAKE1_IN_GROUP, GPIO_BRAKE1_IN_MODE, GPIO_OSPEED_50MHZ, GPIO_BRAKE1_IN_PIN);
+
+	gpio_exti_source_select(GPIO_BRAKE1_EXIT_SRC_GROUP, GPIO_BRAKE1_EXIT_SRC_PIN);
+	exti_init(GPIO_BRAKE1_EXTI, EXTI_INTERRUPT, EXTI_TRIG_BOTH);
+	nvic_irq_enable(GPIO_BRAKE1_IRQ, EBREAK_IRQ_PRIORITY, 0U);
+	exti_interrupt_flag_clear(GPIO_BRAKE1_EXTI);
+	exti_interrupt_enable(GPIO_BRAKE1_EXTI);
+#endif
 }
 
 void gpio_mlock_init(void) {
@@ -101,6 +111,15 @@ bool mc_get_gpio_brake(void) {
 	return gpio_input_bit_get(GPIO_BRAKE_IN_GROUP, GPIO_BRAKE_IN_PIN) == SET;
 }
 
+bool mc_get_gpio_brake1(void) {
+#ifdef GPIO_BRAKE1_IN_GROUP
+	return gpio_input_bit_get(GPIO_BRAKE1_IN_GROUP, GPIO_BRAKE1_IN_PIN) == SET;
+#else
+	return mc_get_gpio_brake();
+#endif
+}
+
+
 bool gpio_motor_locked(void) {
 	return gpio_input_bit_get(GPIO_MLOCK_IN_GROUP, GPIO_MLOCK_IN_PIN) == RESET;
 }

+ 1 - 0
Applications/bsp/gpio.h

@@ -28,5 +28,6 @@ void mc_brk_gpio_init(void);
 bool mc_get_gpio_brake(void);
 void mc_gpio_init(void);
 bool gpio_motor_locked(void);
+bool mc_get_gpio_brake1(void);
 
 #endif /* _GPIO_PIN_H__ */

+ 1 - 1
Applications/bsp/mc_irqs.c

@@ -134,7 +134,7 @@ void EXTI2_IRQHandler(void)
 {
 	if(RESET != exti_interrupt_flag_get(EXTI_2)){
 		exti_interrupt_flag_clear(EXTI_2);
-#if (GPIO_BRAKE_EXTI == EXTI_2)
+#if (GPIO_BRAKE1_EXTI == EXTI_2)
 		MC_Brake_IRQHandler();
 #endif
 	}	

+ 1 - 1
Applications/foc/motor/motor.c

@@ -568,7 +568,7 @@ static bool mc_is_hwbrake(void) {
 	int count = 50;
 	int settimes = 0;
 	while(count-- > 0) {
-		bool b1 = mc_get_gpio_brake();
+		bool b1 = mc_get_gpio_brake() && mc_get_gpio_brake1();
 		if (b1) {
 			settimes ++;
 		}