diff --git a/stm32components b/stm32components index 29c4136..16ccc17 160000 --- a/stm32components +++ b/stm32components @@ -1 +1 @@ -Subproject commit 29c41362b35e5097f8b52751098aede52133aed5 +Subproject commit 16ccc17d6d41154562af9294f49c5545cedaea00 diff --git a/usrc/module/tmc_motor_group.cpp b/usrc/module/tmc_motor_group.cpp index d7d76eb..fe387a5 100644 --- a/usrc/module/tmc_motor_group.cpp +++ b/usrc/module/tmc_motor_group.cpp @@ -8,7 +8,8 @@ using namespace transmit_disfection_protocol; /*********************************************************************************************************************** * 电机异常监控 * ***********************************************************************************************************************/ -static osTimerId MotorMonitorTimerId; // 压力传感器数值上报 +static osTimerId MotorMonitorTimerId; // +static osTimerId MoveToEndUpdateTimer; // static bool motorErrorFlagCache[10]; // 电机异常状态上报标志位 static zmutex motorErrorFlagCacheLock = {"motorErrorFlagCacheLock"}; static TmcMotorGroup* tmcgroup_p; @@ -28,6 +29,16 @@ static void motorErrorFlag_set(int subindex, bool val) { motorErrorFlagCache[subindex] = val; } } +static void onMoveToEndUpdateTimer(void const* argument) { + TmcMotorGroup* DEVICE = (TmcMotorGroup*)tmcgroup_p; + report_exeception_data_t data = {0}; + for (size_t i = 0; i < DEVICE->motorNum(); i++) { + if (DEVICE->motor(i)->isMoveToEnd()) { + ZLOGI(TAG, "refreshMoveToEnd %d", i); + DEVICE->motor(i)->refreshMoveToEnd(); + } + } +} static void onMotorMonitorTimer(void const* argument) { // ZLOGI(TAG, "x MotorMonitorTimerId: %p", argument); @@ -143,10 +154,15 @@ void TmcMotorGroup::initialize(Pin_t tmcPowerPin, TMC51X0Cfg cfg0, TMC51X0Cfg cf motorErrorFlagCacheLock.init(); tmcgroup_p = this; + osTimerDef(MotorMonitorTimer, onMotorMonitorTimer); MotorMonitorTimerId = osTimerCreate(osTimer(MotorMonitorTimer), osTimerPeriodic, this); - ZLOGI(TAG, "MotorMonitorTimerId: %p", this); osTimerStart(MotorMonitorTimerId, 1000); + + osTimerDef(MoveToEndUpdateTimer, onMoveToEndUpdateTimer); + MoveToEndUpdateTimer = osTimerCreate(osTimer(MoveToEndUpdateTimer), osTimerPeriodic, this); + osTimerStart(MoveToEndUpdateTimer, 10000); + m_isInitialized = true; BIND_FN(TmcMotorGroup, this, fn_pump_rotate);