diff --git a/.cproject b/.cproject
index a94d3ed..a6daeff 100644
--- a/.cproject
+++ b/.cproject
@@ -29,7 +29,7 @@
-
+
-
+
@@ -216,7 +216,7 @@
-
+
@@ -237,10 +237,10 @@
-
+
-
+
\ No newline at end of file
diff --git a/.project b/.project
index 79a842e..7add660 100644
--- a/.project
+++ b/.project
@@ -1,6 +1,6 @@
- zcancmder_debug_board
+ Intelligent_winding_robot_main_board
diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml
index a6656dd..7b365a4 100644
--- a/.settings/language.settings.xml
+++ b/.settings/language.settings.xml
@@ -5,7 +5,7 @@
-
+
@@ -16,7 +16,7 @@
-
+
diff --git a/zcancmder_debug_board.ioc b/Intelligent_winding_robot_main_board.ioc
similarity index 98%
rename from zcancmder_debug_board.ioc
rename to Intelligent_winding_robot_main_board.ioc
index f958b88..3f2772d 100644
--- a/zcancmder_debug_board.ioc
+++ b/Intelligent_winding_robot_main_board.ioc
@@ -220,8 +220,8 @@ ProjectManager.MainLocation=Core/Src
ProjectManager.NoMain=false
ProjectManager.PreviousToolchain=
ProjectManager.ProjectBuild=false
-ProjectManager.ProjectFileName=zcancmder_debug_board.ioc
-ProjectManager.ProjectName=zcancmder_debug_board
+ProjectManager.ProjectFileName=Intelligent_winding_robot_main_board.ioc
+ProjectManager.ProjectName=Intelligent_winding_robot_main_board
ProjectManager.ProjectStructure=
ProjectManager.RegisterCallBack=
ProjectManager.StackSize=0x1000
diff --git a/zcancmder_debug_board.launch b/Intelligent_winding_robot_main_board.launch
similarity index 94%
rename from zcancmder_debug_board.launch
rename to Intelligent_winding_robot_main_board.launch
index 48f2121..951f0cd 100644
--- a/zcancmder_debug_board.launch
+++ b/Intelligent_winding_robot_main_board.launch
@@ -12,7 +12,7 @@
-
+
@@ -32,7 +32,7 @@
-
+
@@ -67,13 +67,13 @@
-
-
+
+
-
+
diff --git a/README.md b/README.md
index b1daa39..6484f07 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,9 @@
-开发板资料
-http://47.111.11.73/docs/boards/stm32/zdyz_stm32f407_explorer.html
-```
-注意事项:
-1.注意将CAN/USB选择跳帽,接到CAN接口那一端(否则代码会卡死在CAN初始化处)
+```
+----------------------------------------
+工程初始化:
+git submodule update --init --recursive
+```
-```
\ No newline at end of file
diff --git a/sdk b/sdk
index 962fc1f..aa9d1dd 160000
--- a/sdk
+++ b/sdk
@@ -1 +1 @@
-Subproject commit 962fc1f81b210bcc13cb87a033d8bd04ead290a6
+Subproject commit aa9d1dda89f177ad23af5013fdaf5d8f29c0f8a6
diff --git a/usrc/cmdline_version.cpp b/usrc/cmdline_version.cpp
index 1c0f791..730f9d0 100644
--- a/usrc/cmdline_version.cpp
+++ b/usrc/cmdline_version.cpp
@@ -25,7 +25,6 @@
#include "sdk\components\zprotocol_helper\micro_computer_module_device_script_cmder_paser.hpp"
#include "sdk\components\zprotocols\zcancmder_v2\protocol_proxy.hpp"
#include "sdk\components\zprotocols\zcancmder_v2\zmodule_device_manager.hpp"
-#include "global.hpp"
// #include "M3078CodeScanner"
#define TAG "main"
@@ -33,6 +32,7 @@ using namespace iflytop;
using namespace std;
static ZModuleDeviceManager g_zModuleDeviceManager;
static MicroComputerModuleDeviceScriptCmderPaser g_zModuleDeviceScriptCmderPaser;
+static ZCanCommnaderMaster g_zcanCommnaderMaster;
static ZIProtocolProxy proxy[255];
void cmdline_version_main() {
diff --git a/usrc/device.cpp b/usrc/device.cpp
new file mode 100644
index 0000000..23e269d
--- /dev/null
+++ b/usrc/device.cpp
@@ -0,0 +1,152 @@
+#include "device.hpp"
+
+#include "sdk\components\eq_20_asb_motor\eq20_servomotor.hpp"
+#include "sdk\components\mini_servo_motor\mini_servo_motor_ctrl_module.hpp"
+
+using namespace iflytop;
+
+// void init();
+#define TAG "main"
+void Device::init() {
+ /**
+ * @brief 芯片基础配置
+ */
+ chip_cfg_t chipcfg;
+ chipcfg.us_dleay_tim = &PC_SYS_DELAY_US_TIMER;
+ chipcfg.tim_irq_scheduler_tim = &PC_SYS_TIM_IRQ_SCHEDULER_TIMER;
+ chipcfg.huart = &PC_DEBUG_UART;
+ chipcfg.debuglight = PC_DEBUG_LIGHT_GPIO;
+
+ chip_init(&chipcfg);
+
+ /**
+ * @brief ZOS初始化
+ */
+ zos_cfg_t zoscfg;
+ zos_init(&zoscfg);
+
+ ZLOGI(TAG, "boardId:%d", 0);
+
+ line_locking_solenoid_valve_init();
+ init_uart_cmder();
+ init_dm();
+ init_bus();
+ sub_module_init();
+
+ while (true) {
+ OSDefaultSchduler::getInstance()->loop();
+ m_uart_cmdline_parser.schedule();
+ }
+}
+
+void Device::init_uart_cmder() {
+ static ZUARTDmaReceiver dmaUartReceiver;
+ ZUARTDmaReceiver::hardware_config_t cfg = {
+ .huart = &PC_DEBUG_UART,
+ .dma_rx = &PC_DEBUG_UART_DMA_HANDLER,
+ .rxbuffersize = PC_DEBUG_UART_RX_BUF_SIZE,
+ .rxovertime_ms = 10,
+ };
+ dmaUartReceiver.initialize(&cfg);
+ m_uart_cmdline_parser.initialize(&dmaUartReceiver);
+}
+
+/**
+ * @brief
+ * 1. 初始化设备管理器
+ * 2. 设备管理器支持串口指令解析
+ */
+void Device::init_dm() {
+ m_device_manager.initialize();
+ // m_device_manager 支持命令行解析操作
+ static MicroComputerModuleDeviceScriptCmderPaser m_zModuleDeviceScriptCmderPaser; // 脚本解析器
+ m_zModuleDeviceScriptCmderPaser.initialize(&m_uart_cmdline_parser, &m_device_manager);
+}
+
+void Device::init_bus() {
+ /*******************************************************************************
+ * 初始化CAN总线 *
+ *******************************************************************************/
+ ZLOGI(TAG, "init can bus");
+ m_zcanbus.init(m_zcanbus.createCFG());
+ m_device_manager.regCanCmder(&m_zcanbus);
+ ZLOGI(TAG, "init can bus end...");
+
+ /*******************************************************************************
+ * 初始化FEITE BUS *
+ *******************************************************************************/
+ ZLOGI(TAG, "init feite bus");
+ ZASSERT(huart3.Init.BaudRate == 115200);
+ m_feitebus.initialize(&huart3, &hdma_usart3_rx, &hdma_usart3_tx);
+
+ /*******************************************************************************
+ * 初始化MODBUS总线 *
+ *******************************************************************************/
+ m_modbus.initialize(&huart2, &hdma_usart2_rx, &hdma_usart2_tx);
+}
+
+#define REG_SUB_MODULE(table) \
+ for (size_t i = 0; i < sizeof(table) / sizeof(table[0]); i++) { \
+ m_device_manager.registerModule(&table[i]); \
+ }
+
+/**
+ * @brief
+ * 子CAN模块初始化
+ */
+void Device::sub_module_init() {
+ /**
+ * @brief 初始化舵机
+ * 11->16
+ */
+ static MiniRobotCtrlModule::flash_config_t servo_cfg = {.default_torque = 330};
+ static MiniRobotCtrlModule mini_servo[10];
+ for (size_t i = 0; i < 6; i++) {
+ int idnum = 10 + i;
+ ZLOGI(TAG, "init servo:%d", idnum);
+ mini_servo[i].initialize(idnum, &m_feitebus, idnum, &servo_cfg);
+ m_device_manager.registerModule(&mini_servo[i]);
+ }
+ /**
+ * @brief 初始化主轴电机
+ */
+ static Eq20ServoMotor eq20_motor;
+ eq20_motor.init(1, &m_modbus, 1);
+ m_device_manager.registerModule(&eq20_motor);
+
+ /**
+ * @brief 初始化XY平台
+ */
+ static ZIProtocolProxy xyboard_module_proxy[2];
+ xyboard_module_proxy[0].initialize(20, &m_zcanbus); // BOARD2 XY轴板子
+ xyboard_module_proxy[1].initialize(21, &m_zcanbus);
+ REG_SUB_MODULE(xyboard_module_proxy);
+
+ /**
+ * @brief 初始化Z轴上的设备
+ */
+ static ZIProtocolProxy z_axis_board_can_module_proxy[4];
+ z_axis_board_can_module_proxy[0].initialize(30, &m_zcanbus); // BOARD3 Z轴板子
+ z_axis_board_can_module_proxy[1].initialize(31, &m_zcanbus);
+ z_axis_board_can_module_proxy[1].initialize(32, &m_zcanbus);
+ z_axis_board_can_module_proxy[2].initialize(33, &m_zcanbus);
+ REG_SUB_MODULE(z_axis_board_can_module_proxy);
+
+ /**
+ * @brief 初始化
+ * CAN步进电机模块
+ */
+ static ZIProtocolProxy can_step_motor_proxy[6];
+ can_step_motor_proxy[0].initialize(40, &m_zcanbus); // BOARD4
+ can_step_motor_proxy[1].initialize(41, &m_zcanbus);
+
+ can_step_motor_proxy[2].initialize(50, &m_zcanbus); // BOARD5
+ can_step_motor_proxy[3].initialize(51, &m_zcanbus);
+
+ can_step_motor_proxy[4].initialize(60, &m_zcanbus); // BOARD6
+ can_step_motor_proxy[5].initialize(61, &m_zcanbus);
+ REG_SUB_MODULE(can_step_motor_proxy);
+}
+
+void Device::line_locking_solenoid_valve_init() {}
+void Device::line_locking_solenoid_valve(bool on) {}
diff --git a/usrc/device.hpp b/usrc/device.hpp
new file mode 100644
index 0000000..6796ff6
--- /dev/null
+++ b/usrc/device.hpp
@@ -0,0 +1,94 @@
+#pragma once
+
+#include "sdk/os/zos.hpp"
+#include "sdk\components\flash\zsimple_flash.hpp"
+#include "sdk\components\zcancmder\zcanreceiver.hpp"
+#include "sdk\components\zcancmder_module\zcan_basic_order_module.hpp"
+#include "sdk\components\zprotocols\zcancmder_v2\protocol_parser.hpp"
+//
+#include "sdk\components\flash\znvs.hpp"
+//
+#include "sdk/components/step_motor_ctrl_module/step_motor_ctrl_module.hpp"
+#include "sdk\components\cmdscheduler\cmd_scheduler_v2.hpp"
+#include "sdk\components\hardware\uart\zuart_dma_receiver.hpp"
+#include "sdk\components\mini_servo_motor\mini_servo_motor_ctrl_module.hpp"
+#include "sdk\components\modbus\modbus_block_host.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"
+#include "sdk\components\ti\drv8710.hpp"
+#include "sdk\components\tmc\ic\ztmc5130.hpp"
+#include "sdk\components\water_cooling_temperature_control_module\pwm_ctrl_module.hpp"
+#include "sdk\components\water_cooling_temperature_control_module\water_cooling_temperature_control_module.hpp"
+#include "sdk\components\zcancmder\zcan_board_module.hpp"
+#include "sdk\components\zcancmder\zcanreceiver_master.hpp"
+#include "sdk\components\zprotocol_helper\micro_computer_module_device_script_cmder_paser.hpp"
+#include "sdk\components\zprotocols\zcancmder_v2\protocol_proxy.hpp"
+#include "sdk\components\zprotocols\zcancmder_v2\zmodule_device_manager.hpp"
+namespace iflytop {
+using namespace std;
+
+typedef enum {
+
+ // 主轴绕线电机
+ kdevice_widing_motor = 1,
+ // 线锁死电磁阀
+ kdevice_line_locking_solenoid_valve = 2,
+
+ // 退线舵机
+ kdevice_back_line_servo_motor = 10,
+ // 线宽探测舵机
+ kdevice_line_width_servo_motor = 11,
+ // 压线舵机
+ kdevice_press_line_servo_motor = 12,
+ // 线引导舵机
+ kdevice_line_guide_servo_motor = 13,
+ // 线夹舵机
+ kdevice_line_clamp_servo_motor = 14,
+ // 线拉紧舵机
+ kdevice_line_tighten_servo_motor = 15,
+
+ // XY平台
+ kdevice_xy_platform = 21,
+
+ // Z轴
+ kdevice_z_axis_motor = 31,
+ // Z轴压线电机
+ kdevice_z_axis_press_line_motor = 32,
+ // Z轴梭夹
+ kdevice_z_axis_shuttle_clamp = 33,
+
+} sub_device_list_t;
+
+class Device {
+ ZModuleDeviceManager m_device_manager;
+ CmdSchedulerV2 m_uart_cmdline_parser;
+
+ ModbusBlockHost m_modbus;
+ /*******************************************************************************
+ * CAN_BUS *
+ *******************************************************************************/
+ ZCanCommnaderMaster m_zcanbus;
+ /*******************************************************************************
+ * FEI_TE_BUS *
+ *******************************************************************************/
+ FeiTeServoMotor m_feitebus;
+ /*******************************************************************************
+ * SUB CAN MODULE *
+ *******************************************************************************/
+ public:
+ void init();
+
+ /**
+ * @brief 锁线电磁阀控制
+ */
+ void line_locking_solenoid_valve_init();
+ void line_locking_solenoid_valve(bool on);
+
+ private:
+ void init_uart_cmder();
+ void init_dm();
+ void init_bus();
+ void sub_module_init();
+};
+} // namespace iflytop
\ No newline at end of file
diff --git a/usrc/global.cpp b/usrc/global.cpp
deleted file mode 100644
index 009b73b..0000000
--- a/usrc/global.cpp
+++ /dev/null
@@ -1,9 +0,0 @@
-
-#include "sdk\components\zcancmder\zcanreceiver_master.hpp"
-namespace iflytop {
-ZGPIO g_Key0;
-ZGPIO g_Key1;
-ZGPIO g_Key2;
-ZGPIO g_StateLight1;
-ZCanCommnaderMaster g_zcanCommnaderMaster;
-} // namespace iflytop
\ No newline at end of file
diff --git a/usrc/global.hpp b/usrc/global.hpp
deleted file mode 100644
index 9612761..0000000
--- a/usrc/global.hpp
+++ /dev/null
@@ -1,10 +0,0 @@
-#pragma once
-#include "sdk\components\zcancmder\zcanreceiver_master.hpp"
-
-namespace iflytop {
-extern ZGPIO g_Key0;
-extern ZGPIO g_Key1;
-extern ZGPIO g_Key2;
-extern ZGPIO g_StateLight1;
-extern ZCanCommnaderMaster g_zcanCommnaderMaster;
-} // namespace iflytop
\ No newline at end of file
diff --git a/usrc/main.cpp b/usrc/main.cpp
index e7f910f..4c2468e 100644
--- a/usrc/main.cpp
+++ b/usrc/main.cpp
@@ -1,12 +1,32 @@
#include
#include
-#include "cmdline_version.hpp"
-#include "global.hpp"
-#include "project_configs.h"
#include "sdk/os/zos.hpp"
+#include "sdk\components\flash\zsimple_flash.hpp"
+#include "sdk\components\zcancmder\zcanreceiver.hpp"
+#include "sdk\components\zcancmder_module\zcan_basic_order_module.hpp"
+#include "sdk\components\zprotocols\zcancmder_v2\protocol_parser.hpp"
+//
+#include "sdk\components\flash\znvs.hpp"
+//
+#include "device.hpp"
+#include "sdk/components/step_motor_ctrl_module/step_motor_ctrl_module.hpp"
+#include "sdk\components\cmdscheduler\cmd_scheduler_v2.hpp"
+#include "sdk\components\hardware\uart\zuart_dma_receiver.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"
+#include "sdk\components\ti\drv8710.hpp"
+#include "sdk\components\tmc\ic\ztmc5130.hpp"
+#include "sdk\components\water_cooling_temperature_control_module\pwm_ctrl_module.hpp"
+#include "sdk\components\water_cooling_temperature_control_module\water_cooling_temperature_control_module.hpp"
+#include "sdk\components\zcancmder\zcan_board_module.hpp"
#include "sdk\components\zcancmder\zcanreceiver_master.hpp"
-#include "transparent_version.hpp"
+#include "sdk\components\zprotocol_helper\micro_computer_module_device_script_cmder_paser.hpp"
+#include "sdk\components\zprotocols\zcancmder_v2\protocol_proxy.hpp"
+#include "sdk\components\zprotocols\zcancmder_v2\zmodule_device_manager.hpp"
+// #include "M3078CodeScanner"
#define TAG "main"
using namespace std;
@@ -17,15 +37,6 @@ extern "C" {
void StartDefaultTask(void const* argument) { umain(); }
}
-void umain() {
- g_Key0.initAsInput(KEY0, ZGPIO::kMode_pullup, ZGPIO::kIRQ_noIrq, false);
- g_StateLight1.initAsOutput(STATE_LIGHT_GPIO, ZGPIO::kMode_pullup, false, false);
+Device gdevice;
- if (g_Key0.getState()) {
- g_StateLight1.setState(true);
- cmdline_version_main();
- } else {
- g_StateLight1.setState(false);
- transparent_version_main();
- }
-};
+void umain() { gdevice.init(); };
diff --git a/usrc/project_configs.h b/usrc/project_configs.h
index 741754f..3adb2a2 100644
--- a/usrc/project_configs.h
+++ b/usrc/project_configs.h
@@ -2,13 +2,13 @@
#define PC_VERSION "v1.0.0"
#define PC_MANUFACTURER "http://www.iflytop.com/"
-#define PC_PROJECT_NAME "zcancmder_debug_board"
+#define PC_PROJECT_NAME "Intelligent_winding_robot_main_board"
#define PC_IFLYTOP_ENABLE_OS 1
#define PC_DEBUG_UART huart1
#define PC_DEBUG_UART_DMA_HANDLER hdma_usart1_rx
#define PC_DEBUG_UART_RX_BUF_SIZE 1024
-#define PC_DEBUG_LIGHT_GPIO PF10
+#define PC_DEBUG_LIGHT_GPIO PG0
#define PC_SYS_DELAY_US_TIMER htim6 // US延时定时器
#define PC_SYS_ZTICKET_TIMER TIM11 // 系统ticket定时器
diff --git a/usrc/transparent_version.cpp b/usrc/transparent_version.cpp
deleted file mode 100644
index 241848d..0000000
--- a/usrc/transparent_version.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-#include
-#include
-
-#include "sdk/os/zos.hpp"
-#include "sdk\components\flash\zsimple_flash.hpp"
-#include "sdk\components\zcancmder\zcanreceiver.hpp"
-#include "sdk\components\zcancmder_module\zcan_basic_order_module.hpp"
-#include "sdk\components\zprotocols\zcancmder_v2\protocol_parser.hpp"
-//
-#include "sdk\components\flash\znvs.hpp"
-//
-#include "sdk/components/step_motor_ctrl_module/step_motor_ctrl_module.hpp"
-#include "sdk\components\cmdscheduler\cmd_scheduler_v2.hpp"
-#include "sdk\components\hardware\uart\zuart_dma_receiver.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"
-#include "sdk\components\ti\drv8710.hpp"
-#include "sdk\components\tmc\ic\ztmc5130.hpp"
-#include "sdk\components\water_cooling_temperature_control_module\pwm_ctrl_module.hpp"
-#include "sdk\components\water_cooling_temperature_control_module\water_cooling_temperature_control_module.hpp"
-#include "sdk\components\zcancmder\zcan_board_module.hpp"
-#include "sdk\components\zcancmder\zcanreceiver_master.hpp"
-#include "sdk\components\zprotocol_helper\micro_computer_module_device_script_cmder_paser.hpp"
-#include "sdk\components\zprotocols\zcancmder_v2\protocol_proxy.hpp"
-#include "sdk\components\zprotocols\zcancmder_v2\zmodule_device_manager.hpp"
-#include "string.h"
-// #include "M3078CodeScanner"
-#include "global.hpp"
-
-#define TAG "main"
-using namespace iflytop;
-using namespace std;
-
-uint32_t m_rxbufsize;
-bool m_dataisready = false;
-char m_cmdcache[1024] = {0};
-
-void transparent_version_main() {
- chip_cfg_t chipcfg;
- chipcfg.us_dleay_tim = &PC_SYS_DELAY_US_TIMER;
- chipcfg.tim_irq_scheduler_tim = &PC_SYS_TIM_IRQ_SCHEDULER_TIMER;
- chipcfg.huart = NULL;
- chipcfg.debuglight = PC_DEBUG_LIGHT_GPIO;
-
- chip_init(&chipcfg);
-
- zos_cfg_t zoscfg;
- zos_init(&zoscfg);
-
- ZLOGI(TAG, "boardId:%d", 0);
-
- ZLOGI(TAG, "init can bus");
- auto* m_zcanCommnaderMaster_cfg = g_zcanCommnaderMaster.createCFG(); // can总线配置
- g_zcanCommnaderMaster.init(m_zcanCommnaderMaster_cfg); // can总线
- ZLOGI(TAG, "init can bus end...");
-
- static ZUARTDmaReceiver dmaUartReceiver;
- static CmdSchedulerV2 cmder;
- ZUARTDmaReceiver::hardware_config_t cfg = {
- .huart = &PC_DEBUG_UART,
- .dma_rx = &PC_DEBUG_UART_DMA_HANDLER,
- .rxbuffersize = PC_DEBUG_UART_RX_BUF_SIZE,
- .rxovertime_ms = 3,
- };
- ZLOGI(TAG, "init cmder");
- dmaUartReceiver.initialize(&cfg);
- dmaUartReceiver.startRx([](uint8_t* data, size_t len) {
- if (!m_dataisready) {
- memcpy(m_cmdcache, data, len);
- m_rxbufsize = len;
- m_dataisready = true;
- }
- });
-
- g_zcanCommnaderMaster.regRawPacketListener([](uint8_t* packet, size_t len) { //
- HAL_UART_Transmit(&PC_DEBUG_UART, packet, len, 1000);
- osDelay(5);
- });
-
- while (true) {
- OSDefaultSchduler::getInstance()->loop();
- if (m_dataisready) {
- g_zcanCommnaderMaster.sendRawPacket((uint8_t*)m_cmdcache, m_rxbufsize);
- m_dataisready = false;
- }
- }
-};
diff --git a/usrc/transparent_version.hpp b/usrc/transparent_version.hpp
deleted file mode 100644
index 531df61..0000000
--- a/usrc/transparent_version.hpp
+++ /dev/null
@@ -1,3 +0,0 @@
-#pragma once
-void transparent_version_main();
-