Browse Source

update

master
zhaohe 2 years ago
parent
commit
67d8a85eaf
  1. 2
      .cproject
  2. 2
      .settings/com.st.stm32cube.ide.mcu.sfrview.prefs
  3. 41
      .vscode/settings.json
  4. 2
      Core/Src/tim.c
  5. 2
      robotic_core_xy.ioc
  6. 64
      usrc/main.cpp
  7. 2
      usrc/project.hpp

2
.cproject

@ -130,7 +130,7 @@
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.2026007863" name="Floating-point ABI" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi" useByScannerDiscovery="true" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.value.hard" valueType="enumerated"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.772961433" name="Board" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board" useByScannerDiscovery="false" value="genericBoard" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.1999660059" name="Defaults" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" useByScannerDiscovery="false" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.6 || Release || false || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.option.toolchain.value.workspace || STM32F407VETx || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Core/Inc | ../Drivers/STM32F4xx_HAL_Driver/Inc | ../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy | ../Drivers/CMSIS/Device/ST/STM32F4xx/Include | ../Drivers/CMSIS/Include || || || USE_HAL_DRIVER | STM32F407xx || || Drivers | Core/Startup | Core || || || ${workspace_loc:/${ProjName}/STM32F407VETX_FLASH.ld} || true || NonSecure || || secure_nsclib.o || || None || || || " valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.debug.option.cpuclock.1733776023" superClass="com.st.stm32cube.ide.mcu.debug.option.cpuclock" value="144" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.debug.option.cpuclock.1733776023" superClass="com.st.stm32cube.ide.mcu.debug.option.cpuclock" useByScannerDiscovery="false" value="144" valueType="string"/>
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.1767941885" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/>
<builder buildPath="${workspace_loc:/robotic_core_xy}/Release" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.1109588320" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.1819027329" name="MCU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler">

2
.settings/com.st.stm32cube.ide.mcu.sfrview.prefs

@ -0,0 +1,2 @@
eclipse.preferences.version=1
sfrviewstate={"fFavorites"\:{"fLists"\:{}},"fProperties"\:{"fNodeProperties"\:{}}}

41
.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"
}
}

2
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;

2
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

64
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();

2
usrc/project.hpp

@ -1,6 +1,6 @@
#pragma once
#define VERSION "v1.0"
#define VERSION "v2.0"
// 设备ID
#define DEVICE_ID (128 + 3)
// 调试串口

Loading…
Cancel
Save