You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

184 lines
4.6 KiB

/******************************************************************************
(C), 2018-2099, Radkil
******************************************************************************
: motor_manager.h
: 稿
: radkil
: 2026713
:
:
:
1. : 2026713
: radkil
:
******************************************************************************/
#ifndef __MOTOR_MANAGER_H__
#define __MOTOR_MANAGER_H__
#ifdef __cplusplus
#if __cplusplus
extern "C"{
#endif
#endif /* __cplusplus */
/*==============================================*
* include header files *
*----------------------------------------------*/
#include "motor_protocol.h"
/*==============================================*
* constants or macros define *
*----------------------------------------------*/
/*==============================================*
* data structures *
*----------------------------------------------*/
/*==============================================*
* project-wide global variables *
*----------------------------------------------*/
/*==============================================*
* routines' or functions' implementations *
*----------------------------------------------*/
/**
* @brief
*/
void MotorMgr_Init(void);
/**
* @brief
* @param pstConfig
* @param ptCAN CAN控制器
* @param pstProtocol
* @param pstPrivData NULL
* @return NULL
*/
Motor_Instance_t* MotorMgr_Create(const Motor_Config_t *pstConfig,
TComCtrl *ptCAN,
const Motor_Protocol_t *pstProtocol,
void *pstPrivData);
/**
* @brief
* @param pstMotor
* @return 00
*/
int MotorMgr_Destroy(Motor_Instance_t *pstMotor);
/**
* @brief
* @param pszName
* @return NULL
*/
Motor_Instance_t* MotorMgr_FindByName(const char *pszName);
/**
* @brief ID查找电机实例
* @param ucMotorID ID
* @return NULL
*/
Motor_Instance_t* MotorMgr_FindByID(uint8_t ucMotorID);
/**
* @brief
*/
int MotorMgr_ResetAll(Motor_Instance_t *pstMotor);
/**
* @brief
*/
int MotorMgr_ActivateAll(Motor_Instance_t *pstMotor);
/**
* @brief
*/
int MotorMgr_SetHome(Motor_Instance_t *pstMotor);
/**
* @brief
*/
int MotorMgr_SetWatchdog(Motor_Instance_t *pstMotor, uint32_t uiTimeMs);
/**
* @brief
*/
int MotorMgr_RequestPosition(Motor_Instance_t *pstMotor);
/**
* @brief
*/
int MotorMgr_RequestVelocity(Motor_Instance_t *pstMotor);
/**
* @brief /
*/
int MotorMgr_RequestTorque(Motor_Instance_t *pstMotor);
/**
* @brief
*/
int MotorMgr_RequestFault(Motor_Instance_t *pstMotor);
/**
* @brief
*/
int MotorMgr_SpeedModeInit(Motor_Instance_t *pstMotor);
/**
* @brief
*/
int MotorMgr_SetTargetSpeed(Motor_Instance_t *pstMotor, int32_t iTargetSpeed);
/**
* @brief
*/
int MotorMgr_PositionModeInit(Motor_Instance_t *pstMotor, int32_t iAccel, int32_t iDecel, int32_t iTargetSpeed);
/**
* @brief
*/
int MotorMgr_SetTargetPosition(Motor_Instance_t *pstMotor, int32_t iTargetPos);
/**
* @brief
*/
int MotorMgr_SetDO(Motor_Instance_t *pstMotor, uint8_t ucDoIndex, uint8_t ucState);
/**
* @brief CAN响应数据
* @param ucMotorID ID
* @param pucData
* @param uiLen
*/
void MotorMgr_ParseResponse(uint8_t ucMotorID, const uint8_t *pucData, uint32_t uiLen);
/**
* @brief
*/
int32_t MotorMgr_SpeedConvert(Motor_Instance_t *pstMotor, int32_t iSpeedUserUnit);
/**
* @brief
*/
const Motor_Data_t* MotorMgr_GetData(Motor_Instance_t *pstMotor);
/**
* @brief
*/
Motor_State_e MotorMgr_GetState(Motor_Instance_t *pstMotor);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */
#endif /* __MOTOR_MANAGER_H__ */