|
|
|
@ -41,6 +41,7 @@ |
|
|
|
*----------------------------------------------*/ |
|
|
|
static Motor_Instance_t *g_apstMotors[MOTOR_INSTANCE_MAX] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; |
|
|
|
static uint32_t g_uiMotorModuleID = 0; |
|
|
|
static int g_aiMotorSpeed[MOTOR_INSTANCE_MAX] = {0}; |
|
|
|
|
|
|
|
/*----------------------------------------------*
|
|
|
|
* 常量定义 * |
|
|
|
@ -61,14 +62,10 @@ static void Motor_ModuleHandler(const Msg_t *pstMsg) |
|
|
|
{ |
|
|
|
case MOTOR_CMD_SET_SPEED: |
|
|
|
{ |
|
|
|
if (pstMsg->m_uiDataLen >= sizeof(Motor_CmdData_t)) |
|
|
|
{ |
|
|
|
Motor_CmdData_t *pstData = (Motor_CmdData_t *)pstMsg->m_aucData; |
|
|
|
if (pstData->m_ucMotorIndex < 2 && g_apstMotors[pstData->m_ucMotorIndex] != NULL) |
|
|
|
{ |
|
|
|
MotorMgr_SetTargetSpeed(g_apstMotors[pstData->m_ucMotorIndex], pstData->m_iValue); |
|
|
|
} |
|
|
|
} |
|
|
|
int iSpeed = (int)pstMsg->m_aucData; |
|
|
|
log_i("Set Speed %d", iSpeed); |
|
|
|
// g_aiMotorSpeed[0] = iSpeed;
|
|
|
|
// g_aiMotorSpeed[1] = iSpeed;
|
|
|
|
break; |
|
|
|
} |
|
|
|
case MOTOR_CMD_STOP: |
|
|
|
@ -84,14 +81,7 @@ static void Motor_ModuleHandler(const Msg_t *pstMsg) |
|
|
|
} |
|
|
|
case MOTOR_CMD_SET_HOME: |
|
|
|
{ |
|
|
|
if (pstMsg->m_uiDataLen >= sizeof(Motor_CmdData_t)) |
|
|
|
{ |
|
|
|
Motor_CmdData_t *pstData = (Motor_CmdData_t *)pstMsg->m_aucData; |
|
|
|
if (pstData->m_ucMotorIndex < 2 && g_apstMotors[pstData->m_ucMotorIndex] != NULL) |
|
|
|
{ |
|
|
|
MotorMgr_SetHome(g_apstMotors[pstData->m_ucMotorIndex]); |
|
|
|
} |
|
|
|
} |
|
|
|
log_i("Not Support [%d]", pstMsg->m_uiMsgID); |
|
|
|
break; |
|
|
|
} |
|
|
|
case MOTOR_CMD_GET_STATUS: |
|
|
|
@ -234,7 +224,7 @@ void MotorTask(void *argument) |
|
|
|
MotorMgr_RequestPosition(g_apstMotors[i]); |
|
|
|
MotorMgr_RequestFault(g_apstMotors[i]); |
|
|
|
MotorMgr_RequestVelocity(g_apstMotors[i]); |
|
|
|
MotorMgr_SetTargetSpeed(g_apstMotors[i], 50000); |
|
|
|
MotorMgr_SetTargetSpeed(g_apstMotors[i], g_aiMotorSpeed[i]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|