7 changed files with 233 additions and 1 deletions
-
2sdk
-
8usrc/main.cpp
-
68usrc/subboards/subboard200_ext_tmc5160/pri_board.h
-
78usrc/subboards/subboard200_ext_tmc5160/subboard200_ext_tmc5160.cpp
-
24usrc/subboards/subboard200_ext_tmc5160/subboard200_ext_tmc5160.hpp
-
42usrc/subboards/subboard200_ext_tmc5160/subboard200_ext_tmc5160_board.c
-
12usrc/subboards/subboard200_ext_tmc5160/subboard200_ext_tmc5160_board.h
@ -1 +1 @@ |
|||||
Subproject commit 90ea2d6ded854658853cff8ca31a56835eac43e6 |
|
||||
|
Subproject commit 7dae22500da25578045f9cd39c7011243d8b00fe |
@ -0,0 +1,68 @@ |
|||||
|
#pragma once |
||||
|
|
||||
|
#define ID0_IO PC0 |
||||
|
#define ID1_IO PC1 |
||||
|
#define ID2_IO PC2 |
||||
|
#define ID3_IO PC3 |
||||
|
#define ID4_IO PC4 |
||||
|
|
||||
|
/*********************************************************************************************************************** |
||||
|
* 板载扩展IO * |
||||
|
***********************************************************************************************************************/ |
||||
|
|
||||
|
#define EXT_INPUT_IO0 PD0 |
||||
|
#define EXT_INPUT_IO1 PD1 |
||||
|
#define EXT_INPUT_IO2 PD2 |
||||
|
#define EXT_INPUT_IO3 PD3 |
||||
|
#define EXT_INPUT_IO4 PD4 |
||||
|
#define EXT_INPUT_IO5 PD5 |
||||
|
#define EXT_INPUT_IO6 PD6 |
||||
|
#define EXT_INPUT_IO7 PD7 |
||||
|
#define EXT_INPUT_IO8 PD8 |
||||
|
#define EXT_INPUT_IO9 PD9 |
||||
|
|
||||
|
#define EXT_INPUT_IO0_MIRROR true |
||||
|
#define EXT_INPUT_IO1_MIRROR true |
||||
|
#define EXT_INPUT_IO2_MIRROR true |
||||
|
#define EXT_INPUT_IO3_MIRROR true |
||||
|
#define EXT_INPUT_IO4_MIRROR true |
||||
|
#define EXT_INPUT_IO5_MIRROR true |
||||
|
#define EXT_INPUT_IO6_MIRROR true |
||||
|
#define EXT_INPUT_IO7_MIRROR true |
||||
|
#define EXT_INPUT_IO8_MIRROR true |
||||
|
#define EXT_INPUT_IO9_MIRROR true |
||||
|
|
||||
|
#define TMC_MOTOR_SPI hspi1 |
||||
|
|
||||
|
/*********************************************************************************************************************** |
||||
|
* TMC5160 * |
||||
|
***********************************************************************************************************************/ |
||||
|
|
||||
|
#define MOTOR1_CSN PA4 |
||||
|
#define MOTOR1_ENN PB7 |
||||
|
#define MOTOR1_SPI_MODE_SELECT PB4 |
||||
|
#define MOTOR1_nFREEZE_IO PE12 |
||||
|
#define MOTOR1_nRESET_IO PinNull |
||||
|
#define MOTOR1_SUB_IC_ENN_IO PE11 |
||||
|
|
||||
|
#define MOTOR1_REFL PD0 |
||||
|
#define MOTOR1_REFR PD1 |
||||
|
#define MOTOR1_REFL_MIRROR true |
||||
|
#define MOTOR1_REFR_MIRROR true |
||||
|
|
||||
|
#define MOTOR1_MOTOR_SHAFT false // |
||||
|
#define MOTOR1_MOTOR_ONE_CIRCLE_PULSE 1000 // |
||||
|
#define MOTOR1_MOTOR_ONE_CIRCLE_PULSE_DENOMINATOR 1 // |
||||
|
#define MOTOR1_STEPMOTOR_IHOLD 1 |
||||
|
#define MOTOR1_STEPMOTOR_IRUN 8 |
||||
|
#define MOTOR1_STEPMOTOR_IHOLDDELAY 100 |
||||
|
#define MOTOR1_STEPMOTOR_IGLOBALSCALER 0 |
||||
|
#define MOTOR1_MOTOR_DEFAULT_ACC 300 |
||||
|
#define MOTOR1_MOTOR_DEFAULT_DEC 300 |
||||
|
#define MOTOR1_MOTOR_DEFAULT_VELOCITY 500 |
||||
|
#define MOTOR1_MIN_D 0 |
||||
|
#define MOTOR1_MAX_D 0 |
||||
|
#define MOTOR1_MOTOR_RUN_TO_ZERO_SPEED 100 |
||||
|
#define MOTOR1_MOTOR_RUN_TO_ZERO_DEC 300 |
||||
|
#define MOTOR1_MOTOR_LOOK_ZERO_EDGE_SPEED 50 |
||||
|
#define MOTOR1_MOTOR_LOOK_ZERO_EDGE_DEC 600 |
@ -0,0 +1,78 @@ |
|||||
|
#include "subboard200_ext_tmc5160.hpp"
|
||||
|
extern "C" { |
||||
|
#include "subboard200_ext_tmc5160_board.h"
|
||||
|
} |
||||
|
#include "pri_board.h"
|
||||
|
#include "public_service/instance_init.hpp"
|
||||
|
#include "public_service/public_service.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/sensors/m3078/m3078_code_scaner.hpp"
|
||||
|
#include "sdk/components/step_motor_ctrl_module/step_motor_ctrl_module.hpp"
|
||||
|
#include "sdk/components/tmc/ic/ztmc4361A.hpp"
|
||||
|
#include "sdk\components\pipette_module\pipette_ctrl_module_v2.hpp"
|
||||
|
|
||||
|
#define TAG "Subboard200ExtTmc5160"
|
||||
|
|
||||
|
using namespace iflytop; |
||||
|
|
||||
|
/***********************************************************************************************************************
|
||||
|
* IMPL * |
||||
|
***********************************************************************************************************************/ |
||||
|
void Subboard200ExtTmc5160::initialize() { |
||||
|
IO_INIT(); |
||||
|
GService::inst()->getZCanProtocolParser()->registerModule(this); |
||||
|
#if 1
|
||||
|
static StepMotorCtrlModule* opt_scan_motor = nullptr; |
||||
|
|
||||
|
/***********************************************************************************************************************
|
||||
|
* ID1 * |
||||
|
***********************************************************************************************************************/ |
||||
|
// { TMC5130_MOTOR_INITER(1, 1); }
|
||||
|
|
||||
|
{ |
||||
|
static TMC51X0 motor; |
||||
|
static StepMotorCtrlModule module; |
||||
|
int subid = 1; |
||||
|
TMC51X0::cfg_t tmc5130cfg = { |
||||
|
.spi = &hspi1, |
||||
|
.csgpio = PA4, |
||||
|
.ennPin = PB7, |
||||
|
.spi_mode_select = PB4, |
||||
|
}; |
||||
|
motor.initialize(&tmc5130cfg); |
||||
|
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 = 1000; |
||||
|
stepcfg.motor_one_circle_pulse_denominator = 1; |
||||
|
stepcfg.stepmotor_ihold = 1; |
||||
|
stepcfg.stepmotor_irun = 8; |
||||
|
stepcfg.stepmotor_iholddelay = 100; |
||||
|
stepcfg.stepmotor_iglobalscaler = 0; |
||||
|
stepcfg.motor_default_acc = 300; |
||||
|
stepcfg.motor_default_dec = 300; |
||||
|
stepcfg.motor_default_velocity = 500; |
||||
|
stepcfg.min_d = 0; |
||||
|
stepcfg.max_d = 0; |
||||
|
stepcfg.motor_run_to_zero_speed = 100; |
||||
|
stepcfg.motor_run_to_zero_dec = 300; |
||||
|
stepcfg.motor_look_zero_edge_speed = 50; |
||||
|
stepcfg.motor_look_zero_edge_dec = 600; |
||||
|
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()); |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
#endif
|
||||
|
} |
@ -0,0 +1,24 @@ |
|||||
|
#include <stddef.h>
|
||||
|
#include <stdio.h>
|
||||
|
|
||||
|
//
|
||||
|
#include "configs/device_id_mgr.hpp"
|
||||
|
#include "sdk/chip/chip.hpp"
|
||||
|
#include "sdk/os/zos.hpp"
|
||||
|
//
|
||||
|
#include "public_service/public_service.hpp"
|
||||
|
#include "sdk\components\step_motor_ctrl_module\step_motor_ctrl_module.hpp"
|
||||
|
#include "sdk\components\tmc\ic\ztmc5130.hpp"
|
||||
|
|
||||
|
namespace iflytop { |
||||
|
class Subboard200ExtTmc5160 : public ExtBoardImpl { |
||||
|
public: |
||||
|
static Subboard200ExtTmc5160 *ins() { |
||||
|
static Subboard200ExtTmc5160 instance; |
||||
|
return &instance; |
||||
|
} |
||||
|
|
||||
|
void initialize(); |
||||
|
}; |
||||
|
|
||||
|
} // namespace iflytop
|
@ -0,0 +1,42 @@ |
|||||
|
#include "main.h" |
||||
|
#include "public_service/public_service.h" |
||||
|
|
||||
|
/* SPI1 init function */ |
||||
|
static void MX_SPI1_Init(void) { |
||||
|
__HAL_RCC_SPI1_CLK_ENABLE(); |
||||
|
__HAL_RCC_GPIOA_CLK_ENABLE(); |
||||
|
|
||||
|
hspi1.Instance = SPI1; |
||||
|
hspi1.Init.Mode = SPI_MODE_MASTER; |
||||
|
hspi1.Init.Direction = SPI_DIRECTION_2LINES; |
||||
|
hspi1.Init.DataSize = SPI_DATASIZE_8BIT; |
||||
|
hspi1.Init.CLKPolarity = SPI_POLARITY_LOW; |
||||
|
hspi1.Init.CLKPhase = SPI_PHASE_1EDGE; |
||||
|
hspi1.Init.NSS = SPI_NSS_SOFT; |
||||
|
hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_32; |
||||
|
hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB; |
||||
|
hspi1.Init.TIMode = SPI_TIMODE_DISABLE; |
||||
|
hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; |
||||
|
hspi1.Init.CRCPolynomial = 10; |
||||
|
if (HAL_SPI_Init(&hspi1) != HAL_OK) { |
||||
|
Error_Handler(); |
||||
|
} |
||||
|
GPIO_InitTypeDef GPIO_InitStruct = {0}; |
||||
|
GPIO_InitStruct.Pin = GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7; |
||||
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL; |
||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; |
||||
|
GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; |
||||
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
||||
|
|
||||
|
hspi1_enable = true; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @brief 板夹仓初始化 |
||||
|
*/ |
||||
|
|
||||
|
void subboard200_ext_tmc5160_board_init() { |
||||
|
common_hardware_init(); |
||||
|
MX_SPI1_Init(); |
||||
|
} |
@ -0,0 +1,12 @@ |
|||||
|
#pragma once |
||||
|
#include "main.h" |
||||
|
|
||||
|
#ifdef __cplusplus |
||||
|
extern "C" { |
||||
|
#endif |
||||
|
|
||||
|
void subboard200_ext_tmc5160_board_init(); |
||||
|
|
||||
|
#ifdef __cplusplus |
||||
|
} |
||||
|
#endif |
Write
Preview
Loading…
Cancel
Save
Reference in new issue