diff --git a/sdk b/sdk index 8de2a83..967d39b 160000 --- a/sdk +++ b/sdk @@ -1 +1 @@ -Subproject commit 8de2a83d2ad130ac129af84c58b2f587a3f9afe3 +Subproject commit 967d39b1f8cac49b7a1bfd1ca491dd7cc1e4b97e diff --git a/usrc/main.cpp b/usrc/main.cpp index 94f480d..603ef3a 100644 --- a/usrc/main.cpp +++ b/usrc/main.cpp @@ -3,6 +3,11 @@ #include "sdk/os/zos.hpp" #include "sdk\components\tmc\ic\ztmc4361A.hpp" +#include "sdk\components\xy_robot_ctrl_module\xy_robot_ctrl_module.hpp" +#include "sdk\components\zcancmder\zcanreceiver.hpp" +#include "sdk\components\zcancmder_module\zcan_basic_order_module.hpp" +#include "sdk\components\zcancmder_module\zcan_xy_robot_module.hpp" + #define TAG "main" using namespace iflytop; using namespace std; @@ -13,12 +18,14 @@ void StartDefaultTask(void const* argument) { umain(); } } #define TMC_MOTOR_SPI hspi1 - +static TMC4361A motora; +static TMC4361A motorb; +static ZCanCmder zcanCmder; +static ZCanBasicOrderModule zcanBasicOrderModule; +static ZCANXYRobotCtrlModule zcanXYRobotCtrlModule; +static XYRobotCtrlModule xyRobotCtrlModule; void umain() { - /******************************************************************************* - * * - *******************************************************************************/ chip_cfg_t chipcfg; chipcfg.us_dleay_tim = &DELAY_US_TIMER; chipcfg.tim_irq_scheduler_tim = &TIM_IRQ_SCHEDULER_TIMER; @@ -32,9 +39,6 @@ void umain() { osDelay(1000); - static TMC4361A motora; - static TMC4361A motorb; - { TMC4361A::cfg_t cfg = { .spi = &TMC_MOTOR_SPI, // @@ -73,10 +77,38 @@ void umain() { motora.rotate(0); motorb.rotate(0); - // motorb.rotate(100000); + auto zcanCmder_cfg = zcanCmder.createCFG(DEVICE_ID); + zcanCmder.init(zcanCmder_cfg); + + /******************************************************************************* + * zcanBasicOrderModule * + *******************************************************************************/ + 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; + }); + + uint16_t maincmdid = (((uint32_t)kcmd_xy_robot_ctrl_enable) >> 8) & 0xFFFF; + uint8_t subcmdId = (((uint32_t)kcmd_xy_robot_ctrl_enable)) & 0xFF; + + printf("maincmdid:%d subcmdId:%d\n", maincmdid, subcmdId); + + /******************************************************************************* + * zcanXYRobotCtrlModule * + *******************************************************************************/ + xyRobotCtrlModule.initialize(&motora, &motorb, NULL, NULL, 1.0f); + zcanXYRobotCtrlModule.initialize(&zcanCmder, 1, &xyRobotCtrlModule); while (true) { OSDefaultSchduler::getInstance()->loop(); - osDelay(1); + zcanCmder.loop(); + // zcanCmder.sendPacket(data, 4); + // osDelay(100); } } diff --git a/usrc/project_configs.h b/usrc/project_configs.h index b8021d6..93b3aa7 100644 --- a/usrc/project_configs.h +++ b/usrc/project_configs.h @@ -2,7 +2,7 @@ #define VERSION "v1.0.0" #define MANUFACTURER "http://www.iflytop.com/" -#define PROJECT_NAME "ecom_monitor" +#define PROJECT_NAME "filarobot_arm" #define DEBUG_UART huart1 #define DEBUG_LIGHT_GPIO PE2 @@ -13,6 +13,8 @@ #define IFLYTOP_ENABLE_OS 1 #define IFLYTOP_PREEMPTPRIORITY_DEFAULT 5 +#define DEVICE_ID (2) + /*********************************************************************************/ // MOTOR1