|
@ -8,7 +8,8 @@ using namespace transmit_disfection_protocol; |
|
|
/***********************************************************************************************************************
|
|
|
/***********************************************************************************************************************
|
|
|
* 电机异常监控 * |
|
|
* 电机异常监控 * |
|
|
***********************************************************************************************************************/ |
|
|
***********************************************************************************************************************/ |
|
|
static osTimerId MotorMonitorTimerId; // 压力传感器数值上报
|
|
|
|
|
|
|
|
|
static osTimerId MotorMonitorTimerId; //
|
|
|
|
|
|
static osTimerId MoveToEndUpdateTimer; //
|
|
|
static bool motorErrorFlagCache[10]; // 电机异常状态上报标志位
|
|
|
static bool motorErrorFlagCache[10]; // 电机异常状态上报标志位
|
|
|
static zmutex motorErrorFlagCacheLock = {"motorErrorFlagCacheLock"}; |
|
|
static zmutex motorErrorFlagCacheLock = {"motorErrorFlagCacheLock"}; |
|
|
static TmcMotorGroup* tmcgroup_p; |
|
|
static TmcMotorGroup* tmcgroup_p; |
|
@ -28,6 +29,16 @@ static void motorErrorFlag_set(int subindex, bool val) { |
|
|
motorErrorFlagCache[subindex] = 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) { |
|
|
static void onMotorMonitorTimer(void const* argument) { |
|
|
// ZLOGI(TAG, "x MotorMonitorTimerId: %p", argument);
|
|
|
// ZLOGI(TAG, "x MotorMonitorTimerId: %p", argument);
|
|
@ -143,10 +154,15 @@ void TmcMotorGroup::initialize(Pin_t tmcPowerPin, TMC51X0Cfg cfg0, TMC51X0Cfg cf |
|
|
|
|
|
|
|
|
motorErrorFlagCacheLock.init(); |
|
|
motorErrorFlagCacheLock.init(); |
|
|
tmcgroup_p = this; |
|
|
tmcgroup_p = this; |
|
|
|
|
|
|
|
|
osTimerDef(MotorMonitorTimer, onMotorMonitorTimer); |
|
|
osTimerDef(MotorMonitorTimer, onMotorMonitorTimer); |
|
|
MotorMonitorTimerId = osTimerCreate(osTimer(MotorMonitorTimer), osTimerPeriodic, this); |
|
|
MotorMonitorTimerId = osTimerCreate(osTimer(MotorMonitorTimer), osTimerPeriodic, this); |
|
|
ZLOGI(TAG, "MotorMonitorTimerId: %p", this); |
|
|
|
|
|
osTimerStart(MotorMonitorTimerId, 1000); |
|
|
osTimerStart(MotorMonitorTimerId, 1000); |
|
|
|
|
|
|
|
|
|
|
|
osTimerDef(MoveToEndUpdateTimer, onMoveToEndUpdateTimer); |
|
|
|
|
|
MoveToEndUpdateTimer = osTimerCreate(osTimer(MoveToEndUpdateTimer), osTimerPeriodic, this); |
|
|
|
|
|
osTimerStart(MoveToEndUpdateTimer, 10000); |
|
|
|
|
|
|
|
|
m_isInitialized = true; |
|
|
m_isInitialized = true; |
|
|
|
|
|
|
|
|
BIND_FN(TmcMotorGroup, this, fn_pump_rotate); |
|
|
BIND_FN(TmcMotorGroup, this, fn_pump_rotate); |
|
|