From e86c7fff197ea63a9956962ec91f172206d07d6d Mon Sep 17 00:00:00 2001 From: zhaohe Date: Sat, 8 Jun 2024 22:06:46 +0800 Subject: [PATCH] update --- components/tmc/ic/ztmc4361A.cpp | 47 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/components/tmc/ic/ztmc4361A.cpp b/components/tmc/ic/ztmc4361A.cpp index 8b156fc..53e9b4f 100644 --- a/components/tmc/ic/ztmc4361A.cpp +++ b/components/tmc/ic/ztmc4361A.cpp @@ -235,12 +235,59 @@ uint8_t TMC4361A::reset() { zchip_clock_early_delayus(1000); SET_PIN(m_resetPin, true); + tmc4361_writeInt(TMC4361A_RESET_REG, 0x525354); + zchip_clock_early_delayus(1000); + tmc4361_writeInt(TMC4361A_RESET_REG, 0); + + /** + * @brief 重置芯片镜像寄存?? + * + */ + for (uint32_t add = 0; add < TMC4361A_REGISTER_COUNT; add++) { + if (!TMC_IS_RESETTABLE(m_registerAccessTable[add])) { + continue; + } + tmc4361_writeInt(add, m_defaultRegisterResetState[add]); + } + + uint8_t driver, dataLength; + uint32_t value; + // Setup SPI + switch (m_driver_ic_type) { + case IC_TMC2130: + case IC_TMC2160: + driver = 0x0C; + dataLength = 0; + break; + case IC_TMC2660: + driver = 0x0B; + dataLength = 0; + break; + default: + driver = 0x0F; + dataLength = 40; + break; + } + value = 0x44400040 | (dataLength << 13) | (driver << 0); + tmc4361_writeInt(TMC4361A_SPIOUT_CONF, value); + tmc4361_writeInt(TMC4361A_CURRENT_CONF, 0x00000003); + tmc4361_writeInt(TMC4361A_SCALE_VALUES, 0x00000000); + return 1; +#if 0 + + // Pulse the low-active hardware reset pin + stop(); + SET_PIN(m_resetPin, false); + zchip_clock_early_delayus(1000); + SET_PIN(m_resetPin, true); + // 软件复位 tmc4361_writeInt(TMC4361A_RESET_REG, 0x525354); zchip_clock_early_delayus(1000); tmc4361_writeInt(TMC4361A_RESET_REG, 0); init(); +#endif // 发送 0x4440128C to SPI_OUT_CONF 寄存器 0x04。 // 发送 0xEC 到 COVER_HIGH 寄存器 0x6D 及 0x000100C3 到 COVER_LOW 寄存器 0x6C。