diff --git a/Intelligent_winding_robot_main_board_dap.launch b/Intelligent_winding_robot_main_board_dap.launch new file mode 100644 index 0000000..3bef02f --- /dev/null +++ b/Intelligent_winding_robot_main_board_dap.launch @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dap.cfg b/dap.cfg new file mode 100644 index 0000000..d02b862 --- /dev/null +++ b/dap.cfg @@ -0,0 +1,43 @@ +# This is an genericBoard board with a single STM32F407VETx chip +# +# Generated by STM32CubeIDE +# Take care that such file, as generated, may be overridden without any early notice. Please have a look to debug launch configuration setup(s) + +source [find interface/cmsis-dap.cfg] + + +set WORKAREASIZE 0x8000 + +transport select "swd" + +set CHIPNAME STM32F407VETx +set BOARDNAME genericBoard + +# Enable debug when in low power modes +set ENABLE_LOW_POWER 1 + +# Stop Watchdog counters when halt +set STOP_WATCHDOG 1 + +# STlink Debug clock frequency +set CLOCK_FREQ 500 + +# Reset configuration +# use hardware reset +reset_config srst_only srst_nogate +set CONNECT_UNDER_RESET 0 +set CORE_RESET 0 + +# ACCESS PORT NUMBER +set AP_NUM 0 +# GDB PORT +set GDB_PORT 3333 + + + + + +# BCTM CPU variables + +source [find target/stm32f4x.cfg] + diff --git a/sdk b/sdk index e0f845b..abfd999 160000 --- a/sdk +++ b/sdk @@ -1 +1 @@ -Subproject commit e0f845bbbd3c31562357b7423a58682ab373c406 +Subproject commit abfd99957b7572b1ca8df0d60ad015ac4fabac1d diff --git a/usrc/cmdline_support.cpp b/usrc/cmdline_support.cpp index cddac57..2bd7d0f 100644 --- a/usrc/cmdline_support.cpp +++ b/usrc/cmdline_support.cpp @@ -21,4 +21,10 @@ void CmdlineSupport::init(Device* device) { m_device->blower_set_val(val); return 0; }); + // app_motor_move_from_a_to_b_block + cmdlineparser->registerCmd("app_motor_move_from_a_to_b_block", "(int motor_id, int32_t a, int32_t b, int32_t times)", 4, // + [this](int32_t paramN, const char** paraV, ICmdParserACK* ack) { + m_device->app_motor_move_from_a_to_b_block(atoi(paraV[0]), atoi(paraV[1]), atoi(paraV[2]), atoi(paraV[3])); + return 0; + }); } \ No newline at end of file diff --git a/usrc/device.cpp b/usrc/device.cpp index 561261c..fdd520f 100644 --- a/usrc/device.cpp +++ b/usrc/device.cpp @@ -37,7 +37,7 @@ void Device::init() { blower_init(); line_locking_solenoid_valve_init(); - + ZLOGI(TAG, "init end..."); } @@ -176,3 +176,39 @@ void Device::line_locking_solenoid_valve(bool on) { line_locking_solenoid_valve_ static ZGPIO blower_gpio; void Device::blower_init() { blower_gpio.initAsOutput(PC2, ZGPIO::kMode_nopull, true, false); } void Device::blower_set_val(bool on) { blower_gpio.setState(on); } + +int32_t Device::app_motor_move_from_a_to_b_block(int motor_id, int32_t a, int32_t b, int32_t times) { + int32_t ret = 0; + for (size_t i = 0; i < times; i++) { + ZLOGI(TAG, "move motor %d to %d", a); + ret = m_device_manager.motor_easy_move_to(motor_id, a); + if (ret != 0) break; + ret = wait_for_module(motor_id); + if (ret != 0) break; + ZLOGI(TAG, "move motor %d to %d", b); + ret = m_device_manager.motor_easy_move_to(motor_id, b); + if (ret != 0) break; + ret = wait_for_module(motor_id); + if (ret != 0) break; + } + return ret; +} + +int32_t Device::wait_for_module(int32_t moduleid) { + ThisThread thisThread; + int32_t i = 0; + while (!thisThread.getExitFlag()) { + int32_t status = 0; + int32_t ecode = m_device_manager.module_get_status(moduleid, &status); + if (ecode == 0 && status == 0) { + ZLOGI(TAG, "wait for module %d ok", moduleid); + return 0; + } + i++; + if (i % 10 == 0) { + ZLOGI(TAG, "wait for module %d err: %s(%d)", moduleid, err::error2str(ecode), ecode); + } + thisThread.sleep(100); + } + return 0; +} diff --git a/usrc/device.hpp b/usrc/device.hpp index d95f308..0f99bf8 100644 --- a/usrc/device.hpp +++ b/usrc/device.hpp @@ -89,6 +89,8 @@ class Device { void blower_init(); void blower_set_val(bool on); + int32_t app_motor_move_from_a_to_b_block(int motor_id, int32_t a, int32_t b, int32_t times); + void loop(); private: @@ -96,5 +98,7 @@ class Device { void init_dm(); void init_bus(); void sub_module_init(); + + int32_t wait_for_module(int32_t module_id); }; } // namespace iflytop \ No newline at end of file