|
@@ -199,60 +199,60 @@ uint8_t motor_init_ok(void)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-uint8_t motor_msg_parse(struct rt_can_msg msg)
|
|
|
|
|
|
+uint8_t motor_msg_parse(struct rt_can_msg *msg)
|
|
{
|
|
{
|
|
uint8_t temp = 1;
|
|
uint8_t temp = 1;
|
|
uint16_t svd;
|
|
uint16_t svd;
|
|
- if(msg.ide!=RT_CAN_STDID)
|
|
|
|
|
|
+ if(msg->ide!=RT_CAN_STDID)
|
|
return temp;
|
|
return temp;
|
|
- if(msg.id == motor.id + 0x580) /* 定时上传 */
|
|
|
|
|
|
+ if(msg->id == motor.id + 0x580) /* 定时上传 */
|
|
{
|
|
{
|
|
temp = 0;
|
|
temp = 0;
|
|
- svd = (msg.data[1]<<8) + msg.data[2];
|
|
|
|
|
|
+ svd = (msg->data[1]<<8) + msg->data[2];
|
|
switch(svd)/* 功能码 */
|
|
switch(svd)/* 功能码 */
|
|
{
|
|
{
|
|
case 0x6060: //工作模式
|
|
case 0x6060: //工作模式
|
|
- motor.mode = msg.data[4]; //
|
|
|
|
|
|
+ motor.mode = msg->data[4]; //
|
|
break;
|
|
break;
|
|
case 0x4060: //控制字
|
|
case 0x4060: //控制字
|
|
- motor.control = msg.data[4]; //
|
|
|
|
|
|
+ motor.control = msg->data[4]; //
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- else
|
|
|
|
- if(msg.id == 0x0700) /*即发即回:主站发送,从站回复,以0x700为id,功能码+1,进行状态和参数信息交换*/
|
|
|
|
- {
|
|
|
|
- temp = 0;
|
|
|
|
- if(msg.data[0] == motor.id) /* 源地址 */
|
|
|
|
- {
|
|
|
|
- if(msg.data[1] ==0x1F)/* 功能码 */
|
|
|
|
- {
|
|
|
|
- if(msg.data[2]==0x00 && msg.data[3]==0x03) /* 速度模式地址 */
|
|
|
|
- {
|
|
|
|
- if(msg.data[5] == mode_pos)
|
|
|
|
- motor.mode = mode_pos;
|
|
|
|
- else
|
|
|
|
- if(msg.data[5] == mode_speed)
|
|
|
|
- motor.mode = mode_speed;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- if(msg.data[1] ==0x25)/* 功能码 */
|
|
|
|
- {
|
|
|
|
- if(msg.data[2]==0x00 && msg.data[3]==0xb8) /* 加速度地址 */
|
|
|
|
- {
|
|
|
|
- motor.acc = 1;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- if(msg.data[2]==0x00 && msg.data[3]==0xb9) /* 减速度地址 */
|
|
|
|
- {
|
|
|
|
- motor.dcc = 1;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+// else
|
|
|
|
+// if(msg->id == 0x0700) /*即发即回:主站发送,从站回复,以0x700为id,功能码+1,进行状态和参数信息交换*/
|
|
|
|
+// {
|
|
|
|
+// temp = 0;
|
|
|
|
+// if(msg->data[0] == motor.id) /* 源地址 */
|
|
|
|
+// {
|
|
|
|
+// if(msg->data[1] ==0x1F)/* 功能码 */
|
|
|
|
+// {
|
|
|
|
+// if(msg->data[2]==0x00 && msg.data[3]==0x03) /* 速度模式地址 */
|
|
|
|
+// {
|
|
|
|
+// if(msg.data[5] == mode_pos)
|
|
|
|
+// motor.mode = mode_pos;
|
|
|
|
+// else
|
|
|
|
+// if(msg.data[5] == mode_speed)
|
|
|
|
+// motor.mode = mode_speed;
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// else
|
|
|
|
+// if(msg.data[1] ==0x25)/* 功能码 */
|
|
|
|
+// {
|
|
|
|
+// if(msg.data[2]==0x00 && msg.data[3]==0xb8) /* 加速度地址 */
|
|
|
|
+// {
|
|
|
|
+// motor.acc = 1;
|
|
|
|
+// }
|
|
|
|
+// else
|
|
|
|
+// if(msg.data[2]==0x00 && msg.data[3]==0xb9) /* 减速度地址 */
|
|
|
|
+// {
|
|
|
|
+// motor.dcc = 1;
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
//数据解析
|
|
//数据解析
|
|
return temp;
|
|
return temp;
|
|
}
|
|
}
|