diff --git a/.settings/stm32cubeide.project.prefs b/.settings/stm32cubeide.project.prefs index 834c4e0..43115de 100644 --- a/.settings/stm32cubeide.project.prefs +++ b/.settings/stm32cubeide.project.prefs @@ -1,5 +1,5 @@ 635E684B79701B039C64EA45C3F84D30=6180EFBD1DA04EB1319C95830D4DB159 66BE74F758C12D739921AEA421D593D3=5 -8DF89ED150041C4CBC7CB9A9CAA90856=C40676F5C274295C653AEC2EC599A69D -DC22A860405A8BF2F2C095E5B6529F12=C40676F5C274295C653AEC2EC599A69D +8DF89ED150041C4CBC7CB9A9CAA90856=F84C9880C15B9874E9E687B6E474D0B5 +DC22A860405A8BF2F2C095E5B6529F12=F84C9880C15B9874E9E687B6E474D0B5 eclipse.preferences.version=1 diff --git a/Core/Inc/FreeRTOSConfig.h b/Core/Inc/FreeRTOSConfig.h index e663bda..1eb7a78 100644 --- a/Core/Inc/FreeRTOSConfig.h +++ b/Core/Inc/FreeRTOSConfig.h @@ -64,7 +64,7 @@ #define configTICK_RATE_HZ ((TickType_t)1000) #define configMAX_PRIORITIES ( 7 ) #define configMINIMAL_STACK_SIZE ((uint16_t)128) -#define configTOTAL_HEAP_SIZE ((size_t)15360) +#define configTOTAL_HEAP_SIZE ((size_t)30000) #define configMAX_TASK_NAME_LEN ( 16 ) #define configUSE_16_BIT_TICKS 0 #define configUSE_MUTEXES 1 diff --git a/Intelligent_winding_robot_main_board.ioc b/Intelligent_winding_robot_main_board.ioc index 9e81ea8..d8afeb7 100644 --- a/Intelligent_winding_robot_main_board.ioc +++ b/Intelligent_winding_robot_main_board.ioc @@ -60,8 +60,9 @@ Dma.USART3_TX.1.PeriphInc=DMA_PINC_DISABLE Dma.USART3_TX.1.Priority=DMA_PRIORITY_LOW Dma.USART3_TX.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode FREERTOS.FootprintOK=true -FREERTOS.IPParameters=Tasks01,FootprintOK,configUSE_RECURSIVE_MUTEXES,configUSE_NEWLIB_REENTRANT +FREERTOS.IPParameters=Tasks01,FootprintOK,configUSE_RECURSIVE_MUTEXES,configUSE_NEWLIB_REENTRANT,configTOTAL_HEAP_SIZE FREERTOS.Tasks01=defaultTask,0,512,StartDefaultTask,As weak,NULL,Dynamic,NULL,NULL +FREERTOS.configTOTAL_HEAP_SIZE=30000 FREERTOS.configUSE_NEWLIB_REENTRANT=1 FREERTOS.configUSE_RECURSIVE_MUTEXES=1 File.Version=6 @@ -167,7 +168,7 @@ ProjectManager.DeviceId=STM32F407ZGTx ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.27.1 ProjectManager.FreePins=false ProjectManager.HalAssertFull=false -ProjectManager.HeapSize=0x200 +ProjectManager.HeapSize=0x8000 ProjectManager.KeepUserCode=true ProjectManager.LastFirmware=true ProjectManager.LibraryCopy=1 @@ -179,7 +180,7 @@ ProjectManager.ProjectFileName=Intelligent_winding_robot_main_board.ioc ProjectManager.ProjectName=Intelligent_winding_robot_main_board ProjectManager.ProjectStructure= ProjectManager.RegisterCallBack= -ProjectManager.StackSize=0x400 +ProjectManager.StackSize=0x1000 ProjectManager.TargetToolchain=STM32CubeIDE ProjectManager.ToolChainLocation= ProjectManager.UAScriptAfterPath= diff --git a/STM32F407ZGTX_FLASH.ld b/STM32F407ZGTX_FLASH.ld index 01845e8..7a03950 100644 --- a/STM32F407ZGTX_FLASH.ld +++ b/STM32F407ZGTX_FLASH.ld @@ -39,8 +39,8 @@ ENTRY(Reset_Handler) /* Highest address of the user mode stack */ _estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */ -_Min_Heap_Size = 0x200; /* required amount of heap */ -_Min_Stack_Size = 0x400; /* required amount of stack */ +_Min_Heap_Size = 0x8000; /* required amount of heap */ +_Min_Stack_Size = 0x1000; /* required amount of stack */ /* Memories definition */ MEMORY diff --git a/sdk b/sdk index 68d4e5e..b953c9f 160000 --- a/sdk +++ b/sdk @@ -1 +1 @@ -Subproject commit 68d4e5e6315c6cc16ec1d19cf3f0344716faa6b3 +Subproject commit b953c9fc5b6b58c1fcccf72e4bfa9686289cf0df diff --git a/usrc/main.cpp b/usrc/main.cpp index 824e6af..7211a6a 100644 --- a/usrc/main.cpp +++ b/usrc/main.cpp @@ -21,6 +21,8 @@ #include "sdk\components/xy_robot_ctrl_module/zcan_xy_robot_master_module.hpp" #include "sdk\components\eq_20_asb_motor\script_cmder_eq20_servomotor.hpp" #include "sdk\components\mini_servo_motor\mini_servo_motor_ctrl_module.hpp" +#include "sdk\components\mini_servo_motor\scirpt_cmder_mini_servo_motor_ctrl_module.hpp" +#include "sdk\components\step_motor_45\script_cmder_step_motor_45.hpp" // #include "sdk\components\scriptcmder_module\xy_robot_script_cmder_module.hpp" // #include "sdk\components\zcancmder_master_module/zcan_master_step_motor_ctrl_module.hpp" // #include "sdk\components\zcancmder_master_module\zcan_xy_robot_master_module.hpp" @@ -152,72 +154,13 @@ I_StepMotorCtrlModule* g_z_step_motor = nullptr; /******************************************************************************* * ´®¿ÚÖ¸Áî * *******************************************************************************/ -StepMotorCtrlScriptCmderModule g_step_motor_ctrl_script_cmder_module; -XYRobotScriptCmderModule g_script_xyrobot; -ScriptCmderEq20Servomotor g_script_eq20servomotor; +StepMotorCtrlScriptCmderModule g_step_motor_ctrl_script_cmder_module; +XYRobotScriptCmderModule g_script_xyrobot; +ScriptCmderEq20Servomotor g_script_eq20servomotor; +ScirptCmderMiniServoMotorCtrlModule g_script_mini_servo_motor_ctrl_module; +ScriptCmderStepMotor45 g_script_step_motor45; } // namespace iflytop -#if 0 -void regfn() { - // setzero - // set4095 - // moveto -#if 0 - cmdScheduler.registerCmd("mini_servo_set_zero", [](int argc, char** argv, CmdScheduler::CmdProcessContext* context) { - CHECK_ARGC(1); - int id = atoi(argv[1]); - ZLOGI(TAG, "mini_servo_set_zero %d", id); - g_feiteservomotor.reCalibration(id, 0); - ZLOGI(TAG, "mini_servo_set_zero %d done", id); - }); - cmdScheduler.registerCmd("mini_servo_set_4095", [](int argc, char** argv, CmdScheduler::CmdProcessContext* context) { - CHECK_ARGC(1); - int id = atoi(argv[1]); - ZLOGI(TAG, "mini_servo_set_4095 %d", id); - g_feiteservomotor.reCalibration(id, 4095); - ZLOGI(TAG, "mini_servo_set_4095 %d done", id); - }); - cmdScheduler.registerCmd("mini_servo_move_to", [](int argc, char** argv, CmdScheduler::CmdProcessContext* context) { - CHECK_ARGC(3); - int id = atoi(argv[1]); - int pos = atoi(argv[2]); - int torque = atoi(argv[3]); - - ZLOGI(TAG, "mini_servo_move_to %d %d %d %d", id, pos, 2700, torque); - g_feiteservomotor.moveTo(id, pos, 2700, torque); - }); - cmdScheduler.registerCmd("mini_servo_rotate", [](int argc, char** argv, CmdScheduler::CmdProcessContext* context) { - CHECK_ARGC(2); - int id = atoi(argv[1]); - int speed = atoi(argv[2]); - // int v = atoi(3000); - ZLOGI(TAG, "mini_servo_rotate %d %d %d", id, speed, 10, 2700); - g_feiteservomotor.rotate(id, speed, 10); - }); - cmdScheduler.registerCmd("mini_servo_move_with_torque", [](int argc, char** argv, CmdScheduler::CmdProcessContext* context) { - CHECK_ARGC(2); - int id = atoi(argv[1]); - int torque = atoi(argv[2]); - // int v = atoi(3000); - if (torque == 0) { - g_feiteservomotor.moveWithTorque(id, 1); - } else { - g_feiteservomotor.moveWithTorque(id, torque); - } - }); - - cmdScheduler.registerCmd("sleep_ms", [](int argc, char** argv, CmdScheduler::CmdProcessContext* context) { - CHECK_ARGC(1); - osDelay(atoi(argv[1])); - }); - - cmdScheduler.registerCmd("hbot_enable", [](int argc, char** argv, CmdScheduler::CmdProcessContext* context) { - CHECK_ARGC(0); - g_xyrobotctrlmodule->enable(false); - }); -#endif -} -#endif extern "C" { extern DMA_HandleTypeDef hdma_usart3_rx; @@ -259,7 +202,22 @@ void Main::run() { ZASSERT(g_z_step_motor != nullptr); g_xyrobotctrlmodule = zcancmder_master::create_xyrobot_ctrl_module(&m_zcanCommnaderMaster, 1); + g_mini_servo[0].initialize(&g_feiteservomotor_bus, 1); + g_mini_servo[1].initialize(&g_feiteservomotor_bus, 2); + g_mini_servo[2].initialize(&g_feiteservomotor_bus, 3); + g_mini_servo[3].initialize(&g_feiteservomotor_bus, 4); + g_mini_servo[4].initialize(&g_feiteservomotor_bus, 5); + StepMotor45Scheduler step_motor45_scheduler; + step_motor45_scheduler.initialize(&htim10, 1000); + + g_step_motor45[0].initialize(&step_motor45_scheduler, cfg1); + g_step_motor45[1].initialize(&step_motor45_scheduler, cfg2); + g_step_motor45[2].initialize(&step_motor45_scheduler, cfg3); + g_step_motor45[3].initialize(&step_motor45_scheduler, cfg4); + g_step_motor45[4].initialize(&step_motor45_scheduler, cfg5); + g_step_motor45[5].initialize(&step_motor45_scheduler, cfg6); + step_motor45_scheduler.start(); /******************************************************************************* * CMD * @@ -272,56 +230,23 @@ void Main::run() { g_script_xyrobot.initialize(&g_cmdScheduler); g_script_xyrobot.regmodule(1, g_xyrobotctrlmodule); -#if 0 - - g_xyrobotctrlmodule = zcancmder_master::create_xyrobot_ctrl_module(&m_zcanCommnaderMaster, 1); - // g_xyrobotctrlmodule->enable(false); - - g_stepmotorctrlmodule = zcancmder_master::create_zcan_master_step_motor_ctrl_module(&m_zcanCommnaderMaster, 1); - // g_stepmotorctrlmodule->rotate(300000, 0, [this](int32_t end) {}); - cmdScheduler - xyRobotScriptCmderModule.initialize(&cmdScheduler); - xyRobotScriptCmderModule.regXYRobot(1, g_xyrobotctrlmodule); + g_script_mini_servo_motor_ctrl_module.initialize(&g_cmdScheduler); + g_script_mini_servo_motor_ctrl_module.regmodule(1, &g_mini_servo[0]); + g_script_mini_servo_motor_ctrl_module.regmodule(2, &g_mini_servo[1]); + g_script_mini_servo_motor_ctrl_module.regmodule(3, &g_mini_servo[2]); + g_script_mini_servo_motor_ctrl_module.regmodule(4, &g_mini_servo[3]); + g_script_mini_servo_motor_ctrl_module.regmodule(5, &g_mini_servo[4]); + + g_script_step_motor45.initialize(&g_cmdScheduler); + g_script_step_motor45.regmodule(1, &g_step_motor45[0]); + g_script_step_motor45.regmodule(2, &g_step_motor45[1]); + g_script_step_motor45.regmodule(3, &g_step_motor45[2]); + g_script_step_motor45.regmodule(4, &g_step_motor45[3]); + g_script_step_motor45.regmodule(5, &g_step_motor45[4]); + g_script_step_motor45.regmodule(6, &g_step_motor45[5]); - - regfn(); - - int i = 1; - g_step_motor[i++].initialize(11, 10000, &m_IflytopCanMaster); - g_step_motor[i++].initialize(12, 10000, &m_IflytopCanMaster); - g_step_motor[i++].initialize(13, 10000, &m_IflytopCanMaster); - g_step_motor[i++].initialize(14, 10000, &m_IflytopCanMaster); - g_step_motor[i++].initialize(15, 10000, &m_IflytopCanMaster); - g_step_motor[i++].initialize(16, 10000, &m_IflytopCanMaster); - - g_step_motor45[0].initialize(cfg1); - g_step_motor45[1].initialize(cfg1); - g_step_motor45[2].initialize(cfg2); - g_step_motor45[3].initialize(cfg3); - g_step_motor45[4].initialize(cfg4); - g_step_motor45[5].initialize(cfg5); - g_step_motor45[6].initialize(cfg6); - - StepMotor45Scheduler step_motor45_scheduler; - step_motor45_scheduler.initialize(&htim10, 1000); - step_motor45_scheduler.addMotor(&g_step_motor45[1]); - step_motor45_scheduler.addMotor(&g_step_motor45[2]); - step_motor45_scheduler.addMotor(&g_step_motor45[3]); - step_motor45_scheduler.addMotor(&g_step_motor45[4]); - step_motor45_scheduler.addMotor(&g_step_motor45[5]); - step_motor45_scheduler.addMotor(&g_step_motor45[6]); - // g_step_motor45_1.rotate(true, 1000); - - step_motor45_scheduler.start(); - - - g_modbusblockhost.initialize(&huart2); - g_eq20servomotor.init(&g_modbusblockhost); - g_feiteservomotor.initialize(&huart3, &hdma_usart3_rx, &hdma_usart3_tx); -#endif - #if 0 step_motor_cmd_reg(); #endif