|
|
@@ -14,6 +14,7 @@
|
|
|
#include "foc/core/F_Calc.h"
|
|
|
#include "foc/core/etcs.h"
|
|
|
#include "app/nv_storage.h"
|
|
|
+#include "app/factory.h"
|
|
|
#include "foc/motor/mot_params_ind.h"
|
|
|
#include "foc/motor/throttle.h"
|
|
|
#include "foc/limit.h"
|
|
|
@@ -32,7 +33,7 @@ static void _encoder_zero_off_timer_handler(shark_timer_t *);
|
|
|
static shark_timer_t _encoder_zero_off_timer = TIMER_INIT(_encoder_zero_off_timer, _encoder_zero_off_timer_handler);
|
|
|
static void _led_off_timer_handler(shark_timer_t *);
|
|
|
static shark_timer_t _led_off_timer = TIMER_INIT(_led_off_timer, _led_off_timer_handler);
|
|
|
-m_contrl_t motor = {
|
|
|
+motor_t motor = {
|
|
|
.s_direction = POSITIVE,
|
|
|
.n_gear = 0,
|
|
|
.b_high_vol_mode = false,
|
|
|
@@ -87,6 +88,10 @@ static void MC_Check_MosVbusThrottle(void) {
|
|
|
sys_debug("ibus offset %d\n", offset);
|
|
|
sample_ibus_offset(offset);
|
|
|
|
|
|
+ if (factory_is_running()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
gpio_phase_u_detect(false);
|
|
|
float abc[3];
|
|
|
get_phase_vols_filtered(abc);
|
|
|
@@ -125,6 +130,9 @@ static void MC_Check_MosVbusThrottle(void) {
|
|
|
static int hw_brk_err_cnt = 0;
|
|
|
static int hw_brk_no_err_cnt = 0;
|
|
|
static u32 _self_check_task(void *p) {
|
|
|
+ if (factory_is_running()) {
|
|
|
+ return 1000;
|
|
|
+ }
|
|
|
if (get_tick_ms() < 500) { //启动500ms内检测刹车状态是否正常,应该是没有刹车
|
|
|
if (mc_detect_hwbrake() && hw_brk_err_cnt++ >= 60) {
|
|
|
mc_set_critical_error(FOC_CRIT_BRK_Err);
|
|
|
@@ -244,7 +252,7 @@ void mc_init(void) {
|
|
|
shark_timer_post(&_led_off_timer, 5000);
|
|
|
}
|
|
|
|
|
|
-m_contrl_t * mc_params(void) {
|
|
|
+motor_t * get_motor(void) {
|
|
|
return &motor;
|
|
|
}
|
|
|
|
|
|
@@ -1586,6 +1594,10 @@ void Sched_MC_mTask(void) {
|
|
|
/* 母线电流,实际采集的相电流矢量大小的计算 */
|
|
|
mot_contrl_calc_current(&motor.controller);
|
|
|
|
|
|
+ if (factory_is_running()) {
|
|
|
+ motor.n_CritiCalErrMask = 0;
|
|
|
+ return;
|
|
|
+ }
|
|
|
if ((mot_contrl_get_dc_current(&motor.controller) > (CONFIG_HW_MAX_DC_CURRENT * 1.1f)) || (mot_contrl_get_dc_current(&motor.controller) < CONFIG_HW_MAX_CHRG_CURRENT)) {
|
|
|
vbus_err_cnt ++;
|
|
|
if (vbus_err_cnt >= 5) {
|