|
|
@ -29,7 +29,6 @@ void Subboard10HbotV2::initialize() { |
|
|
|
static ZGPIO motorPowerEnPin; |
|
|
|
static ZGPIO motor1ENNPin; |
|
|
|
static ZGPIO motor2ENNPin; |
|
|
|
|
|
|
|
static ZGPIO TMC51X0_1_SPI_MODE; |
|
|
|
static ZGPIO TMC51X0_1_SD_MODE; |
|
|
|
static ZGPIO TMC51X0_2_SPI_MODE; |
|
|
@ -37,68 +36,18 @@ void Subboard10HbotV2::initialize() { |
|
|
|
|
|
|
|
motor1ENNPin.initAsOutput(MOTOR1_ENN, iflytop::ZGPIO::kMode_nopull, false, true); |
|
|
|
motor2ENNPin.initAsOutput(MOTOR2_ENN, iflytop::ZGPIO::kMode_nopull, false, true); |
|
|
|
TMC51X0_1_SPI_MODE.initAsOutput(PB3, iflytop::ZGPIO::kMode_nopull, false, true); |
|
|
|
TMC51X0_1_SD_MODE.initAsOutput(PB4, iflytop::ZGPIO::kMode_nopull, false, false); |
|
|
|
TMC51X0_2_SPI_MODE.initAsOutput(PE11, iflytop::ZGPIO::kMode_nopull, false, true); |
|
|
|
TMC51X0_2_SD_MODE.initAsOutput(PE12, iflytop::ZGPIO::kMode_nopull, false, false); |
|
|
|
|
|
|
|
motorPowerEnPin.initAsOutput(PB12, iflytop::ZGPIO::kMode_nopull, true, true); |
|
|
|
|
|
|
|
osDelay(100); |
|
|
|
|
|
|
|
// #define MOTOR1_CSN PA4
|
|
|
|
// #define MOTOR1_ENN PB7
|
|
|
|
// #define MOTOR1_SPI_MODE_SELECT PB4
|
|
|
|
// #define MOTOR1_nFREEZE_IO PE12
|
|
|
|
// #define MOTOR1_nRESET_IO PinNull
|
|
|
|
TMC5130_MOTOR_INITER(/*motorid*/ 1, /*moduleid*/ 1); |
|
|
|
TMC5130_MOTOR_INITER(/*motorid*/ 2, /*moduleid*/ 2); |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
static TMC51X0 motor; |
|
|
|
static StepMotorCtrlModule module; |
|
|
|
int subid = 1; |
|
|
|
TMC51X0::cfg_t tmc5130cfg = { |
|
|
|
.spi = &hspi1, |
|
|
|
.csgpio = PA4, |
|
|
|
.ennPin = PB7 |
|
|
|
}; |
|
|
|
motor.initialize(&tmc5130cfg); |
|
|
|
motor.setIHOLD_IRUN(1, 3, 100); |
|
|
|
motor.enable(true); |
|
|
|
motor.rotate(800); |
|
|
|
// motor.setMotorShaft(false);
|
|
|
|
// static ZGPIO input[2];
|
|
|
|
// input[0].initAsInput(PD0, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true);
|
|
|
|
// input[1].initAsInput(PD1, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true);
|
|
|
|
// StepMotorCtrlModule::config_t stepcfg = {0};
|
|
|
|
// StepMotorCtrlModule::create_default_cfg(stepcfg);
|
|
|
|
// stepcfg.motor_shaft = false;
|
|
|
|
// stepcfg.motor_one_circle_pulse = 10000;
|
|
|
|
// stepcfg.motor_one_circle_pulse_denominator = 1;
|
|
|
|
// stepcfg.stepmotor_ihold = 5;
|
|
|
|
// stepcfg.stepmotor_irun = 20;
|
|
|
|
// stepcfg.stepmotor_iholddelay = 10;
|
|
|
|
// stepcfg.stepmotor_iglobalscaler = 0;
|
|
|
|
// stepcfg.motor_default_velocity = 600;
|
|
|
|
// stepcfg.min_d = 0;
|
|
|
|
// stepcfg.max_d = 0;
|
|
|
|
// stepcfg.motor_run_to_zero_speed = 300;
|
|
|
|
// stepcfg.motor_look_zero_edge_speed = 200;
|
|
|
|
// stepcfg.motor_vstart = 100;
|
|
|
|
// stepcfg.motor_a1 = 50;
|
|
|
|
// stepcfg.motor_amax = 100;
|
|
|
|
// stepcfg.motor_v1 = 300;
|
|
|
|
// stepcfg.motor_dmax = 100;
|
|
|
|
// stepcfg.motor_d1 = 50;
|
|
|
|
// stepcfg.motor_vstop = 100;
|
|
|
|
// stepcfg.motor_tzerowait = 0;
|
|
|
|
// module.initialize(getmoduleId(subid), &motor, input, ((int32_t)(sizeof(input) / sizeof(input[0]))), &stepcfg);
|
|
|
|
// GService::inst()->getZCanProtocolParser()->registerModule(&module);
|
|
|
|
if (g_enable_log) { |
|
|
|
zos_log( |
|
|
|
"%08lu INFO [%-10s] " |
|
|
|
"motor%d readic version %x" |
|
|
|
"\n", |
|
|
|
zchip_clock_get_ticket(), "Subboard200ExtTmc5160", subid, motor.readICVersion()); |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
// { TMC5130_MOTOR_INITER(2, 2); }
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
/***********************************************************************************************************************
|
|
|
|