|
|
@ -42,7 +42,8 @@ static const uint8_t tmc5130_defaultRegisterAccess[TMC5130_REGISTER_COUNT] = { |
|
|
|
|
|
|
|
#define TMC51x0_ADDRESS(x) ((x) & (TMC5130_ADDRESS_MASK))
|
|
|
|
#define TAG "TMC51X0"
|
|
|
|
void TMC51X0::initialize(TMC51X0Cfg cfg) { |
|
|
|
void TMC51X0::initialize(int mid, TMC51X0Cfg cfg) { |
|
|
|
m_mid = mid; |
|
|
|
m_cfg = cfg; |
|
|
|
m_hspi = cfg.hspi; |
|
|
|
|
|
|
@ -211,6 +212,10 @@ void TMC51X0::moveToEnd(int32_t direction, uint32_t velocityMax) { |
|
|
|
void TMC51X0::moveBy(int32_t relativePosition, uint32_t velocityMax) { // determine actual position and add numbers of ticks to move
|
|
|
|
zlock_guard lkg(m_mutex); |
|
|
|
|
|
|
|
// m_mid
|
|
|
|
|
|
|
|
// ZLOGI(TAG, "m[%d] moveBy %d,%d", m_mid, relativePosition, velocityMax);
|
|
|
|
|
|
|
|
int32_t pos = getXACTUAL(); |
|
|
|
int32_t target = pos + relativePosition; |
|
|
|
moveTo(target, velocityMax); |
|
|
@ -264,7 +269,7 @@ bool TMC51X0::isTMC5130() { |
|
|
|
return chipId == kTMC5130; |
|
|
|
} |
|
|
|
|
|
|
|
TMC5130DevStatusReg_t TMC51X0::getDevStatus() { // R
|
|
|
|
TMC5130DevStatusReg_t TMC51X0::getDevStatus() { // R
|
|
|
|
zlock_guard lkg(m_mutex); |
|
|
|
static_assert(sizeof(TMC5130DevStatusReg_t) == 4); |
|
|
|
uint32_t value = readInt(TMC5130_DRVSTATUS); |
|
|
@ -272,7 +277,7 @@ TMC5130DevStatusReg_t TMC51X0::getDevStatus() { // R |
|
|
|
memcpy(&val, &value, sizeof(TMC5130DevStatusReg_t)); |
|
|
|
return val; |
|
|
|
} |
|
|
|
TMC5130GState_t TMC51X0::getGState() { // R+C
|
|
|
|
TMC5130GState_t TMC51X0::getGState() { // R+C
|
|
|
|
zlock_guard lkg(m_mutex); |
|
|
|
static_assert(sizeof(TMC5130GState_t) == 4); |
|
|
|
uint32_t value = readInt(TMC5130_GSTAT); |
|
|
@ -370,9 +375,6 @@ bool TMC51X0::setEncResolution(int32_t enc_resolution) { |
|
|
|
/**
|
|
|
|
* @brief |
|
|
|
* |
|
|
|
* 1.��电机是256细分 |
|
|
|
* 2.��TMC5130_ENC_CONST��进制模� |
|
|
|
* 3.å�?æ”?æŒ�指定分辨率的编ç �器 |
|
|
|
*/ |
|
|
|
|
|
|
|
int32_t enc_resolution_tmp = enc_resolution * 4; |
|
|
|