MotorDriver.h 1.51 KB
Newer Older
时昊's avatar
时昊 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
/*
 * MOTOR.h
 *
 *  Created on: Apr 21, 2019
 *      Author: qitiancun
 */

#ifndef MOTORDRIVER_H_
#define MOTORDRIVER_H_

typedef struct
{
	unsigned short curPosition;
	unsigned short destPosition;
} MeterPostion_t;

typedef enum
{
	direction_1 = 0,
	direction_2,
} MoveDirection_t;

typedef enum
{
	Motor_0 = 0,
	Motor_1,
	Motor_2,
	Motor_3,
	Motor_4,
	Motor_5,
	
} MotorIndex_t;

typedef enum
{
	Normal = 0,
	MinReset,
	MaxReset,
	MaxStep,
	MaxStepKeep,
	MinStep
} workMode_t;
typedef enum
{
	Motor_BKA = 0,
	Motor_TYW,
} motorType_t;

extern volatile MeterPostion_t MeterPostion[6]; /* 6 个电机位置数组 */

extern unsigned char *bsp_MotorGetVersion(void); /* 获取版本号 */

extern void bsp_MotorMove_50us_main(void); /* 必须在 VectorNumber_Vmctimovf 中断中调用,初始化电机默认使能中断 */

extern unsigned char bsp_set_meterCfg(motorType_t motorType, unsigned char meterIndex,unsigned char motorIndex, MoveDirection_t motorDir, unsigned short MaxAngle, unsigned short One_Step_Damp, unsigned char (*ZeroPosition)(void));

extern void bsp_SetMotorMode(unsigned char index, workMode_t Mode); /* 设置电机工作模式 */

extern workMode_t bsp_GetMotorState(unsigned char index); /* 获取电机工作模式 */

extern void bsp_SetOneStepDamp(unsigned char motorIndex, unsigned int One_Step_Damp); /* 设置每一步阻尼时间 */

extern void bsp_MotorDriverOff(void);

extern void bsp_SetMaxSpeed(unsigned char motorIndex, unsigned int speed); /* speed 越小越快,默认是1 */

#endif /* MOTORDRIVER_H_ */