|
|
@ -48,12 +48,29 @@ static void onMotorMonitorTimer(void const* argument) { |
|
|
|
zcanbus_send_emergency_report(kreport_exception_error, (uint8_t*)&data, sizeof(data), 100); |
|
|
|
} |
|
|
|
} else { |
|
|
|
auto gstate = DEVICE->motor(i)->getGState(); |
|
|
|
bool flag = gstate.reset || gstate.drv_err || gstate.uv_cp; |
|
|
|
auto gstate = DEVICE->motor(i)->getGState(); |
|
|
|
auto gstatus = DEVICE->motor(i)->getDevStatus(); |
|
|
|
bool flag = gstate.reset || gstate.drv_err || gstate.uv_cp; |
|
|
|
if (!flag && estate) { |
|
|
|
motorErrorFlag_set(i, false); |
|
|
|
} else if (flag && !estate) { |
|
|
|
ZLOGE(TAG, "motor %d error, reset %d, drv_err %d, uv_cp %d", i, gstate.reset, gstate.drv_err, gstate.uv_cp); |
|
|
|
|
|
|
|
ZLOGE(TAG, "motor %d sg_result :%d ", i, gstatus.sg_result); |
|
|
|
ZLOGE(TAG, "motor %d reserved0 :%d ", i, gstatus.reserved0); |
|
|
|
ZLOGE(TAG, "motor %d fsactive :%d ", i, gstatus.fsactive); |
|
|
|
ZLOGE(TAG, "motor %d cs_actual :%d ", i, gstatus.cs_actual); |
|
|
|
ZLOGE(TAG, "motor %d reserved1 :%d ", i, gstatus.reserved1); |
|
|
|
ZLOGE(TAG, "motor %d stallguard :%d ", i, gstatus.stallguard); |
|
|
|
ZLOGE(TAG, "motor %d ot :%d ", i, gstatus.ot); |
|
|
|
ZLOGE(TAG, "motor %d otpw :%d ", i, gstatus.otpw); |
|
|
|
ZLOGE(TAG, "motor %d s2ga :%d ", i, gstatus.s2ga); |
|
|
|
ZLOGE(TAG, "motor %d s2gb :%d ", i, gstatus.s2gb); |
|
|
|
ZLOGE(TAG, "motor %d ola :%d ", i, gstatus.ola); |
|
|
|
ZLOGE(TAG, "motor %d olb :%d ", i, gstatus.olb); |
|
|
|
ZLOGE(TAG, "motor %d stst :%d ", i, gstatus.stst); |
|
|
|
|
|
|
|
DEVICE->motor(i)->setdriErr(true); |
|
|
|
if (gstate.reset) { |
|
|
|
data.ecode = kerr_motor_reset_error; |
|
|
|
} else if (gstate.uv_cp) { |
|
|
@ -120,6 +137,7 @@ void TmcMotorGroup::initialize(Pin_t tmcPowerPin, TMC51X0Cfg cfg0, TMC51X0Cfg cf |
|
|
|
BIND_FN(TmcMotorGroup, this, fn_pump_set_subic_reg); |
|
|
|
BIND_FN(TmcMotorGroup, this, fn_pump_get_subic_reg); |
|
|
|
BIND_FN(TmcMotorGroup, this, fn_pump_ping); |
|
|
|
BIND_FN(TmcMotorGroup, this, fn_pump_is_run); |
|
|
|
} |
|
|
|
|
|
|
|
#define MOTOR_CHECK() \
|
|
|
@ -225,3 +243,10 @@ void TmcMotorGroup::fn_pump_ping(ProcessContext* cxt) { |
|
|
|
MOTOR_CHECK(); |
|
|
|
zcanbus_send_ack(cxt->packet, NULL, 0); |
|
|
|
} |
|
|
|
void TmcMotorGroup::fn_pump_is_run(ProcessContext* cxt) { |
|
|
|
CHECK_PARAM_LEN(PRAAM_LEN(), 1); |
|
|
|
MOTOR_CHECK(); |
|
|
|
auto state = motor(GET_PARAM(0))->getRampStat(); |
|
|
|
int32_t isRun = motor(GET_PARAM(0))->isReachTarget(&state); |
|
|
|
zcanbus_send_ack(cxt->packet, isRun); |
|
|
|
} |