|
|
@ -5,9 +5,10 @@ using namespace iflytop; |
|
|
|
/***********************************************************************************************************************
|
|
|
|
* 电机异常监控 * |
|
|
|
***********************************************************************************************************************/ |
|
|
|
static osTimerId MotorMonitorTimerId; // 压力传感器数值上报
|
|
|
|
static bool motorErrorFlagCache[10]; // 电机异常状态上报标志位
|
|
|
|
static zmutex motorErrorFlagCacheLock; |
|
|
|
static osTimerId MotorMonitorTimerId; // 压力传感器数值上报
|
|
|
|
static bool motorErrorFlagCache[10]; // 电机异常状态上报标志位
|
|
|
|
static zmutex motorErrorFlagCacheLock; |
|
|
|
static TmcMotorGroup* tmcgroup_p; |
|
|
|
|
|
|
|
static bool motorErrorFlag_get(int subindex) { |
|
|
|
bool ret; |
|
|
@ -26,12 +27,15 @@ static void motorErrorFlag_set(int subindex, bool val) { |
|
|
|
} |
|
|
|
|
|
|
|
static void onMotorMonitorTimer(void const* argument) { |
|
|
|
return; |
|
|
|
// 电机异常检查
|
|
|
|
TmcMotorGroup* DEVICE = (TmcMotorGroup*)argument; |
|
|
|
// ZLOGI(TAG, "x MotorMonitorTimerId: %p", argument);
|
|
|
|
// return;
|
|
|
|
|
|
|
|
// return;
|
|
|
|
// 电机异常检查
|
|
|
|
TmcMotorGroup* DEVICE = (TmcMotorGroup*)tmcgroup_p; |
|
|
|
report_exeception_data_t data; |
|
|
|
for (size_t i = 0; i < DEVICE->motorNum(); i++) { |
|
|
|
ZLOGI(TAG, "check motor %d", i); |
|
|
|
// ZLOGI(TAG, "check motor %d", i);
|
|
|
|
bool estate = motorErrorFlag_get(i); |
|
|
|
|
|
|
|
if (!DEVICE->motor(i)->ping()) { |
|
|
@ -100,8 +104,10 @@ void TmcMotorGroup::initialize(Pin_t tmcPowerPin, TMC51X0Cfg cfg0, TMC51X0Cfg cf |
|
|
|
ZLOGI(TAG, "motor1: reset:%d drv_err:%d uv_cp:%d", gstate1.reset, gstate1.drv_err, gstate1.uv_cp); |
|
|
|
|
|
|
|
motorErrorFlagCacheLock.init(); |
|
|
|
tmcgroup_p = this; |
|
|
|
osTimerDef(MotorMonitorTimer, onMotorMonitorTimer); |
|
|
|
MotorMonitorTimerId = osTimerCreate(osTimer(MotorMonitorTimer), osTimerPeriodic, this); |
|
|
|
ZLOGI(TAG, "MotorMonitorTimerId: %p", this); |
|
|
|
osTimerStart(MotorMonitorTimerId, 1000); |
|
|
|
m_isInitialized = true; |
|
|
|
} |
|
|
@ -208,4 +214,4 @@ void TmcMotorGroup::fn_pump_ping(ProcessContext* cxt) { |
|
|
|
CHECK_PARAM_LEN(PRAAM_LEN(), 1); |
|
|
|
MOTOR_CHECK(); |
|
|
|
zcanbus_send_ack(cxt->packet, NULL, 0); |
|
|
|
} |
|
|
|
} |