diff --git a/components/step_motor_45/step_motor_45.cpp b/components/step_motor_45/step_motor_45.cpp index 2a683c6..f732a46 100644 --- a/components/step_motor_45/step_motor_45.cpp +++ b/components/step_motor_45/step_motor_45.cpp @@ -33,7 +33,7 @@ stepmotor_control_matrix_t onestepsq2[] = { #define MAX_STEP_TABLE_OFF (ZARRAY_SIZE(onestepsq1) - 1) -void StepMotor45::initialize(cfg_t cfg) { +void StepMotor45::initialize(StepMotor45Scheduler* scheduler, cfg_t cfg) { m_cfg = cfg; // ³õʼ»¯GPIO @@ -54,6 +54,7 @@ void StepMotor45::initialize(cfg_t cfg) { m_zeroPinZGPIO->initAsInput(cfg.zeroPin, ZGPIO::kMode_pullup, ZGPIO::kIRQ_noIrq, cfg.zeroPinMirror); } setdriverpinstate(1, 1, 1, 1); + scheduler->addMotor(this); return; } @@ -221,7 +222,7 @@ int32_t StepMotor45::move_to(int to, int speed) { CriticalContext cc; if (to == m_pos) { - return (int32_t)0; + return (int32_t)0; } if (to <= m_pos) { diff --git a/components/step_motor_45/step_motor_45.hpp b/components/step_motor_45/step_motor_45.hpp index c04f77d..42ecaa3 100644 --- a/components/step_motor_45/step_motor_45.hpp +++ b/components/step_motor_45/step_motor_45.hpp @@ -1,6 +1,7 @@ #pragma once #include "sdk/os/zos.hpp" +#include "sdk\components\step_motor_45\step_motor_45_scheduler.hpp" namespace iflytop { using namespace std; @@ -59,7 +60,7 @@ class StepMotor45 { int defaultspeed = 1000; public: - void initialize(cfg_t cfg); + void initialize(StepMotor45Scheduler *scheduler, cfg_t cfg); int32_t rotate(int direction) { rotate(direction, defaultspeed); } int32_t rotate(int direction, int speed); diff --git a/components/step_motor_45/step_motor_45_scheduler.cpp b/components/step_motor_45/step_motor_45_scheduler.cpp index a50e707..eb1d6fd 100644 --- a/components/step_motor_45/step_motor_45_scheduler.cpp +++ b/components/step_motor_45/step_motor_45_scheduler.cpp @@ -1,5 +1,6 @@ #include "step_motor_45_scheduler.hpp" +#include "step_motor_45.hpp" using namespace iflytop; void StepMotor45Scheduler::initialize(zchip_tim_t* tim, int freq) { diff --git a/components/step_motor_45/step_motor_45_scheduler.hpp b/components/step_motor_45/step_motor_45_scheduler.hpp index d170e0b..02431a4 100644 --- a/components/step_motor_45/step_motor_45_scheduler.hpp +++ b/components/step_motor_45/step_motor_45_scheduler.hpp @@ -1,10 +1,10 @@ #pragma once #include "sdk/os/zos.hpp" -#include "step_motor_45.hpp" +// #include "step_motor_45.hpp" namespace iflytop { using namespace std; - +class StepMotor45; class StepMotor45Scheduler { public: zchip_tim_t* m_htim;