|
|
@ -12,6 +12,7 @@ |
|
|
|
//
|
|
|
|
// port_tmc_DRV_ENN_pin_set_state
|
|
|
|
|
|
|
|
using namespace iflytop; |
|
|
|
class TMC4361AImpl : public TMC4361A { |
|
|
|
protected: |
|
|
|
virtual void setResetPinState(bool state) { port_tmc_nRESET_pin_set_state(m_channel, state); }; |
|
|
@ -37,7 +38,6 @@ class TMC2160Impl : public TMC2160 { |
|
|
|
virtual void sleepus(int32_t us) { port_delay_us(us); }; |
|
|
|
virtual void readWriteArray(uint8_t *data, size_t length) { m_tmc4361->readWriteCover(data, length); }; |
|
|
|
}; |
|
|
|
|
|
|
|
static TMC4361AImpl tmc4361motor1; |
|
|
|
static TMC2160Impl tmc2160motor1; |
|
|
|
|
|
|
@ -48,8 +48,14 @@ int umain(int argc, char const *argv[]) { |
|
|
|
port_tmc_extern_clk_enable(); |
|
|
|
// tmc4361motor1.init();
|
|
|
|
|
|
|
|
tmc4361motor1.initialize(MOTOR_1_TMC4361A_CHANNEL, TMC4361A::IC_TMC2160); |
|
|
|
TMC4361AImpl::TMC4361AConfig_t *tmc4361aconfig = TMC4361AImpl::createDeafultTMC4361AConfig(); |
|
|
|
|
|
|
|
tmc4361motor1.initialize(MOTOR_1_TMC4361A_CHANNEL, TMC4361A::IC_TMC2160, tmc4361aconfig); |
|
|
|
tmc2160motor1.initialize(MOTOR_1_TMC2160_CHANNEL, &tmc4361motor1); |
|
|
|
|
|
|
|
// 2160初始化
|
|
|
|
tmc2160motor1.setMaximumCurrent(3); |
|
|
|
|
|
|
|
HAL_Delay(100); |
|
|
|
tmc4361motor1.enableIC(true); |
|
|
|
tmc2160motor1.enableIC(true); |
|
|
@ -60,14 +66,18 @@ int umain(int argc, char const *argv[]) { |
|
|
|
int32_t ic4361Version = tmc4361motor1.readICVersion(); |
|
|
|
int32_t ic2160Version = tmc2160motor1.readICVersion(); |
|
|
|
// 期望 4361Version:2 ic2160Version:30
|
|
|
|
ZLOGI(TAG, "4361Version:%x ic2160Version:%x", ic4361Version, ic2160Version); |
|
|
|
ZLOGI(TAG, "TMC4361Version:%x TMC2160VERSION:%x", ic4361Version, ic2160Version); |
|
|
|
|
|
|
|
tmc4361motor1.setMaximumAcceleration(300000); |
|
|
|
tmc4361motor1.setMaximumDeceleration(300000); |
|
|
|
tmc4361motor1.rotate(100000); |
|
|
|
tmc4361motor1.moveTo(41370340, 500000); |
|
|
|
|
|
|
|
while (true) { |
|
|
|
port_do_debug_light_state(); |
|
|
|
HAL_Delay(30); |
|
|
|
int32_t encpos = tmc4361motor1.getENC_POS(); |
|
|
|
int32_t xactual = tmc4361motor1.getXACTUAL(); |
|
|
|
ZLOGI(TAG, "encpos:%d xactual:%d %d", encpos, xactual, tmc4361motor1.getENC_POS_DEV()); |
|
|
|
} |
|
|
|
return 0; |
|
|
|
} |
|
|
|