Browse Source

moveToEndTestVersion

moveToEndTestVersion
zhaohe 11 months ago
parent
commit
fbefb0e3d1
  1. 2
      stm32components
  2. 20
      usrc/module/tmc_motor_group.cpp

2
stm32components

@ -1 +1 @@
Subproject commit 29c41362b35e5097f8b52751098aede52133aed5
Subproject commit 16ccc17d6d41154562af9294f49c5545cedaea00

20
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);

Loading…
Cancel
Save