55 lines
1.4 KiB
C
55 lines
1.4 KiB
C
/*******************************************************************************
|
|
* @file motor.h
|
|
* @author: MQjehovah mail:MQjehovah@hotmail.com
|
|
* @version 1.0.0
|
|
* @date 2020.0.20
|
|
* @brief
|
|
******************************************************************************
|
|
* @attention
|
|
*******************************************************************************/
|
|
#ifndef __MOTOR_H
|
|
#define __MOTOR_H
|
|
/* Includes ------------------------------------------------------------------*/
|
|
#include "stm32f10x_conf.h"
|
|
/* Definition ----------------------------------------------------------------*/
|
|
enum motor_mode
|
|
{
|
|
MOTOR_MODE_SPEED, //速度模式
|
|
MOTOR_MODE_POSITION, //位置模式
|
|
MOTOR_MODE_TORQUE, //转矩模式
|
|
};
|
|
|
|
enum motor_dir
|
|
{
|
|
MOTOR_DIR_CW, //正向
|
|
MOTOR_DIR_CCW //反向
|
|
};
|
|
|
|
enum motor_state
|
|
{
|
|
MOTOR_STATE_STOP //停止状态
|
|
};
|
|
|
|
typedef struct _motor
|
|
{
|
|
u8 mode; //电机控制模式
|
|
u8 dir;
|
|
u8 state; //运行状态
|
|
u8 hall_position; //霍尔位置
|
|
s16 speed; //转速
|
|
u32 step;
|
|
|
|
} motor_t;
|
|
|
|
/* Exported Functions --------------------------------------------------------*/
|
|
extern motor_t motor_info;
|
|
|
|
void motor_init(void);
|
|
void motor_start(void);
|
|
void motor_stop(void);
|
|
void motor_step(void);
|
|
void motor_set_speed(s16 speed);
|
|
|
|
#endif
|
|
/*********************************END OF FILE**********************************/
|