Browse Source

update

master
zhaohe 2 years ago
parent
commit
a39ee1ce5a
  1. 9
      components/tmc/basic/tmc_ic_interface.hpp
  2. 4
      components/tmc/helpers/Config.h
  3. 1
      components/tmc/ic/tmc_driver_ic.hpp
  4. 27
      components/tmc/ic/ztmc4361A.hpp

9
components/tmc/basic/tmc_ic_interface.hpp

@ -3,11 +3,6 @@
namespace iflytop { namespace iflytop {
using namespace std; using namespace std;
class IStepperMotor; class IStepperMotor;
// class MotorEventListener {
// public:
// virtual void onEvent(IStepperMotor* motor, StepperMotorEvent event) = 0;
// };
class IStepperMotor { class IStepperMotor {
public: public:
IStepperMotor() {} IStepperMotor() {}
@ -57,8 +52,12 @@ class IStepperMotor {
virtual void setAcceleration(float accelerationpps2) = 0; // 设置最大加速度 virtual void setAcceleration(float accelerationpps2) = 0; // 设置最大加速度
virtual void setDeceleration(float accelerationpps2) = 0; // 设置最大减速度 virtual void setDeceleration(float accelerationpps2) = 0; // 设置最大减速度
virtual void setMotorShaft(bool reverse) = 0;
virtual bool isReachTarget() = 0; virtual bool isReachTarget() = 0;
virtual bool isStoped() = 0; virtual bool isStoped() = 0;
virtual void setIHOLD_IRUN(uint8_t ihold, uint8_t irun, uint16_t iholddelay) = 0;
}; };
} // namespace iflytop } // namespace iflytop

4
components/tmc/helpers/Config.h

@ -30,8 +30,8 @@ typedef struct
ConfigState state; ConfigState state;
uint8_t configIndex; uint8_t configIndex;
int32_t shadowRegister[TMC_REGISTER_COUNT]; int32_t shadowRegister[TMC_REGISTER_COUNT];
uint8_t (*reset) (void); // tmc-ic by:zhaohe
uint8_t (*restore) (void); // tmc-ic by:zhaohe
uint8_t (*reset) (void); // tmc-ic by:zhaohe
uint8_t (*restore) (void); // tmc-ic by:zhaohe
tmc_callback_config callback; tmc_callback_config callback;
uint8_t channel; uint8_t channel;
} ConfigurationTypeDef; } ConfigurationTypeDef;

1
components/tmc/ic/tmc_driver_ic.hpp

@ -39,7 +39,6 @@ class TMCDriverICInterface {
virtual void enableIC(bool enable) = 0; virtual void enableIC(bool enable) = 0;
virtual void setIHOLD_IRUN(uint8_t ihold, uint8_t irun, uint16_t iholddelay) = 0; virtual void setIHOLD_IRUN(uint8_t ihold, uint8_t irun, uint16_t iholddelay) = 0;
// register access // register access
virtual void writeDatagram(uint8_t address, uint8_t x1, uint8_t x2, uint8_t x3, uint8_t x4) = 0; virtual void writeDatagram(uint8_t address, uint8_t x1, uint8_t x2, uint8_t x3, uint8_t x4) = 0;
virtual void writeInt(uint8_t address, int32_t value) = 0; virtual void writeInt(uint8_t address, int32_t value) = 0;

27
components/tmc/ic/ztmc4361A.hpp

@ -8,7 +8,6 @@
#include "../basic/tmc_ic_interface.hpp" #include "../basic/tmc_ic_interface.hpp"
#include "sdk/os/zos.hpp" #include "sdk/os/zos.hpp"
#include "tmc_driver_ic.hpp" #include "tmc_driver_ic.hpp"
extern "C" { extern "C" {
#include "TMC2160\TMC2160.h" #include "TMC2160\TMC2160.h"
@ -68,15 +67,15 @@ class TMC4361A : public IStepperMotor {
TMC4361A(/* args */); TMC4361A(/* args */);
/******************************************************************************* /*******************************************************************************
* ?? *
* *
*******************************************************************************/ *******************************************************************************/
/** /**
* @brief TMC4361A配置参数,使 * @brief TMC4361A配置参数,使
* *
* : * :
* 1. 使??
* 2. ??
* 1. 使
* 2.
* @param config * @param config
*/ */
@ -99,22 +98,22 @@ class TMC4361A : public IStepperMotor {
virtual void setAcceleration(float accelerationpps2); // 设置最大加速度 virtual void setAcceleration(float accelerationpps2); // 设置最大加速度
virtual void setDeceleration(float accelerationpps2); // 设置最大减速度 virtual void setDeceleration(float accelerationpps2); // 设置最大减速度
virtual void setIHOLD_IRUN(uint8_t ihold, uint8_t irun, uint16_t iholddelay) { driverIC_setIHOLD_IRUN(ihold, irun, iholddelay); }
virtual void setMotorShaft(bool reverse) { driverIC_setMotorShaft(reverse); }
/******************************************************************************* /*******************************************************************************
* * * *
*******************************************************************************/ *******************************************************************************/
/** /**
* @brief ??
* @brief
* *
* @param channel SPI通道??
* @param driver_ic_type ??
* @param channel SPI通道
* @param driver_ic_type
*/ */
int32_t readICVersion(); int32_t readICVersion();
uint8_t reset(); uint8_t reset();
uint8_t restore(); uint8_t restore();
/******************************************************************************* /*******************************************************************************
* ?? *
*******************************************************************************/
/*******************************************************************************
* * * *
*******************************************************************************/ *******************************************************************************/
void writeDatagram(uint8_t address, uint8_t x1, uint8_t x2, uint8_t x3, uint8_t x4); void writeDatagram(uint8_t address, uint8_t x1, uint8_t x2, uint8_t x3, uint8_t x4);
@ -123,8 +122,8 @@ class TMC4361A : public IStepperMotor {
void readWriteCover(uint8_t *data, size_t length); void readWriteCover(uint8_t *data, size_t length);
void writeSubRegister(uint8_t address, uint32_t mask, uint32_t shift, uint32_t value); void writeSubRegister(uint8_t address, uint32_t mask, uint32_t shift, uint32_t value);
int32_t getENC_POS_DEV(); // ENC_POS和XACTUAL的偏差??
uint32_t readEVENTS(); // 读取事件寄存??
int32_t getENC_POS_DEV(); // ENC_POS和XACTUAL的偏差
uint32_t readEVENTS(); // 读取事件寄存
/******************************************************* /*******************************************************
* driverIc function * * driverIc function *
*******************************************************/ *******************************************************/
@ -137,12 +136,8 @@ class TMC4361A : public IStepperMotor {
void tmc4361AConfigCallback(ConfigState state); void tmc4361AConfigCallback(ConfigState state);
void readWriteArray(uint8_t *data, size_t length); void readWriteArray(uint8_t *data, size_t length);
void setIHOLD_IRUN(uint8_t ihold, uint8_t irun, uint16_t iholddelay) { driverIC_setIHOLD_IRUN(ihold, irun, iholddelay); }
void setMotorShaft(bool reverse) { driverIC_setMotorShaft(reverse); }
private: private:
uint32_t haspassedms(uint32_t now, uint32_t last); uint32_t haspassedms(uint32_t now, uint32_t last);
// void callOnEventCallback(StepperMotorEvent event);
void driverIC_reset(); void driverIC_reset();
void driverIC_enableIC(bool enable); void driverIC_enableIC(bool enable);

Loading…
Cancel
Save