|
|
@ -16,7 +16,7 @@ static motor_t *motor_init_structer; |
|
|
|
|
|
|
|
/** |
|
|
|
* @brief 电机初始化 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param motor 初始化的结构体(暂时写死,所以结构体为空) |
|
|
|
*/ |
|
|
|
void motor_init(motor_t *motor) { |
|
|
@ -37,7 +37,6 @@ void motor_init(motor_t *motor) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static double motor_drive_read_encoder(); |
|
|
|
static uint8_t motor_drive_set_packages_ctr(double position, int direction); |
|
|
|
|
|
|
@ -82,7 +81,7 @@ void motor_run_to_postion(int rotation_direction, double position, int speed_lev |
|
|
|
uint8_t checksum = 0; |
|
|
|
uint32_t limit_speed = 0; |
|
|
|
uint8_t buffer[14] = {0x3E, 0XA6, MOTOR_ID, 0X08, 0XED, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00}; |
|
|
|
// char *notify_err = "set size error"; |
|
|
|
// char *notify_err = "set size error"; |
|
|
|
|
|
|
|
// forward |
|
|
|
if ((rotation_direction == 1)) { |
|
|
@ -146,20 +145,20 @@ void motor_run_to_postion(int rotation_direction, double position, int speed_lev |
|
|
|
} |
|
|
|
|
|
|
|
// Parse receive |
|
|
|
// motor_drive_buffer_cmd_parse(buffer); |
|
|
|
// motor_drive_buffer_cmd_parse(buffer); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @brief 注册回调 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param onevent 注册的回调函数 |
|
|
|
*/ |
|
|
|
void motor_reg_event_cb(motor_on_event_t onevent) { return; } |
|
|
|
|
|
|
|
/** |
|
|
|
* @brief 读取编码器 |
|
|
|
* |
|
|
|
* |
|
|
|
* @return double 编码器当前位置值返回 |
|
|
|
*/ |
|
|
|
static double motor_drive_read_encoder() { |
|
|
@ -189,10 +188,10 @@ static double motor_drive_read_encoder() { |
|
|
|
|
|
|
|
/** |
|
|
|
* @brief 控制电机转多少度 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param position 角度 |
|
|
|
* @param direction 方向 |
|
|
|
* @return uint8_t |
|
|
|
* @return uint8_t |
|
|
|
*/ |
|
|
|
static uint8_t motor_drive_set_packages_ctr(double position, int direction) { |
|
|
|
int position_int = 0; |
|
|
|