|
|
@@ -211,8 +211,8 @@ static void _led_off_timer_handler(shark_timer_t *t) {
|
|
|
}
|
|
|
|
|
|
|
|
|
-static void mc_gear_vmode_changed(void) {
|
|
|
- gear_t *gears = mc_get_gear_config();
|
|
|
+static void mc_gear_mode_set(void) {
|
|
|
+ gear_t *gears = mc_gear_conf();
|
|
|
if (gears != &sensorless_gear) {
|
|
|
sensorless_gear.max_torque = gears->max_torque;
|
|
|
}else { //slowly changed
|
|
|
@@ -260,7 +260,7 @@ gear_t *mc_get_gear_config_by_gear(u8 n_gear) {
|
|
|
return &gears[n_gear];
|
|
|
}
|
|
|
|
|
|
-gear_t *mc_get_gear_config(void) {
|
|
|
+gear_t *mc_gear_conf(void) {
|
|
|
return mc_get_gear_config_by_gear(motor.n_gear);
|
|
|
}
|
|
|
|
|
|
@@ -380,9 +380,9 @@ bool mc_start(u8 mode) {
|
|
|
throttle_torque_reset();
|
|
|
motor_encoder_start(true);
|
|
|
mot_contrl_start(&motor.controller, mode);
|
|
|
- mot_contrl_set_torque_ramp_time(&motor.controller, mc_get_gear_config()->zero_accl, mc_conf()->c.thro_dec_time);
|
|
|
+ mot_contrl_set_torque_ramp_time(&motor.controller, mc_gear_conf()->zero_accl, mc_conf()->c.thro_dec_time);
|
|
|
mc_set_ebrk_level(motor.u_set.ebrk_lvl);
|
|
|
- mc_gear_vmode_changed();
|
|
|
+ mc_gear_mode_set();
|
|
|
cpu_exit_critical(mask);
|
|
|
|
|
|
pwm_turn_on_low_side();
|
|
|
@@ -461,7 +461,7 @@ bool mc_set_gear(u8 gear) {
|
|
|
if (motor.n_gear != gear) {
|
|
|
u32 mask = cpu_enter_critical();
|
|
|
motor.n_gear = gear;
|
|
|
- mc_gear_vmode_changed();
|
|
|
+ mc_gear_mode_set();
|
|
|
cpu_exit_critical(mask);
|
|
|
}
|
|
|
return true;
|
|
|
@@ -530,7 +530,7 @@ void mc_set_idc_limit(s16 limit) {
|
|
|
return;
|
|
|
}
|
|
|
motor.u_set.idc_lim = limit;
|
|
|
- mc_gear_vmode_changed();
|
|
|
+ mc_gear_mode_set();
|
|
|
}
|
|
|
|
|
|
void mc_set_rpm_limit(s16 limit) {
|
|
|
@@ -538,7 +538,7 @@ void mc_set_rpm_limit(s16 limit) {
|
|
|
return;
|
|
|
}
|
|
|
motor.u_set.rpm_lim = limit;
|
|
|
- mc_gear_vmode_changed();
|
|
|
+ mc_gear_mode_set();
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -638,7 +638,7 @@ bool mc_start_epm(bool epm) {
|
|
|
mot_contrl_request_mode(&motor.controller, CTRL_MODE_TRQ);
|
|
|
mot_contrl_set_torque_limit_rttime(&motor.controller, CONFIG_LIMIT_RAMP_TIME);
|
|
|
mot_contrl_set_vel_rttime(&motor.controller, CONFIG_CRUISE_RAMP_TIME);
|
|
|
- mc_gear_vmode_changed();
|
|
|
+ mc_gear_mode_set();
|
|
|
}
|
|
|
cpu_exit_critical(mask);
|
|
|
|
|
|
@@ -672,7 +672,7 @@ bool mc_start_epm_move(epm_dir_t dir, bool is_command) {
|
|
|
|
|
|
if (!mot_contrl_is_start(&motor.controller)) {
|
|
|
mot_contrl_start(&motor.controller, motor.mode);
|
|
|
- mc_gear_vmode_changed();
|
|
|
+ mc_gear_mode_set();
|
|
|
pwm_enable_channel();
|
|
|
}else if (mot_contrl_is_auto_holdding(&motor.controller)) {
|
|
|
mc_auto_hold(false);
|
|
|
@@ -1473,7 +1473,7 @@ static void mc_motor_runstop(void) {
|
|
|
if (!mot_contrl_is_start(&motor.controller) && mc_can_restart_foc()) {
|
|
|
mask = cpu_enter_critical();
|
|
|
mot_contrl_start(&motor.controller, motor.mode);
|
|
|
- mc_gear_vmode_changed();
|
|
|
+ mc_gear_mode_set();
|
|
|
throttle_torque_reset();
|
|
|
pwm_enable_channel();
|
|
|
g_meas_foc.first = true;
|
|
|
@@ -1561,7 +1561,7 @@ void Sched_MC_mTask(void) {
|
|
|
}
|
|
|
bool sensor_less = !foc_observer_is_encoder();
|
|
|
if (mc_detect_vbus_mode() || (limted == FOC_LIM_CHANGE_L) || (_sensorless_run != sensor_less)) {
|
|
|
- mc_gear_vmode_changed();
|
|
|
+ mc_gear_mode_set();
|
|
|
if (sensor_less && foc_observer_sensorless_stable()) {//unstable 记录在ADC中断处理中
|
|
|
if (motor_encoder_may_error() == ENCODER_PWM_ERR) {
|
|
|
mc_set_critical_error(FOC_CRIT_Encoder_Err);
|
|
|
@@ -1580,7 +1580,7 @@ void Sched_MC_mTask(void) {
|
|
|
/* 如果取消高温,欠压等限流需要释放转把后才生效,确保不会突然加速 */
|
|
|
if (motor.b_limit_pending && mc_throttle_released()) {
|
|
|
motor.b_limit_pending = false;
|
|
|
- mc_gear_vmode_changed();
|
|
|
+ mc_gear_mode_set();
|
|
|
}
|
|
|
/* 堵转处理 */
|
|
|
if (mc_run_stall_process(runMode) || (motor.mode == CTRL_MODE_CURRENT)) {
|