|
|
@ -8,7 +8,6 @@ |
|
|
|
|
|
|
|
#include "../basic/tmc_ic_interface.hpp"
|
|
|
|
#include "sdk/os/zos.hpp"
|
|
|
|
|
|
|
|
#include "tmc_driver_ic.hpp"
|
|
|
|
extern "C" { |
|
|
|
#include "TMC2160\TMC2160.h"
|
|
|
@ -68,15 +67,15 @@ class TMC4361A : public IStepperMotor { |
|
|
|
TMC4361A(/* args */); |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* 初始化相关方?? * |
|
|
|
* 初始化相关方 * |
|
|
|
*******************************************************************************/ |
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief 静态方法,创建默认的TMC4361A配置参数,使用时只需修改自己需要的参数即可 |
|
|
|
* |
|
|
|
* 注意: |
|
|
|
* 1. 该方法内部使用的是一个静态变量,所以每次调用该方法时,返回的都是同一个对象的地址?? |
|
|
|
* 2. 该方法返回的数值不需要被释放?? |
|
|
|
* 1. 该方法内部使用的是一个静态变量,所以每次调用该方法时,返回的都是同一个对象的地址 |
|
|
|
* 2. 该方法返回的数值不需要被释放 |
|
|
|
* @param config |
|
|
|
*/ |
|
|
|
|
|
|
@ -99,22 +98,22 @@ class TMC4361A : public IStepperMotor { |
|
|
|
virtual void setAcceleration(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(); |
|
|
|
uint8_t reset(); |
|
|
|
uint8_t restore(); |
|
|
|
/*******************************************************************************
|
|
|
|
* 常用寄存器读写方?? * |
|
|
|
*******************************************************************************/ |
|
|
|
/*******************************************************************************
|
|
|
|
* 驱动器寄存器读写方法 * |
|
|
|
*******************************************************************************/ |
|
|
|
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 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 * |
|
|
|
*******************************************************/ |
|
|
@ -137,12 +136,8 @@ class TMC4361A : public IStepperMotor { |
|
|
|
void tmc4361AConfigCallback(ConfigState state); |
|
|
|
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: |
|
|
|
uint32_t haspassedms(uint32_t now, uint32_t last); |
|
|
|
// void callOnEventCallback(StepperMotorEvent event);
|
|
|
|
|
|
|
|
void driverIC_reset(); |
|
|
|
void driverIC_enableIC(bool enable); |
|
|
|