|
|
@ -104,12 +104,22 @@ void Hardware::initialize(int deviceId) { |
|
|
|
m_motor1.initialize(&cfg); |
|
|
|
int32_t chipv = m_motor1.readChipVERSION(); |
|
|
|
ZLOGI(TAG, "m_motor1:%lx", chipv); |
|
|
|
|
|
|
|
while (!m_motor1.ping()) { |
|
|
|
ZLOGI(TAG, "waitting for motor1 become ready"); |
|
|
|
HAL_Delay(100); |
|
|
|
} |
|
|
|
m_motor1.reInitialize(); |
|
|
|
|
|
|
|
m_motor1.setIHOLD_IRUN(1, 20, 0); |
|
|
|
m_motor1.setMotorShaft(true); |
|
|
|
|
|
|
|
m_motor1.setAcceleration(300000); |
|
|
|
m_motor1.setDeceleration(300000); |
|
|
|
// m_motor1.rotate(1000000);
|
|
|
|
|
|
|
|
auto gstate = m_motor1.getGState(); |
|
|
|
ZLOGI(TAG, "motor1: reset:%d drv_err:%d uv_cp:%d", gstate.reset, gstate.drv_err, gstate.uv_cp); |
|
|
|
} |
|
|
|
|
|
|
|
{ |
|
|
@ -118,11 +128,22 @@ void Hardware::initialize(int deviceId) { |
|
|
|
m_motor2.initialize(&cfg); |
|
|
|
int32_t chipv = m_motor2.readChipVERSION(); |
|
|
|
ZLOGI(TAG, "m_motor2:%lx", chipv); |
|
|
|
|
|
|
|
while (!m_motor2.ping()) { |
|
|
|
ZLOGI(TAG, "waitting for motor2 become ready"); |
|
|
|
HAL_Delay(100); |
|
|
|
} |
|
|
|
|
|
|
|
m_motor2.reInitialize(); |
|
|
|
|
|
|
|
m_motor2.setIHOLD_IRUN(1, 20, 0); // 5W
|
|
|
|
m_motor2.setMotorShaft(true); |
|
|
|
|
|
|
|
m_motor2.setAcceleration(300000); |
|
|
|
m_motor2.setDeceleration(300000); |
|
|
|
|
|
|
|
auto gstate = m_motor2.getGState(); |
|
|
|
ZLOGI(TAG, "motor2: reset:%d drv_err:%d uv_cp:%d", gstate.reset, gstate.drv_err, gstate.uv_cp); |
|
|
|
// m_motor2.rotate(1000000);
|
|
|
|
} |
|
|
|
|
|
|
@ -377,3 +398,6 @@ int32_t Hardware::process_rx_packet(from_where_t fromwhere, uint8_t *packet, int |
|
|
|
return 0; |
|
|
|
} |
|
|
|
void Hardware::loop() {} |
|
|
|
|
|
|
|
TMC5130 *Hardware::getMotor1() { return &m_motor1; } |
|
|
|
TMC5130 *Hardware::getMotor2() { return &m_motor2; } |