diff --git a/.cproject b/.cproject
index b900dfb..8b70b2b 100644
--- a/.cproject
+++ b/.cproject
@@ -130,7 +130,7 @@
-
+
diff --git a/.settings/com.st.stm32cube.ide.mcu.sfrview.prefs b/.settings/com.st.stm32cube.ide.mcu.sfrview.prefs
new file mode 100644
index 0000000..98a69fc
--- /dev/null
+++ b/.settings/com.st.stm32cube.ide.mcu.sfrview.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+sfrviewstate={"fFavorites"\:{"fLists"\:{}},"fProperties"\:{"fNodeProperties"\:{}}}
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 6d51097..3080e17 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -21,6 +21,45 @@
"cstdint": "c",
"stm32f4xx_hal_rcc.h": "c",
"stm32f4xx_hal_def.h": "c",
- "stm32_hal_legacy.h": "c"
+ "stm32_hal_legacy.h": "c",
+ "array": "cpp",
+ "bit": "cpp",
+ "cctype": "cpp",
+ "clocale": "cpp",
+ "cmath": "cpp",
+ "concepts": "cpp",
+ "cstddef": "cpp",
+ "cstdio": "cpp",
+ "cstdlib": "cpp",
+ "cwchar": "cpp",
+ "cwctype": "cpp",
+ "deque": "cpp",
+ "map": "cpp",
+ "set": "cpp",
+ "string": "cpp",
+ "unordered_map": "cpp",
+ "vector": "cpp",
+ "exception": "cpp",
+ "algorithm": "cpp",
+ "functional": "cpp",
+ "iterator": "cpp",
+ "memory_resource": "cpp",
+ "numeric": "cpp",
+ "string_view": "cpp",
+ "system_error": "cpp",
+ "tuple": "cpp",
+ "type_traits": "cpp",
+ "utility": "cpp",
+ "fstream": "cpp",
+ "initializer_list": "cpp",
+ "iosfwd": "cpp",
+ "istream": "cpp",
+ "limits": "cpp",
+ "new": "cpp",
+ "numbers": "cpp",
+ "ostream": "cpp",
+ "stdexcept": "cpp",
+ "streambuf": "cpp",
+ "typeinfo": "cpp"
}
}
\ No newline at end of file
diff --git a/Core/Src/tim.c b/Core/Src/tim.c
index 07c46ea..4157ad3 100644
--- a/Core/Src/tim.c
+++ b/Core/Src/tim.c
@@ -124,7 +124,7 @@ void MX_TIM6_Init(void)
/* USER CODE END TIM6_Init 1 */
htim6.Instance = TIM6;
- htim6.Init.Prescaler = 81;
+ htim6.Init.Prescaler = 71;
htim6.Init.CounterMode = TIM_COUNTERMODE_UP;
htim6.Init.Period = 65535;
htim6.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
diff --git a/robotic_core_xy.ioc b/robotic_core_xy.ioc
index 3bd9f99..b203f1f 100644
--- a/robotic_core_xy.ioc
+++ b/robotic_core_xy.ioc
@@ -215,7 +215,7 @@ TIM3.IPParameters=Prescaler,Period
TIM3.Period=9999
TIM3.Prescaler=71
TIM6.IPParameters=Prescaler
-TIM6.Prescaler=81
+TIM6.Prescaler=71
TIM7.IPParameters=Prescaler
TIM7.Prescaler=81
USART1.IPParameters=VirtualMode
diff --git a/usrc/main.cpp b/usrc/main.cpp
index 2353eab..857c9a5 100644
--- a/usrc/main.cpp
+++ b/usrc/main.cpp
@@ -7,22 +7,78 @@
#include "project.hpp"
//
#include "sdk/hal/zhal.hpp"
+#include "sdk\components\tmc\ic\ztmc4361A.hpp"
+
+#define TAG "main"
namespace iflytop {
Main gmain;
};
using namespace iflytop;
void Main::run() {
- iflytop_no_os_cfg_t cfg = {
+ iflytop_no_os_cfg_t oscfg = {
.delayhtim = &DELAY_US_TIMER,
.debuguart = &DEBUG_UART,
};
- iflytop_no_os_init(&cfg);
- printf("Hello World!\r\n");
+ iflytop_no_os_init(&oscfg);
+
+ ZLOGI(TAG, "robotic_core_xy:%s", VERSION);
DEBUG_LIGHT_GPIO.initAsOutput(true);
+ ZHAL_CORE_REG(200, { DEBUG_LIGHT_GPIO.toggleState(); });
+
+ // while (true) {
+ // chip_delay_us(1000 * 1000);
+ // ZLOGI(TAG, ".....");
+ // }
+ TMC4361A motora;
+ TMC4361A motorb;
+ TMC_MOTOR1_SPI_SELECT1_IO.initAsOutput(true);
+ TMC_MOTOR1_nFREEZE_IO.initAsOutput(true);
+ TMC_MOTOR1_nRESET_IO.initAsOutput(true);
+ TMC_MOTOR1_SUB_IC_ENN_IO.initAsOutput(true);
+ TMC_MOTOR2_SPI_SELECT1_IO.initAsOutput(true);
+ TMC_MOTOR2_nFREEZE_IO.initAsOutput(true);
+ TMC_MOTOR2_nRESET_IO.initAsOutput(true);
+ TMC_MOTOR2_SUB_IC_ENN_IO.initAsOutput(true);
+ {
+ TMC4361A::cfg_t motora_cfg = {.spi = &TMC_MOTOR_SPI,
+ .csgpio = &TMC_MOTOR1_SPI_SELECT1_IO,
+ .resetPin = &TMC_MOTOR1_nRESET_IO,
+ .fREEZEPin = &TMC_MOTOR1_nFREEZE_IO,
+ .ennPin = NULL,
+ .driverIC_ennPin = &TMC_MOTOR1_SUB_IC_ENN_IO,
+ .driverIC_resetPin = NULL};
+
+ motora.initialize(&motora_cfg);
+ int32_t ic4361Version = motora.readICVersion();
+ int32_t ic2160Version = motora.readSubICVersion();
+ ZLOGI(TAG, "motora:TMC4361Version:%lx TMC2160VERSION:%lx", ic4361Version, ic2160Version);
+ }
+
+ {
+ TMC4361A::cfg_t motorb_cfg = {.spi = &TMC_MOTOR_SPI,
+ .csgpio = &TMC_MOTOR2_SPI_SELECT1_IO,
+ .resetPin = &TMC_MOTOR2_nRESET_IO,
+ .fREEZEPin = &TMC_MOTOR2_nFREEZE_IO,
+ .ennPin = NULL,
+ .driverIC_ennPin = &TMC_MOTOR2_SUB_IC_ENN_IO,
+ .driverIC_resetPin = NULL};
+
+ motorb.initialize(&motorb_cfg);
+ int32_t ic4361Version = motorb.readICVersion();
+ int32_t ic2160Version = motorb.readSubICVersion();
+ ZLOGI(TAG, "motorb:TMC4361Version:%lx TMC2160VERSION:%lx", ic4361Version, ic2160Version);
+ }
+
+ motora.setIHOLD_IRUN(1, 28, 0); // 小臂
+ motora.setMotorShaft(0);
+
+ motorb.setIHOLD_IRUN(1, 28, 0); // 小臂
+ motorb.setMotorShaft(0);
- ZHAL_CORE_REG(300, { DEBUG_LIGHT_GPIO.toggleState(); });
+ motora.rotate(1200000);
+ motorb.rotate(1200000);
while (1) {
ZHALCORE::getInstance()->loop();
diff --git a/usrc/project.hpp b/usrc/project.hpp
index e50609a..397f3b6 100644
--- a/usrc/project.hpp
+++ b/usrc/project.hpp
@@ -1,6 +1,6 @@
#pragma once
-#define VERSION "v1.0"
+#define VERSION "v2.0"
// 设备ID
#define DEVICE_ID (128 + 3)
// 调试串口