diff --git a/.cproject b/.cproject
index 50ffba8..51b9c10 100644
--- a/.cproject
+++ b/.cproject
@@ -26,7 +26,7 @@
-
+
-
+
@@ -207,16 +207,16 @@
-
+
-
+
-
+
diff --git a/.project b/.project
index f94bb8c..085a4d5 100644
--- a/.project
+++ b/.project
@@ -1,6 +1,6 @@
- robotic_core_xy
+ zapp
diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml
index 4dfe58f..d6ab3cb 100644
--- a/.settings/language.settings.xml
+++ b/.settings/language.settings.xml
@@ -5,7 +5,7 @@
-
+
@@ -16,7 +16,7 @@
-
+
diff --git a/.settings/stm32cubeide.project.prefs b/.settings/stm32cubeide.project.prefs
index a9f6b79..d599a44 100644
--- a/.settings/stm32cubeide.project.prefs
+++ b/.settings/stm32cubeide.project.prefs
@@ -1,3 +1,3 @@
-8DF89ED150041C4CBC7CB9A9CAA90856=763711B08F1ABC1A77FC8FA1A08B45FA
-DC22A860405A8BF2F2C095E5B6529F12=763711B08F1ABC1A77FC8FA1A08B45FA
+8DF89ED150041C4CBC7CB9A9CAA90856=F6DE5292A9642B92EC07AFF89A393D1B
+DC22A860405A8BF2F2C095E5B6529F12=D76CD03FA6D6925E54EEE32EC928F8C2
eclipse.preferences.version=1
diff --git a/robotic_core_xy dap.cfg b/dap.cfg
similarity index 100%
rename from robotic_core_xy dap.cfg
rename to dap.cfg
diff --git a/sdk b/sdk
index c081915..f28856b 160000
--- a/sdk
+++ b/sdk
@@ -1 +1 @@
-Subproject commit c081915dfcdc6901b278c969f861458ee386eae0
+Subproject commit f28856b68a9c6fd2b06070a2a10c6f40dfe9896d
diff --git a/usrc/main.cpp b/usrc/main.cpp
index 7625c57..87a0855 100644
--- a/usrc/main.cpp
+++ b/usrc/main.cpp
@@ -9,6 +9,7 @@
#include "sdk/hal/zhal.hpp"
#include "sdk\components\iflytop_can_slave_v1\iflytop_can_slave.hpp"
#include "sdk\components\tmc\ic\ztmc4361A.hpp"
+#include "sdk\components\tmc\ic\ztmc5130.hpp"
#define TAG "main"
namespace iflytop {
@@ -18,17 +19,18 @@ Main gmain;
using namespace iflytop;
IflytopCanProtocolStackProcesser m_protocolStack;
-TMC4361A m_motora;
-TMC4361A m_motorb;
-
-ZGPIO arm_sensor1_gpio;
-ZGPIO arm_sensor2_gpio;
-ZGPIO arm_sensor3_gpio;
-ZGPIO arm_sensor4_gpio;
-ZGPIO arm_sensor5_gpio;
-ZGPIO arm_sensor6_gpio;
-ZGPIO arm_sensor7_gpio;
-ZGPIO arm_sensor8_gpio;
+
+TMC5130 m_tj_motor;
+TMC5130 m_py_motor;
+
+// ZGPIO arm_sensor1_gpio;
+// ZGPIO arm_sensor2_gpio;
+// ZGPIO arm_sensor3_gpio;
+// ZGPIO arm_sensor4_gpio;
+// ZGPIO arm_sensor5_gpio;
+// ZGPIO arm_sensor6_gpio;
+// ZGPIO arm_sensor7_gpio;
+// ZGPIO arm_sensor8_gpio;
ZGPIO debuglight;
@@ -42,43 +44,40 @@ ZGPIO tmc_motor2_nreset_io;
ZGPIO tmc_motor2_sub_ic_enn_io;
void input_sensors_init() {
- arm_sensor1_gpio.initAsInput(ARM_SENSOR1_GPIO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_risingAndFallingIrq, true);
- arm_sensor2_gpio.initAsInput(ARM_SENSOR2_GPIO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_risingAndFallingIrq, true);
- arm_sensor3_gpio.initAsInput(ARM_SENSOR3_GPIO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, false);
- arm_sensor4_gpio.initAsInput(ARM_SENSOR4_GPIO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, false);
- arm_sensor5_gpio.initAsInput(ARM_SENSOR5_GPIO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, false);
- arm_sensor6_gpio.initAsInput(ARM_SENSOR6_GPIO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, false);
- arm_sensor7_gpio.initAsInput(ARM_SENSOR7_GPIO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_risingAndFallingIrq, true);
- arm_sensor8_gpio.initAsInput(ARM_SENSOR8_GPIO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_risingAndFallingIrq, true);
+ // arm_sensor1_gpio.initAsInput(ARM_SENSOR1_GPIO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_risingAndFallingIrq, true);
+ // arm_sensor2_gpio.initAsInput(ARM_SENSOR2_GPIO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_risingAndFallingIrq, true);
+ // arm_sensor3_gpio.initAsInput(ARM_SENSOR3_GPIO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, false);
+ // arm_sensor4_gpio.initAsInput(ARM_SENSOR4_GPIO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, false);
+ // arm_sensor5_gpio.initAsInput(ARM_SENSOR5_GPIO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, false);
+ // arm_sensor6_gpio.initAsInput(ARM_SENSOR6_GPIO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, false);
+ // arm_sensor7_gpio.initAsInput(ARM_SENSOR7_GPIO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_risingAndFallingIrq, true);
+ // arm_sensor8_gpio.initAsInput(ARM_SENSOR8_GPIO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_risingAndFallingIrq, true);
}
uint32_t intput_sensors_get_table0() {
uint32_t val = 0;
- val |= arm_sensor1_gpio.getStateUint32() << 1;
- val |= arm_sensor2_gpio.getStateUint32() << 2;
- val |= arm_sensor3_gpio.getStateUint32() << 3;
- val |= arm_sensor4_gpio.getStateUint32() << 4;
- val |= arm_sensor5_gpio.getStateUint32() << 5;
- val |= arm_sensor6_gpio.getStateUint32() << 6;
- val |= arm_sensor7_gpio.getStateUint32() << 7;
- val |= arm_sensor8_gpio.getStateUint32() << 8;
+ // val |= arm_sensor1_gpio.getStateUint32() << 1;
+ // val |= arm_sensor2_gpio.getStateUint32() << 2;
+ // val |= arm_sensor3_gpio.getStateUint32() << 3;
+ // val |= arm_sensor4_gpio.getStateUint32() << 4;
+ // val |= arm_sensor5_gpio.getStateUint32() << 5;
+ // val |= arm_sensor6_gpio.getStateUint32() << 6;
+ // val |= arm_sensor7_gpio.getStateUint32() << 7;
+ // val |= arm_sensor8_gpio.getStateUint32() << 8;
return val;
}
-ZGPIO *input_sensors_get_arm1_homegpio() { return &arm_sensor8_gpio; }
-ZGPIO *input_sensors_get_arm2_homegpio() { return &arm_sensor7_gpio; }
-
icps::error_t Main::onHostRegisterWriteEvent(IflytopCanProtocolStackProcesser *processer, icps::WriteEvent *event) { return icps::kSuccess; }
icps::error_t Main::onHostRegisterReadEvent(IflytopCanProtocolStackProcesser *processer, icps::ReadEvent *event) { return icps::kSuccess; }
void Main::onHostRegisterReportEvent(IflytopCanProtocolStackProcesser *processer, icps::ReportEvent *event) {}
void Main::run() {
- iflytop_no_os_cfg_t oscfg = {
+ ZHALCORE::cfg_t oscfg = {
.delayhtim = &DELAY_US_TIMER,
.debuguart = &DEBUG_UART,
};
- iflytop_no_os_init(&oscfg);
+ ZHALCORE::getInstance()->initialize(oscfg);
- ZLOGI(TAG, "robotic_core_xy:%s", VERSION);
+ ZLOGI(TAG, "zapp:%s", VERSION);
printf("int32_t %d int %d longint %d\n", sizeof(int32_t), sizeof(int), sizeof(long int));
debuglight.initAsOutput(DEBUG_LIGHT_GPIO, ZGPIO::kMode_nopull, false, false);
@@ -93,43 +92,20 @@ void Main::run() {
/*******************************************************************************
* 电机初始化 *
*******************************************************************************/
- tmc_motor1_spi_select1_io.initAsOutput(TMC_MOTOR1_SPI_SELECT1_IO, ZGPIO::kMode_nopull, false, true);
- tmc_motor1_nfreeze_io.initAsOutput(TMC_MOTOR1_nFREEZE_IO, ZGPIO::kMode_nopull, false, true);
- tmc_motor1_nreset_io.initAsOutput(TMC_MOTOR1_nRESET_IO, ZGPIO::kMode_nopull, false, true);
- tmc_motor1_sub_ic_enn_io.initAsOutput(TMC_MOTOR1_SUB_IC_ENN_IO, ZGPIO::kMode_nopull, false, true);
- tmc_motor2_spi_select1_io.initAsOutput(TMC_MOTOR2_SPI_SELECT1_IO, ZGPIO::kMode_nopull, false, true);
- tmc_motor2_nfreeze_io.initAsOutput(TMC_MOTOR2_nFREEZE_IO, ZGPIO::kMode_nopull, false, true);
- tmc_motor2_nreset_io.initAsOutput(TMC_MOTOR2_nRESET_IO, ZGPIO::kMode_nopull, false, true);
- tmc_motor2_sub_ic_enn_io.initAsOutput(TMC_MOTOR2_SUB_IC_ENN_IO, ZGPIO::kMode_nopull, false, true);
-
{
- TMC4361A::cfg_t motora_cfg = {.spi = &TMC_MOTOR_SPI,
- .csgpio = &tmc_motor1_spi_select1_io,
- .resetPin = &tmc_motor1_nreset_io,
- .fREEZEPin = &tmc_motor1_nfreeze_io,
- .ennPin = NULL,
- .driverIC_ennPin = &tmc_motor1_sub_ic_enn_io,
- .driverIC_resetPin = NULL};
-
- m_motora.initialize(&motora_cfg);
- int32_t ic4361Version = m_motora.readICVersion();
- int32_t ic2160Version = m_motora.readSubICVersion();
- ZLOGI(TAG, "m_motora:TMC4361Version:%lx TMC2160VERSION:%lx", ic4361Version, ic2160Version);
+ TMC5130::cfg_t cfg = {.hspi = &MOTOR_SPI, .enn_pin = MOTOR0_ENN, .csn_pin = MOTOR0_CSN};
+
+ m_py_motor.initialize(&cfg);
+ int32_t chipv = m_py_motor.readChipVERSION();
+ ZLOGI(TAG, "m_py_motor:%lx", chipv);
}
{
- TMC4361A::cfg_t motorb_cfg = {.spi = &TMC_MOTOR_SPI,
- .csgpio = &tmc_motor2_spi_select1_io,
- .resetPin = &tmc_motor2_nreset_io,
- .fREEZEPin = &tmc_motor2_nfreeze_io,
- .ennPin = NULL,
- .driverIC_ennPin = &tmc_motor2_sub_ic_enn_io,
- .driverIC_resetPin = NULL};
-
- m_motorb.initialize(&motorb_cfg);
- int32_t ic4361Version = m_motorb.readICVersion();
- int32_t ic2160Version = m_motorb.readSubICVersion();
- ZLOGI(TAG, "m_motorb:TMC4361Version:%lx TMC2160VERSION:%lx", ic4361Version, ic2160Version);
+ TMC5130::cfg_t cfg = {.hspi = &MOTOR_SPI, .enn_pin = MOTOR1_ENN, .csn_pin = MOTOR1_CSN};
+
+ m_tj_motor.initialize(&cfg);
+ int32_t chipv = m_tj_motor.readChipVERSION();
+ ZLOGI(TAG, "m_tj_motor:%lx", chipv);
}
/*******************************************************************************
@@ -162,15 +138,6 @@ void Main::run() {
m_protocolStack.activeReg(REG_GPIO_INPUT0, icps::kwr, 0);
}
- m_motora.setIHOLD_IRUN(1, 12, 0); // 小臂
- m_motora.setMotorShaft(0);
-
- m_motorb.setIHOLD_IRUN(1, 12, 0); // 小臂
- m_motorb.setMotorShaft(0);
-
- m_motora.rotate(1200000);
- m_motorb.rotate(1200000);
-
while (1) {
ZHALCORE::getInstance()->loop();
}
diff --git a/usrc/project.hpp b/usrc/project.hpp
index 770283c..cabe275 100644
--- a/usrc/project.hpp
+++ b/usrc/project.hpp
@@ -1,64 +1,83 @@
#pragma once
-#define VERSION "v2.0"
+#define VERSION "v1.0"
// 设备ID
-#define DEVICE_ID (128 + 3)
+#define DEVICE_ID (128 + 5)
// 调试串口
#define DEBUG_UART huart1
// 调试指示灯
-#define DEBUG_LIGHT_GPIO PE2
-
+#define DEBUG_LIGHT_GPIO PE8
// 微秒延迟定时器,注意该延时定时器需要按照以下文档进行配置
// http://192.168.1.3:3000/zwikipedia/iflytop_wikipedia/src/branch/master/doc/stm32cubemx_us_timer.md
-#define DELAY_US_TIMER htim6
-
-// 电机通道编号
-#define TMC_MOTOR_SPI hspi1
-
-// MOTOR1
-#define TMC_MOTOR1_CHANNEL 1
-#define TMC_MOTOR1_SPI_SELECT1_IO PA4
-#define TMC_MOTOR1_nFREEZE_IO PC2
-#define TMC_MOTOR1_nRESET_IO PB3
-#define TMC_MOTOR1_SUB_IC_ENN_IO PC3
-#define TMC_MOTOR1_ENN_IO // unused
+#define DELAY_US_TIMER htim6
+#define MICROSWITCH_NUM 6
+//
+/*******************************************************************************
+ * 主从485通讯 *
+ *******************************************************************************/
+#define MASTER_SLAVE_485_UART huart2
+/*******************************************************************************
+ * 反应盒扫码传感器 *
+ *******************************************************************************/
+#define REACTION_BOX_SWEEP_SENSOR_UART huart3
+/*******************************************************************************
+ * MOTOR *
+ *******************************************************************************/
+/**
+ *
+ *
+ */
+#define MOTOR_SPI hspi1
-// MOTOR2
-#define TMC_MOTOR2_CHANNEL 2
-#define TMC_MOTOR2_SPI_SELECT1_IO PA8
-#define TMC_MOTOR2_nFREEZE_IO PC6
-#define TMC_MOTOR2_nRESET_IO PB2
-#define TMC_MOTOR2_SUB_IC_ENN_IO PC7
-#define TMC_MOTOR2_ENN_IO // unused
+#define TMC5130_MOTOR_NUM 2
+#define MOTOR_CH(n) (n)
+// FYBJ_PY
+#define MOTOR0_CSN PA4 // 平移电机片选信号
+#define MOTOR0_ENN PE14
+// FYBJ_TJ_DRV
+#define MOTOR1_CSN PC4 // 添加电机片选信号
+#define MOTOR1_ENN PE13
/*******************************************************************************
- * MotorConfig *
+ * REG LIST *
*******************************************************************************/
-#define MOTOR_REDUCTION_RATIO1 50
-#define MOTOR_REDUCTION_RATIO2 50
+#define DEVICE_BASIC_CONTROLLER_ADD_BASE 0
+
+#define GPIO_INPUT_ADD_BASE 1000 // GPIO输入
+#define REG_GPIO_INPUT0 (GPIO_INPUT_ADD_BASE + 0)
+
+#define REG_PY_MOTOR_CTRL_ADD_BASE 10000 // 控制 入料电机控制
+#define REG_TJ_MOTOR_CTRL_ADD_BASE 10100 // 控制 转移电机控制
+#define REG_ID_CARD_READER_CTRL_ADD_BASE 20000 // 控制 串口扫码器
+#define REG_LARSER_SCANNER_CTRL_ADD_BASE 30000 // 控制 单点激光扫码器
+
-#define SCARA_L2 (2385) // 0.1mm
-#define SCARA_L1 (2150) // 0.1mm
/*******************************************************************************
- * REG LIST *
+ * GPIO *
*******************************************************************************/
-// https://iflytop1.feishu.cn/docx/ZBsddjrL1oHAiYx8DdmcccEBnPf
+#define BEEP PA1 // 蜂鸣器
+#define FAN1_FB_INT PA15 // 帕尔贴风机反馈
-#define DEVICE_BASIC_CTRL_ADD_BASE 0
-#define GPIO_INPUT_ADD_BASE 1000 // GPIO输入
-#define REG_SCARA_CTRL_ADD_BASE 11200 // 机械臂控制基地址
-#define REG_BARCODE_CTRL_ADD_BASE 20000 // 扫码器控制基地址
+#define HOT_CTR PB1
-#define REG_GPIO_INPUT0 (GPIO_INPUT_ADD_BASE + 0)
+#define FAN0_POWER PC8 // 外部风机电源
+#define FAN1_POWER PC9 // 帕尔贴风机
-#define ARM_SENSOR1_GPIO PD0
-#define ARM_SENSOR2_GPIO PD1
-#define ARM_SENSOR3_GPIO PD2
-#define ARM_SENSOR4_GPIO PD3
-#define ARM_SENSOR5_GPIO PD4
-#define ARM_SENSOR6_GPIO PD5
-#define ARM_SENSOR7_GPIO PD6
-#define ARM_SENSOR8_GPIO PD7
+#define FYBH_READ1 PD0
+#define FYBH_READ2 PD1
+#define FYBH_READ3 PD2
+#define FYBH_READ4 PD3
+#define FYBH_READ5 PD4
+#define FYBH_READ6 PD5
+#define FYBJL_SENSOR8 PD7 // 开门霍尔
+#define FYBJL_SENSOR7 PD8 // 卡板光电1
+#define FYBJL_SENSOR6 PD9 // 预留光电
+#define FYBJL_SENSOR5 PD10 // 推杆限位光电
+#define FYBJL_SENSOR4 PD11 // 推杆原点光电
+#define FYBJL_SENSOR3 PD12 // 平移计步光电(预留)
+#define FYBJL_SENSOR2 PD13 // 平移限位光电
+#define FYBJL_SENSOR1 PD14 // 平移原点光电
+#define FYBJL_SENSOR0 PD15 // 黑白扫码
-#define CODE_SCANER_UART huart3
\ No newline at end of file
+#define COLD_CTR PE10
\ No newline at end of file
diff --git a/robotic_core_xy.ioc b/zapp.ioc
similarity index 98%
rename from robotic_core_xy.ioc
rename to zapp.ioc
index b203f1f..bdf150b 100644
--- a/robotic_core_xy.ioc
+++ b/zapp.ioc
@@ -147,8 +147,8 @@ ProjectManager.MainLocation=Core/Src
ProjectManager.NoMain=false
ProjectManager.PreviousToolchain=STM32CubeIDE
ProjectManager.ProjectBuild=false
-ProjectManager.ProjectFileName=robotic_core_xy.ioc
-ProjectManager.ProjectName=robotic_core_xy
+ProjectManager.ProjectFileName=zapp.ioc
+ProjectManager.ProjectName=zapp
ProjectManager.ProjectStructure=
ProjectManager.RegisterCallBack=
ProjectManager.StackSize=0x1000
diff --git a/robotic_core_xy.launch b/zapp.launch
similarity index 94%
rename from robotic_core_xy.launch
rename to zapp.launch
index 0027e0e..9e1624d 100644
--- a/robotic_core_xy.launch
+++ b/zapp.launch
@@ -12,7 +12,7 @@
-
+
@@ -36,7 +36,7 @@
-
+
@@ -46,7 +46,7 @@
-
+
@@ -80,13 +80,13 @@
-
-
+
+
-
+
-
+