|
|
@ -10,6 +10,7 @@ |
|
|
|
#include "sdk\components\flash\znvs.hpp"
|
|
|
|
//
|
|
|
|
#include "sdk/components/step_motor_ctrl_module/step_motor_ctrl_module.hpp"
|
|
|
|
#include "sdk\components\mini_servo_motor\mini_servo_motor_ctrl_module.hpp"
|
|
|
|
#include "sdk\components\pipette_module\pipette_ctrl_module_v2.hpp"
|
|
|
|
#include "sdk\components\sensors\m3078\m3078_code_scaner.hpp"
|
|
|
|
#include "sdk\components\sensors\tmp117\tmp117.hpp"
|
|
|
@ -19,6 +20,7 @@ |
|
|
|
#include "sdk\components\water_cooling_temperature_control_module\water_cooling_temperature_control_module.hpp"
|
|
|
|
#include "sdk\components\water_cooling_temperature_control_module\water_cooling_temperature_control_module_factory.cpp"
|
|
|
|
#include "sdk\components\water_cooling_temperature_control_module\water_cooling_temperature_control_module_factory.hpp"
|
|
|
|
#include "sdk\components\zcancmder\zcan_board_module.hpp"
|
|
|
|
// #include "M3078CodeScanner"
|
|
|
|
|
|
|
|
#define TAG "main"
|
|
|
@ -36,71 +38,133 @@ extern DMA_HandleTypeDef hdma_usart2_tx; |
|
|
|
static ZCanCmder g_zcanCmder; |
|
|
|
static ZIProtocolParser g_ziProtocolParser; |
|
|
|
//
|
|
|
|
static TMC5130 g_motor; |
|
|
|
static StepMotorCtrlModule g_stepMotorCtrlModule; |
|
|
|
static TMC5130 g_motor[3]; |
|
|
|
//
|
|
|
|
static PipetteModule g_pipetteModule; |
|
|
|
// USART4_TX
|
|
|
|
|
|
|
|
void init_and_reg_motor() { |
|
|
|
void initmodule() { |
|
|
|
osDelay(1000); |
|
|
|
|
|
|
|
{ |
|
|
|
static ZCanBoardModule::hardware_config_t cfg = { |
|
|
|
.input = |
|
|
|
{ |
|
|
|
{PD0, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, false}, |
|
|
|
{PD1, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, false}, |
|
|
|
{PD2, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, false}, |
|
|
|
{PD3, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, false}, |
|
|
|
{PD4, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, false}, |
|
|
|
{PD5, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, false}, |
|
|
|
{PD6, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, false}, |
|
|
|
{PD7, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, false}, |
|
|
|
{PD8, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, false}, |
|
|
|
}, |
|
|
|
}; |
|
|
|
static ZCanBoardModule boardmodule; |
|
|
|
boardmodule.initialize(BOARD_ID * 10 + 0, &cfg); |
|
|
|
g_ziProtocolParser.registerModule(&boardmodule); |
|
|
|
} |
|
|
|
|
|
|
|
{ |
|
|
|
static TMC5130 motor; |
|
|
|
static StepMotorCtrlModule stepMotorCtrlModule; |
|
|
|
|
|
|
|
TMC5130::cfg_t cfg = { |
|
|
|
.spi = &TMC_MOTOR_SPI, //
|
|
|
|
.csgpio = MOTOR0_CSN, //
|
|
|
|
.ennPin = MOTOR0_ENN, //
|
|
|
|
.spi_mode_select = MOTOR0_SPI_MODE_SELECT, //
|
|
|
|
}; |
|
|
|
motor.initialize(&cfg); |
|
|
|
motor.setMotorShaft(false); |
|
|
|
ZLOGI(TAG, "motora initialize 5160:%x ", motor.readICVersion()); |
|
|
|
|
|
|
|
static ZGPIO input[2]; |
|
|
|
input[0].initAsInput(MOTOR0_REFL /*REFL*/, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true); |
|
|
|
input[1].initAsInput(MOTOR0_REFR /*REFR*/, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true); |
|
|
|
|
|
|
|
stepMotorCtrlModule.initialize(BOARD_ID * 10 + 1, &motor, input, ZARRAY_SIZE(input), nullptr); |
|
|
|
g_ziProtocolParser.registerModule(&stepMotorCtrlModule); |
|
|
|
} |
|
|
|
|
|
|
|
{ |
|
|
|
static TMC5130 motor; |
|
|
|
static StepMotorCtrlModule stepMotorCtrlModule; |
|
|
|
|
|
|
|
TMC5130::cfg_t cfg = { |
|
|
|
.spi = &TMC_MOTOR_SPI, //
|
|
|
|
.csgpio = MOTOR1_CSN, //
|
|
|
|
.ennPin = MOTOR1_ENN, //
|
|
|
|
.spi_mode_select = MOTOR1_SPI_MODE_SELECT, //
|
|
|
|
}; |
|
|
|
g_motor.initialize(&cfg); |
|
|
|
g_motor.setMotorShaft(false); |
|
|
|
ZLOGI(TAG, "motora initialize 5160:%x ", g_motor.readICVersion()); |
|
|
|
motor.initialize(&cfg); |
|
|
|
motor.setMotorShaft(false); |
|
|
|
ZLOGI(TAG, "motora initialize 5160:%x ", motor.readICVersion()); |
|
|
|
|
|
|
|
static ZGPIO input[2]; |
|
|
|
input[0].initAsInput(MOTOR1_REFL /*REFL*/, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true); |
|
|
|
input[1].initAsInput(MOTOR1_REFR /*REFR*/, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true); |
|
|
|
|
|
|
|
stepMotorCtrlModule.initialize(BOARD_ID * 10 + 2, &motor, input, ZARRAY_SIZE(input), nullptr); |
|
|
|
g_ziProtocolParser.registerModule(&stepMotorCtrlModule); |
|
|
|
} |
|
|
|
|
|
|
|
g_motor.setAcceleration(100); |
|
|
|
g_motor.setDeceleration(100); |
|
|
|
g_motor.setIHOLD_IRUN(0, 8, 10); |
|
|
|
{ |
|
|
|
static TMC5130 motor; |
|
|
|
static StepMotorCtrlModule stepMotorCtrlModule; |
|
|
|
|
|
|
|
static ZGPIO input[10]; |
|
|
|
input[0].initAsInput(PD1 /*REFL*/, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true); |
|
|
|
input[1].initAsInput(PD2 /*REFR*/, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true); |
|
|
|
input[2].initAsInput(PD3 /*DIAG0*/, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true); |
|
|
|
input[3].initAsInput(PD4 /*DIAG1*/, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true); |
|
|
|
TMC5130::cfg_t cfg = { |
|
|
|
.spi = &TMC_MOTOR_SPI, //
|
|
|
|
.csgpio = MOTOR2_CSN, //
|
|
|
|
.ennPin = MOTOR2_ENN, //
|
|
|
|
.spi_mode_select = MOTOR2_SPI_MODE_SELECT, //
|
|
|
|
}; |
|
|
|
motor.initialize(&cfg); |
|
|
|
motor.setMotorShaft(false); |
|
|
|
ZLOGI(TAG, "motora initialize 5160:%x ", motor.readICVersion()); |
|
|
|
|
|
|
|
g_stepMotorCtrlModule.initialize(BOARD_ID * 10 + 1, &g_motor, input, ZARRAY_SIZE(input), MOTOR_CFG_FLASH_MARK); |
|
|
|
g_ziProtocolParser.registerModule(&g_stepMotorCtrlModule); |
|
|
|
} |
|
|
|
static ZGPIO input[2]; |
|
|
|
input[0].initAsInput(MOTOR2_REFL /*REFL*/, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true); |
|
|
|
input[1].initAsInput(MOTOR2_REFR /*REFR*/, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true); |
|
|
|
|
|
|
|
void init_and_reg_cliptip_module() { |
|
|
|
// # RS232输出压力流
|
|
|
|
// /1U2!0R\r
|
|
|
|
// # 设置移液枪最大行程100,防止设备误操作导致吸入液体到设备中
|
|
|
|
// /1u1,100R\r
|
|
|
|
PipetteModule::config_t cfg = { |
|
|
|
.limit_ul = 100, |
|
|
|
}; |
|
|
|
|
|
|
|
PipetteModule::hardward_config_t hardwarecfg = { |
|
|
|
.uart = &huart2, |
|
|
|
.hdma_rx = &hdma_usart2_rx, |
|
|
|
.hdma_tx = &hdma_usart2_tx, |
|
|
|
}; |
|
|
|
g_pipetteModule.initialize(BOARD_ID * 10 + 2, &cfg, &hardwarecfg); |
|
|
|
g_ziProtocolParser.registerModule(&g_pipetteModule); |
|
|
|
} |
|
|
|
stepMotorCtrlModule.initialize(BOARD_ID * 10 + 3, &motor, input, ZARRAY_SIZE(input), nullptr); |
|
|
|
g_ziProtocolParser.registerModule(&stepMotorCtrlModule); |
|
|
|
} |
|
|
|
|
|
|
|
void init_and_reg_m3078() { //
|
|
|
|
static M3078CodeScanner codescanner; |
|
|
|
static M3078CodeScanner::hardware_config_t cfg = { |
|
|
|
.uart = &huart2, |
|
|
|
.hdma_rx = nullptr, |
|
|
|
.hdma_tx = nullptr, |
|
|
|
|
|
|
|
.codeReadOkPin = PinNull, |
|
|
|
.rstPin = PinNull, |
|
|
|
.triggerPin = PD15, |
|
|
|
}; |
|
|
|
codescanner.initialize(BOARD_ID * 10 + 3, &cfg); |
|
|
|
g_ziProtocolParser.registerModule(&codescanner); |
|
|
|
{ |
|
|
|
static M3078CodeScanner codescanner; |
|
|
|
static M3078CodeScanner::hardware_config_t cfg = { |
|
|
|
.uart = &huart3, |
|
|
|
.hdma_rx = nullptr, |
|
|
|
.hdma_tx = nullptr, |
|
|
|
|
|
|
|
.codeReadOkPin = PinNull, |
|
|
|
.rstPin = PinNull, |
|
|
|
.triggerPin = PE15, |
|
|
|
}; |
|
|
|
codescanner.initialize(BOARD_ID * 10 + 4, &cfg); |
|
|
|
g_ziProtocolParser.registerModule(&codescanner); |
|
|
|
} |
|
|
|
|
|
|
|
{ |
|
|
|
// 115200
|
|
|
|
static FeiTeServoMotor feiteservomotor_bus; // 飞特舵机总线
|
|
|
|
static MiniRobotCtrlModule mini_servo[4]; |
|
|
|
|
|
|
|
ZASSERT(huart2.Init.BaudRate == 115200); // 飞特舵机总线
|
|
|
|
feiteservomotor_bus.initialize(&huart2, &hdma_usart2_rx, &hdma_usart2_tx); // 飞特舵机总线
|
|
|
|
|
|
|
|
mini_servo[0].initialize(BOARD_ID * 10 + 5, &feiteservomotor_bus, 1); |
|
|
|
mini_servo[1].initialize(BOARD_ID * 10 + 6, &feiteservomotor_bus, 2); |
|
|
|
mini_servo[2].initialize(BOARD_ID * 10 + 7, &feiteservomotor_bus, 3); |
|
|
|
mini_servo[3].initialize(BOARD_ID * 10 + 8, &feiteservomotor_bus, 4); |
|
|
|
|
|
|
|
g_ziProtocolParser.registerModule(&mini_servo[0]); |
|
|
|
g_ziProtocolParser.registerModule(&mini_servo[1]); |
|
|
|
g_ziProtocolParser.registerModule(&mini_servo[2]); |
|
|
|
g_ziProtocolParser.registerModule(&mini_servo[3]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void umain() { |
|
|
@ -131,10 +195,7 @@ void umain() { |
|
|
|
g_zcanCmder.init(zcanCmder_cfg); |
|
|
|
g_ziProtocolParser.initialize(&g_zcanCmder); |
|
|
|
|
|
|
|
init_and_reg_motor(); |
|
|
|
init_and_reg_cliptip_module(); |
|
|
|
init_and_reg_m3078(); |
|
|
|
|
|
|
|
initmodule(); |
|
|
|
while (true) { |
|
|
|
OSDefaultSchduler::getInstance()->loop(); |
|
|
|
g_zcanCmder.loop(); |
|
|
|