|
|
@ -4,6 +4,7 @@ |
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "a8000_protocol\protocol.hpp"
|
|
|
|
#include "sdk/components/tmc/ic/ztmc4361A.hpp"
|
|
|
|
#include "sdk\components\flash\znvs.hpp"
|
|
|
|
#include "sdk\components\tmc\ic\ztmc5130.hpp"
|
|
|
|
using namespace iflytop; |
|
|
@ -29,6 +30,14 @@ void StepMotorCtrlModule::initialize(int moduleid, IStepperMotor* stepM, ZGPIO i |
|
|
|
if (tmcmotor) { |
|
|
|
tmcmotor->getGState(); // 读取状态,清空下复位标识
|
|
|
|
} |
|
|
|
|
|
|
|
TMC4361A* tmc4361motor = dynamic_cast<TMC4361A*>(m_stepM1); |
|
|
|
if (tmc4361motor) { |
|
|
|
auto tmc4361state = tmc4361motor->getTMC4361AMotorEventState(); |
|
|
|
auto tmc4361status = tmc4361motor->getTMC4361AMotorStatus(); |
|
|
|
auto tmc2160Status = tmc4361motor->getTMC2160MotorDriverStatus(); |
|
|
|
auto tmc2160State = tmc4361motor->getTMC2160MotorGstate(); |
|
|
|
} |
|
|
|
} |
|
|
|
void StepMotorCtrlModule::create_default_cfg(config_t& cfg) { |
|
|
|
memset(&cfg, 0, sizeof(cfg)); |
|
|
@ -163,6 +172,47 @@ int32_t StepMotorCtrlModule::step_motor_read_tmc5130_status(int32_t* status) { |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
int32_t StepMotorCtrlModule::step_motor_read_tmc5130_state(int32_t* status) { |
|
|
|
TMC51X0* tmc5130 = dynamic_cast<TMC51X0*>(m_stepM1); |
|
|
|
if (tmc5130) { |
|
|
|
auto state = tmc5130->getGState(); |
|
|
|
memcpy(status, &state, sizeof(int32_t)); |
|
|
|
} |
|
|
|
return 0; |
|
|
|
}; |
|
|
|
int32_t StepMotorCtrlModule::step_motor_read_tmc4361a_status(int32_t* status) { |
|
|
|
TMC4361A* tmc4361 = dynamic_cast<TMC4361A*>(m_stepM1); |
|
|
|
if (tmc4361) { |
|
|
|
auto devStatus = tmc4361->getTMC4361AMotorStatus(); |
|
|
|
memcpy(status, &devStatus, sizeof(int32_t)); |
|
|
|
} |
|
|
|
return 0; |
|
|
|
}; |
|
|
|
int32_t StepMotorCtrlModule::step_motor_read_tmc4361a_state(int32_t* gstate) { |
|
|
|
TMC4361A* tmc4361 = dynamic_cast<TMC4361A*>(m_stepM1); |
|
|
|
if (tmc4361) { |
|
|
|
auto state = tmc4361->getTMC4361AMotorEventState(); |
|
|
|
memcpy(gstate, &state, sizeof(int32_t)); |
|
|
|
} |
|
|
|
return 0; |
|
|
|
}; |
|
|
|
int32_t StepMotorCtrlModule::step_motor_read_tmc2160_status(int32_t* status) { |
|
|
|
TMC4361A* tmc4361 = dynamic_cast<TMC4361A*>(m_stepM1); |
|
|
|
if (tmc4361) { |
|
|
|
auto devStatus = tmc4361->getTMC2160MotorDriverStatus(); |
|
|
|
memcpy(status, &devStatus, sizeof(int32_t)); |
|
|
|
} |
|
|
|
return 0; |
|
|
|
}; |
|
|
|
int32_t StepMotorCtrlModule::step_motor_read_tmc2160_state(int32_t* status) { |
|
|
|
TMC4361A* tmc4361 = dynamic_cast<TMC4361A*>(m_stepM1); |
|
|
|
if (tmc4361) { |
|
|
|
auto state = tmc4361->getTMC2160MotorGstate(); |
|
|
|
memcpy(status, &state, sizeof(int32_t)); |
|
|
|
} |
|
|
|
return 0; |
|
|
|
}; |
|
|
|
|
|
|
|
/***********************************************************************************************************************
|
|
|
|
* INTER * |
|
|
|
***********************************************************************************************************************/ |
|
|
@ -208,6 +258,55 @@ void StepMotorCtrlModule::dumpTMC5130Status(TMC51X0::DevStatusReg_t* status) { |
|
|
|
ZLOGE(TAG, "olb: %d", status->olb); |
|
|
|
ZLOGE(TAG, "stst: %d", status->stst); |
|
|
|
} |
|
|
|
void StepMotorCtrlModule::dump(TMC2160MotorDriverStatus_t val) { |
|
|
|
ZLOGE(TAG, "sg_result: %d", val.sg_result); |
|
|
|
ZLOGE(TAG, "s2vsa: %d", val.s2vsa); |
|
|
|
ZLOGE(TAG, "s2vsb: %d", val.s2vsb); |
|
|
|
ZLOGE(TAG, "stealth: %d", val.stealth); |
|
|
|
ZLOGE(TAG, "fsactive: %d", val.fsactive); |
|
|
|
ZLOGE(TAG, "cs_actual: %d", val.cs_actual); |
|
|
|
ZLOGE(TAG, "reserved2: %d", val.reserved2); |
|
|
|
ZLOGE(TAG, "stallguard: %d", val.stallguard); |
|
|
|
ZLOGE(TAG, "ot: %d", val.ot); |
|
|
|
ZLOGE(TAG, "otpw: %d", val.otpw); |
|
|
|
ZLOGE(TAG, "s2ga: %d", val.s2ga); |
|
|
|
ZLOGE(TAG, "s2gb: %d", val.s2gb); |
|
|
|
ZLOGE(TAG, "ola: %d", val.ola); |
|
|
|
ZLOGE(TAG, "olb: %d", val.olb); |
|
|
|
ZLOGE(TAG, "stst: %d", val.stst); |
|
|
|
} |
|
|
|
void StepMotorCtrlModule::dump(TMC4361AMotorStatus_t val) { |
|
|
|
|
|
|
|
ZLOGE(TAG, "TARGET_REACHED_F: %d", val.TARGET_REACHED_F); |
|
|
|
ZLOGE(TAG, "POS_COMP_REACHED_F: %d", val.POS_COMP_REACHED_F); |
|
|
|
ZLOGE(TAG, "VEL_REACHED_F: %d", val.VEL_REACHED_F); |
|
|
|
ZLOGE(TAG, "VEL_STATE_F: %d", val.VEL_STATE_F); |
|
|
|
ZLOGE(TAG, "RAMP_STATE_F: %d", val.RAMP_STATE_F); |
|
|
|
ZLOGE(TAG, "STOPL_ACTIVE_F: %d", val.STOPL_ACTIVE_F); |
|
|
|
ZLOGE(TAG, "STOPR_ACTIVE_F: %d", val.STOPR_ACTIVE_F); |
|
|
|
ZLOGE(TAG, "VSTOPL_ACTIVE_F: %d", val.VSTOPL_ACTIVE_F); |
|
|
|
ZLOGE(TAG, "VSTOPR_ACTIVE_F: %d", val.VSTOPR_ACTIVE_F); |
|
|
|
ZLOGE(TAG, "ACTIVE_STALL_F: %d", val.ACTIVE_STALL_F); |
|
|
|
ZLOGE(TAG, "HOME_ERROR_F: %d", val.HOME_ERROR_F); |
|
|
|
ZLOGE(TAG, "FS_ACTIVE_F: %d", val.FS_ACTIVE_F); |
|
|
|
ZLOGE(TAG, "ENC_FAIL_F: %d", val.ENC_FAIL_F); |
|
|
|
ZLOGE(TAG, "N_ACTIVE_F: %d", val.N_ACTIVE_F); |
|
|
|
ZLOGE(TAG, "ENC_LATCH_F: %d", val.ENC_LATCH_F); |
|
|
|
ZLOGE(TAG, "MULTI_CYCLE_FAIL_F: %d", val.MULTI_CYCLE_FAIL_F); |
|
|
|
ZLOGE(TAG, "___: %d", val.___); |
|
|
|
ZLOGE(TAG, "CL_FIT_F: %d", val.CL_FIT_F); |
|
|
|
ZLOGE(TAG, "SERIAL_ENC_FLAGS: %d", val.SERIAL_ENC_FLAGS); |
|
|
|
ZLOGE(TAG, "SG: %d", val.SG); |
|
|
|
ZLOGE(TAG, "OT: %d", val.OT); |
|
|
|
ZLOGE(TAG, "OTPW: %d", val.OTPW); |
|
|
|
ZLOGE(TAG, "S2GA: %d", val.S2GA); |
|
|
|
ZLOGE(TAG, "S2GB: %d", val.S2GB); |
|
|
|
ZLOGE(TAG, "OLA: %d", val.OLA); |
|
|
|
ZLOGE(TAG, "OLB: %d", val.OLB); |
|
|
|
ZLOGE(TAG, "STST: %d", val.STST); |
|
|
|
} |
|
|
|
void StepMotorCtrlModule::dump(TMC2160MotorGstate_t val) {} |
|
|
|
void StepMotorCtrlModule::dump(TMC4361AMotorEventState_t val) {} |
|
|
|
|
|
|
|
void StepMotorCtrlModule::setErrorFlag(int32_t ecode, uint32_t motorStatue) { |
|
|
|
creg.module_errorcode = ecode; |
|
|
|