You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
163 lines
7.1 KiB
163 lines
7.1 KiB
#include <stddef.h>
|
|
#include <stdio.h>
|
|
|
|
#include "board.h"
|
|
#include "sdk\components\subcanmodule\zcancmder_subboard_initer.hpp"
|
|
/*******************************************************************************
|
|
* PROJECT_INCLUDE *
|
|
*******************************************************************************/
|
|
#include "sdk/components/step_motor_ctrl_module/step_motor_ctrl_module.hpp"
|
|
#include "sdk\components\mini_servo_motor\feite_servo_motor.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\tmc\ic\ztmc4361A.hpp"
|
|
#include "sdk\components\tmc\ic\ztmc5130.hpp"
|
|
|
|
#define TAG "main"
|
|
using namespace iflytop;
|
|
using namespace std;
|
|
|
|
static ZCancmderSubboardIniter initer;
|
|
|
|
extern void umain();
|
|
extern "C" {
|
|
void StartDefaultTask(void const* argument) { umain(); }
|
|
}
|
|
/*******************************************************************************
|
|
* GET_DEVICE_ID *
|
|
*******************************************************************************/
|
|
static int32_t getDeviceId() { return BOARD_ID; }
|
|
/*******************************************************************************
|
|
* INIT_SUBMODULE *
|
|
*******************************************************************************/
|
|
void nvs_init_cb() {}
|
|
static void initsubmodule() {
|
|
osDelay(1000);
|
|
{
|
|
static TMC5130 g_motor;
|
|
static StepMotorCtrlModule g_stepMotorCtrlModule;
|
|
TMC5130::cfg_t cfg = {
|
|
.spi = &TMC_MOTOR_SPI, //
|
|
.csgpio = MOTOR0_CSN, //
|
|
.ennPin = MOTOR0_ENN, //
|
|
.spi_mode_select = MOTOR0_SPI_MODE_SELECT, //
|
|
};
|
|
g_motor.initialize(&cfg);
|
|
ZLOGI(TAG, "motora initialize 5160:%x ", g_motor.readICVersion());
|
|
|
|
g_motor.setMotorShaft(false);
|
|
g_motor.setAcceleration(100);
|
|
g_motor.setDeceleration(100);
|
|
g_motor.setIHOLD_IRUN(0, 8, 10);
|
|
|
|
static ZGPIO input[10];
|
|
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::flash_config_t smcm_cfg = {0};
|
|
StepMotorCtrlModule::create_default_cfg(smcm_cfg);
|
|
smcm_cfg.base_param.motor_one_circle_pulse = 80;
|
|
smcm_cfg.base_param.motor_one_circle_pulse_denominator = 1;
|
|
smcm_cfg.base_param.stepmotor_ihold = 1;
|
|
smcm_cfg.base_param.stepmotor_irun = 8;
|
|
smcm_cfg.base_param.motor_shaft = false;
|
|
smcm_cfg.base_param.motor_default_velocity = 500;
|
|
smcm_cfg.base_param.motor_run_to_zero_speed = 100;
|
|
smcm_cfg.base_param.max_d = 0;
|
|
smcm_cfg.base_param.min_d = 0;
|
|
|
|
g_stepMotorCtrlModule.initialize(initer.get_module_id(1), &g_motor, input, ZARRAY_SIZE(input), nullptr, &smcm_cfg);
|
|
initer.register_module(&g_stepMotorCtrlModule);
|
|
}
|
|
|
|
{
|
|
static TMC5130 g_motor;
|
|
static StepMotorCtrlModule g_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);
|
|
ZLOGI(TAG, "motora initialize 5160:%x ", g_motor.readICVersion());
|
|
|
|
g_motor.setMotorShaft(false);
|
|
g_motor.setAcceleration(100);
|
|
g_motor.setDeceleration(100);
|
|
g_motor.setIHOLD_IRUN(0, 8, 10);
|
|
|
|
static ZGPIO input[10];
|
|
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::flash_config_t smcm_cfg = {0};
|
|
StepMotorCtrlModule::create_default_cfg(smcm_cfg);
|
|
smcm_cfg.base_param.motor_one_circle_pulse = 100;
|
|
smcm_cfg.base_param.motor_one_circle_pulse_denominator = 1;
|
|
smcm_cfg.base_param.stepmotor_ihold = 4;
|
|
smcm_cfg.base_param.stepmotor_irun = 16;
|
|
smcm_cfg.base_param.motor_shaft = true;
|
|
smcm_cfg.base_param.motor_default_velocity = 50;
|
|
smcm_cfg.base_param.motor_run_to_zero_speed = 50;
|
|
smcm_cfg.base_param.max_d = 0;
|
|
smcm_cfg.base_param.min_d = 0;
|
|
|
|
g_stepMotorCtrlModule.initialize(initer.get_module_id(2), &g_motor, input, ZARRAY_SIZE(input), nullptr, &smcm_cfg);
|
|
initer.register_module(&g_stepMotorCtrlModule);
|
|
}
|
|
|
|
{
|
|
{
|
|
{
|
|
/*******************************************************************************
|
|
* 试管夹舵机 *
|
|
*******************************************************************************/
|
|
static FeiTeServoMotor feiteservomotor_bus; // 飞特舵机总线
|
|
static MiniRobotCtrlModule mini_servo;
|
|
|
|
// 飞特舵机总线
|
|
ZASSERT(huart2.Init.BaudRate == 115200);
|
|
feiteservomotor_bus.initialize(&huart2, &hdma_usart2_rx, &hdma_usart2_tx);
|
|
|
|
static MiniRobotCtrlModule::flash_config_t cfg = {0};
|
|
cfg.default_torque = 400;
|
|
mini_servo.initialize(initer.get_module_id(3), &feiteservomotor_bus, 1, &cfg);
|
|
initer.register_module(&mini_servo);
|
|
}
|
|
|
|
// {
|
|
// // 115200
|
|
// /*******************************************************************************
|
|
// *******************************************************************************/
|
|
// static FeiTeServoMotor feiteservomotor_bus; // 飞特舵机总线
|
|
// static MiniRobotCtrlModule mini_servo;
|
|
|
|
// // 飞特舵机总线
|
|
// ZASSERT(huart3.Init.BaudRate == 115200);
|
|
// feiteservomotor_bus.initialize(&huart3, &hdma_usart3_rx, &hdma_usart3_tx);
|
|
|
|
// static MiniRobotCtrlModule::flash_config_t cfg = {0};
|
|
// cfg.default_torque = 330;
|
|
// mini_servo.initialize(initer.get_module_id(4), &feiteservomotor_bus, 2, &cfg);
|
|
// initer.register_module(&mini_servo);
|
|
// }
|
|
}
|
|
}
|
|
}
|
|
|
|
/*******************************************************************************
|
|
* MAIN *
|
|
*******************************************************************************/
|
|
void umain() {
|
|
ZCancmderSubboardIniter::cfg_t cfg = //
|
|
{
|
|
.deviceId = getDeviceId(),
|
|
.input_gpio = {},
|
|
.output_gpio = {},
|
|
};
|
|
initer.init(&cfg);
|
|
initsubmodule();
|
|
initer.loop();
|
|
}
|