Преглед изворни кода

加入mc_start错误码日志

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui пре 2 година
родитељ
комит
0261d890b1
2 измењених фајлова са 5 додато и 1 уклоњено
  1. 4 1
      Applications/foc/commands.c
  2. 1 0
      Applications/foc/core/PMSM_FOC_Core.h

+ 4 - 1
Applications/foc/commands.c

@@ -12,6 +12,7 @@
 #include "foc/mc_error.h"
 #include "foc/motor/mot_params_ind.h"
 #include "foc/mc_config.h"
+#include "foc/motor/throttle.h"
 
 #ifdef CONFIG_DQ_STEP_RESPONSE
 extern float target_d;
@@ -70,7 +71,9 @@ static void process_ext_command(foc_cmd_body_t *command) {
 		u8 b0 = decode_u8(command->data);
 		u8 p_mode = decode_8bits(b0, 0, 1);
 		if (p_mode == 1) {
-			mc_start(CTRL_MODE_TRQ);
+			if (!mc_start(CTRL_MODE_TRQ)) {
+				mc_crit_err_add(FOC_START_Err_Code, (s16)(throttle_get_signal()*100.0f), (s16)PMSM_FOC_GetSpeed());
+			}
 		}else if (p_mode == 2) {
 			mc_stop();
 		}

+ 1 - 0
Applications/foc/core/PMSM_FOC_Core.h

@@ -80,6 +80,7 @@ typedef enum {
 	FOC_EV_MOT_Limit_L=FOC_CRIT_Err_Max + 1,
 	FOC_EV_MOS_Limit_L,
 	FOC_EV_THRO_START_V,
+	FOC_START_Err_Code,
 }FOC_EVENT_R_t;
 
 #define FOC_Cri_Err_Mask(err) (1<<(err))