10 changed files with 375 additions and 108 deletions
-
103.vscode/c_cpp_properties.json
-
8.vscode/settings.json
-
2dep/libiflytop_micro
-
70src/board/hardware.cpp
-
26src/board/hardware.hpp
-
28src/board/hardwarelib.cpp
-
30src/board/hardwarelib.hpp
-
52src/board/project_board.hpp
-
108src/umain.cpp
-
56src/umain.hpp
@ -1,5 +1,11 @@ |
|||
{ |
|||
"files.associations": { |
|||
"compare": "cpp" |
|||
"compare": "cpp", |
|||
"system_error": "cpp", |
|||
"array": "cpp", |
|||
"functional": "cpp", |
|||
"tuple": "cpp", |
|||
"type_traits": "cpp", |
|||
"utility": "cpp" |
|||
} |
|||
} |
@ -1 +1 @@ |
|||
Subproject commit 66cbc54d57a7a2d1b2e704e1042a98a44ce0959e |
|||
Subproject commit c0bdaba2f2561fe2cc97c308ad5c3a9745302a91 |
@ -0,0 +1,28 @@ |
|||
#include "hardwarelib.hpp"
|
|||
|
|||
#define TAG "hardware"
|
|||
using namespace iflytop; |
|||
|
|||
/*******************************************************************************
|
|||
* TMC5130HImpl * |
|||
*******************************************************************************/ |
|||
|
|||
void TMC5130HImpl::initialize(const char *name, IflytopMicroOS *os, SPI_HandleTypeDef *spi, STM32_GPIO *spics, STM32_GPIO *enn) { |
|||
m_name = name; |
|||
m_os = os; |
|||
m_port.initialize(os, spi, spics, enn); |
|||
TMC5130::createDeafultTMC5130Config(&m_config, &m_port); |
|||
tmc5130.initialize(0, &m_config); |
|||
|
|||
uint32_t idVersion0 = tmc5130.readChipVERSION(); |
|||
ZLOGI(m_name, "idVersion :%x", idVersion0); |
|||
|
|||
tmc5130.setMotorShaft(false); |
|||
|
|||
tmc5130.setAcceleration(30000); |
|||
tmc5130.setDeceleration(30000); |
|||
|
|||
tmc5130.setIHOLD_IRUN(0, 3, 0); |
|||
} |
|||
void TMC5130HImpl::periodicJob() { tmc5130.periodicJob(m_os->getTicket()); } |
|||
TMC5130 *TMC5130HImpl::getTMC5130() { return &tmc5130; } |
@ -0,0 +1,30 @@ |
|||
#pragma once
|
|||
#include "board/project_board.hpp"
|
|||
#include "libiflytop_micro/stm32/basic/basic.h"
|
|||
#include "libiflytop_micro\stm32\basic\iflytop_micro_os.hpp"
|
|||
#include "libiflytop_micro\stm32\basic\stm32_hal.hpp"
|
|||
#include "main.h"
|
|||
#include "usart.h"
|
|||
|
|||
// TMC
|
|||
#include "libiflytop_micro\stm32\component\tmc\ic\tmc4361A.hpp"
|
|||
#include "libiflytop_micro\stm32\component\tmc\ic\ztmc2160.hpp"
|
|||
#include "libiflytop_micro\stm32\component\tmc\ic\ztmc5130.hpp"
|
|||
#include "libiflytop_micro\stm32\component\tmcutils\tmc51x0_port_impl.hpp"
|
|||
|
|||
namespace iflytop { |
|||
class TMC5130HImpl { |
|||
public: |
|||
const char* m_name; |
|||
IflytopMicroOS* m_os; |
|||
|
|||
TMC51X0PortImpl m_port; |
|||
TMC5130::TMC5130Config_t m_config; |
|||
TMC5130 tmc5130; |
|||
|
|||
public: |
|||
void initialize(const char* name, IflytopMicroOS* os, SPI_HandleTypeDef* spi, STM32_GPIO* spics, STM32_GPIO* enn); |
|||
void periodicJob(); |
|||
TMC5130* getTMC5130(); |
|||
}; |
|||
} // namespace iflytop
|
@ -1,10 +1,54 @@ |
|||
#pragma once
|
|||
#include "libiflytop_micro\stm32\basic\stm32_gpio.hpp"
|
|||
#define VERSION "v1.0"
|
|||
#define VERSION "v1.0"
|
|||
#define DEVICE_ID 200
|
|||
|
|||
// 调试串口
|
|||
#define DEBUG_UART huart2
|
|||
#define DEBUG_UART huart1
|
|||
// 调试指示灯
|
|||
#define DEBUG_LIGHT_GPIO PA1
|
|||
#define DEBUG_LIGHT_GPIO PB3
|
|||
// 微秒延迟定时器,注意该延时定时器需要按照以下文档进行配置
|
|||
// http://192.168.1.3:3000/zwikipedia/iflytop_wikipedia/src/branch/master/doc/stm32cubemx_us_timer.md
|
|||
#define DELAY_US_TIMER htim4
|
|||
#define DELAY_US_TIMER htim4
|
|||
|
|||
#define CONFIG_ENABLE_IFLYTOP_CAN_SLAVE_MODULE 1
|
|||
#define CONFIG_ENABLE_TMC_MOTOR 1
|
|||
|
|||
/*******************************************************************************
|
|||
* 5130步进电机配置 * |
|||
*******************************************************************************/ |
|||
|
|||
#if CONFIG_ENABLE_TMC_MOTOR
|
|||
// 电机通道编号
|
|||
#define MOTOR_SPI hspi1
|
|||
#define TMC5130_MOTOR_NUM 1
|
|||
#define MOTOR0_CSN PA4
|
|||
#define MOTOR0_ENN PB9
|
|||
// #define MOTOR1_SPI_MODE_SELECT
|
|||
|
|||
// 步进电机
|
|||
#define MOTOR_R_SENSOR PB13
|
|||
#define MOTOR_L_SENSOR PB12 // 作为零点限位
|
|||
#endif
|
|||
|
|||
#if CONFIG_ENABLE_IFLYTOP_CAN_SLAVE_MODULE
|
|||
/*******************************************************************************
|
|||
* CAN REG LIST * |
|||
*******************************************************************************/ |
|||
#define DEVICE_BASIC_CTRL_ADD_BASE 0 // 模块控制基本功能 https://iflytop1.feishu.cn/wiki/wikcnBmIF0vqLzbzWBsB3VDMalb
|
|||
#define REG_MOTOR1_CTRL_ADD_BASE 10000 // 步进电机控制基地址 https://iflytop1.feishu.cn/wiki/wikcnI9UaaRBfWQ7zY2PQfik5hb
|
|||
#define REG_GPIO_INPUT0 1000 // GPIO输入寄存器0
|
|||
#define REG_GPIO_OUTPUT0_WRITE 1100 // GPIO输出寄存器0 0-16,写时,高16位为掩码
|
|||
#define REG_GPIO_OUTPUT0_STATE 1101 // GPIO输出寄存器0 0-16,写时,高16位为掩码
|
|||
#endif
|
|||
|
|||
|
|||
/*******************************************************************************
|
|||
* GPIO INPUT * |
|||
*******************************************************************************/ |
|||
#define SENSOR_INT1 PA0
|
|||
#define SENSOR_INT0 PA1
|
|||
|
|||
/*******************************************************************************
|
|||
* GPIO OUTPUT * |
|||
*******************************************************************************/ |
Write
Preview
Loading…
Cancel
Save
Reference in new issue