diff --git a/.cproject b/.cproject
index 2c2b3f1..dbd73e0 100644
--- a/.cproject
+++ b/.cproject
@@ -90,6 +90,7 @@
+
diff --git a/sdk b/sdk
index 6377ea5..998c09f 160000
--- a/sdk
+++ b/sdk
@@ -1 +1 @@
-Subproject commit 6377ea57353ab7b08f5c141378f346d8f9075805
+Subproject commit 998c09f13efa863031c2a01cd0ffb8e7964b3c05
diff --git a/usrc/main.cpp b/usrc/main.cpp
index ac14131..038612d 100644
--- a/usrc/main.cpp
+++ b/usrc/main.cpp
@@ -3,14 +3,13 @@
#include "sdk/components/step_motor_ctrl_module/step_motor_ctrl_module.hpp"
#include "sdk/components/step_motor_ctrl_module/step_motor_ctrl_script_cmder_module.hpp"
-#include "sdk/components/step_motor_ctrl_module/zcan_master_step_motor_ctrl_module.hpp"
-#include "sdk/components/step_motor_ctrl_module/zcan_step_motor_ctrl_module.hpp"
#include "sdk/os/zos.hpp"
#include "sdk\components\flash\zsimple_flash.hpp"
#include "sdk\components\mini_servo_motor\feite_servo_motor.hpp"
#include "sdk\components\tmc\ic\ztmc5130.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"
//
@@ -24,10 +23,10 @@ extern "C" {
void StartDefaultTask(void const* argument) { umain(); }
}
-static TMC5130 g_motor;
-static ZCanCmder g_zcanCmder;
-static StepMotorCtrlModule g_stepMotorCtrlModule;
-static ZCanStepMotorCtrlModule g_zcanStepMotorCtrlModule;
+static TMC5130 g_motor;
+static ZCanCmder g_zcanCmder;
+static StepMotorCtrlModule g_stepMotorCtrlModule;
+static ZIProtocolParser g_ziProtocolParser;
uint8_t getId() {
static bool init = false;
@@ -61,13 +60,8 @@ void umain() {
zos_init(&zoscfg);
uint8_t deviceId = getId();
- ZLOGI(TAG, "motorId:%d boardId", deviceId, deviceId + ZCAN_CMD_PUBLIC_DEVICE_ID_STEP_MOTOR_BOARD_OFFEST);
- if (deviceId == 0) {
- chip_set_error();
- while (true) {
- osDelay(1000);
- }
- }
+ ZLOGI(TAG, "motorId:%d", deviceId + STEP_MOTOR_ID_OFF);
+
/*******************************************************************************
* NVSINIT *
@@ -100,24 +94,12 @@ void umain() {
g_motor.rotate(0);
// g_motor.enable(false);
- auto zcanCmder_cfg = g_zcanCmder.createCFG(deviceId + ZCAN_CMD_PUBLIC_DEVICE_ID_STEP_MOTOR_BOARD_OFFEST);
+ auto zcanCmder_cfg = g_zcanCmder.createCFG( deviceId + STEP_MOTOR_ID_OFF);
g_zcanCmder.init(zcanCmder_cfg);
/*******************************************************************************
* zcanBasicOrderModule *
*******************************************************************************/
-#if 0
- zcanBasicOrderModule.initialize(&zcanCmder);
- zcanBasicOrderModule.reg_set_io(1, [](bool val) { ZLOGI(TAG, "write io 1:%d", val); });
- zcanBasicOrderModule.reg_read_io(1, []() {
- ZLOGI(TAG, "read io 1");
- return 1;
- });
- zcanBasicOrderModule.reg_read_adc(1, []() {
- ZLOGI(TAG, "read adc 1");
- return 123;
- });
-#endif
/*******************************************************************************
* zcanXYRobotCtrlModule *
@@ -153,7 +135,8 @@ void umain() {
1000);
g_stepMotorCtrlModule.initialize(deviceId, &g_motor, input, ZARRAY_SIZE(input), "MOTOR_CFG_FLASH_MARK");
- g_zcanStepMotorCtrlModule.initialize(&g_zcanCmder, 1, &g_stepMotorCtrlModule);
+ g_ziProtocolParser.initialize(&g_zcanCmder);
+ g_ziProtocolParser.registerModule(&g_stepMotorCtrlModule);
while (true) {
OSDefaultSchduler::getInstance()->loop();