#include #include #include "sdk/os/zos.hpp" #include "sdk\components\tmc\ic\ztmc4361A.hpp" #define TAG "main" using namespace iflytop; using namespace std; extern void umain(); extern "C" { void StartDefaultTask(void const* argument) { umain(); } } #define TMC_MOTOR_SPI hspi1 void umain() { /******************************************************************************* * * *******************************************************************************/ chip_cfg_t chipcfg; chipcfg.us_dleay_tim = &DELAY_US_TIMER; chipcfg.tim_irq_scheduler_tim = &TIM_IRQ_SCHEDULER_TIMER; chipcfg.huart = &DEBUG_UART; chipcfg.debuglight = DEBUG_LIGHT_GPIO; chip_init(&chipcfg); zos_cfg_t zoscfg; zos_init(&zoscfg); osDelay(1000); static TMC4361A motora; static TMC4361A motorb; { TMC4361A::cfg_t cfg = { .spi = &TMC_MOTOR_SPI, // .csgpio = TMC_MOTOR1_SPI_SELECT1_IO, // .resetPin = TMC_MOTOR1_nRESET_IO, // .fREEZEPin = TMC_MOTOR1_nFREEZE_IO, // .ennPin = PinNull, // .driverIC_ennPin = TMC_MOTOR1_SUB_IC_ENN_IO, // .driverIC_resetPin = PinNull, // }; motora.initialize(&cfg); ZLOGI(TAG, "motora initialize TMC4361A:%x DriverIC:%x", motora.readICVersion(), motora.readSubICVersion()); } { TMC4361A::cfg_t cfg = { .spi = &TMC_MOTOR_SPI, // .csgpio = TMC_MOTOR2_SPI_SELECT1_IO, // .resetPin = TMC_MOTOR2_nRESET_IO, // .fREEZEPin = TMC_MOTOR2_nFREEZE_IO, // .ennPin = PinNull, // .driverIC_ennPin = TMC_MOTOR2_SUB_IC_ENN_IO, // .driverIC_resetPin = PinNull, // }; motorb.initialize(&cfg); ZLOGI(TAG, "motorb initialize TMC4361A:%x DriverIC:%x", motorb.readICVersion(), motorb.readSubICVersion()); } motora.setAcceleration(300000); motora.setDeceleration(300000); motora.setIHOLD_IRUN(0, 2, 10); motorb.setAcceleration(300000); motorb.setDeceleration(300000); motorb.setIHOLD_IRUN(0, 2, 10); motora.rotate(0); motorb.rotate(0); // motorb.rotate(100000); while (true) { OSDefaultSchduler::getInstance()->loop(); osDelay(1); } }