From 04bc45b20048780cdf057cda48d71a18c0988a8b Mon Sep 17 00:00:00 2001 From: zhaohe Date: Tue, 25 Jun 2024 20:28:49 +0800 Subject: [PATCH] update --- .../subboard10_hbot_v2/subboard10_hbot_v2.cpp | 65 +++------------------- .../subboard70_incubation_turntable/pri_board.h | 19 +++---- 2 files changed, 16 insertions(+), 68 deletions(-) diff --git a/usrc/subboards/subboard10_hbot_v2/subboard10_hbot_v2.cpp b/usrc/subboards/subboard10_hbot_v2/subboard10_hbot_v2.cpp index 7cdd1c3..e80402f 100644 --- a/usrc/subboards/subboard10_hbot_v2/subboard10_hbot_v2.cpp +++ b/usrc/subboards/subboard10_hbot_v2/subboard10_hbot_v2.cpp @@ -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 /*********************************************************************************************************************** diff --git a/usrc/subboards/subboard70_incubation_turntable/pri_board.h b/usrc/subboards/subboard70_incubation_turntable/pri_board.h index 600590f..0941a36 100644 --- a/usrc/subboards/subboard70_incubation_turntable/pri_board.h +++ b/usrc/subboards/subboard70_incubation_turntable/pri_board.h @@ -13,15 +13,15 @@ #define EXT_INPUT_IO1 PD1, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true #define EXT_INPUT_IO2 PD2, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true #define EXT_INPUT_IO3 PD3, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true -#define EXT_INPUT_IO4 PD4, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true -#define EXT_INPUT_IO5 PD5, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true -#define EXT_INPUT_IO6 PD6, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true -#define EXT_INPUT_IO7 PD7, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true -#define EXT_INPUT_IO8 PD8, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true -#define EXT_INPUT_IO9 PD9, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true +#define EXT_INPUT_IO4 PD10, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true +#define EXT_INPUT_IO5 PD11, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true +#define EXT_INPUT_IO6 PinNull, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true +#define EXT_INPUT_IO7 PinNull, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true +#define EXT_INPUT_IO8 PinNull, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true +#define EXT_INPUT_IO9 PinNull, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true -#define EXT_OUTPUT_IO0 PinNull, ZGPIO::kMode_nopull, false /*mirror*/, true /*init val*/ -#define EXT_OUTPUT_IO1 PinNull, ZGPIO::kMode_nopull, false /*mirror*/, true /*init val*/ +#define EXT_OUTPUT_IO0 PD9, ZGPIO::kMode_nopull, true /*mirror*/, false /*init val*/ +#define EXT_OUTPUT_IO1 PD10, ZGPIO::kMode_nopull, true /*mirror*/, false /*init val*/ #define EXT_OUTPUT_IO2 PinNull, ZGPIO::kMode_nopull, false /*mirror*/, true /*init val*/ #define EXT_OUTPUT_IO3 PinNull, ZGPIO::kMode_nopull, false /*mirror*/, true /*init val*/ #define EXT_OUTPUT_IO4 PinNull, ZGPIO::kMode_nopull, false /*mirror*/, true /*init val*/ @@ -38,10 +38,9 @@ #define MOTOR1_CSN PA4 #define MOTOR1_ENN PB7 -#define MOTOR1_SPI_MODE_SELECT PB4 #define MOTOR1_REFL PD0 -#define MOTOR1_REFR PD1 +#define MOTOR1_REFR PinNull #define MOTOR1_REFL_MIRROR true #define MOTOR1_REFR_MIRROR true