Sfoglia il codice sorgente

1、增加步科电机解析

zhouwz 3 anni fa
parent
commit
ac4ee9cdfc
3 ha cambiato i file con 42 aggiunte e 39 eliminazioni
  1. 38 38
      applications/kinco.c
  2. 1 1
      applications/kinco.h
  3. 3 0
      applications/nav/dl-dwd.c

+ 38 - 38
applications/kinco.c

@@ -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;
 	uint16_t svd;
-	if(msg.ide!=RT_CAN_STDID)
+	if(msg->ide!=RT_CAN_STDID)
 	return temp;
-	if(msg.id == motor.id + 0x580)	/* 定时上传 */
+	if(msg->id == motor.id + 0x580)	/* 定时上传 */
 	{
 		temp = 0;
-		svd = (msg.data[1]<<8) + msg.data[2];
+		svd = (msg->data[1]<<8) + msg->data[2];
 		switch(svd)/* 功能码 */
 		{
 			case 0x6060:	//工作模式
-				motor.mode = msg.data[4];	//
+				motor.mode = msg->data[4];	//
 			break;
             case 0x4060: //控制字
-				motor.control = msg.data[4];	//
+				motor.control = msg->data[4];	//
 			break;
 			default:
 			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;    	
 }

+ 1 - 1
applications/kinco.h

@@ -55,7 +55,7 @@ struct rt_can_msg send_motor_rpm(void) ;
 #endif /* SEND_RPM_EN */
 
 struct rt_can_msg send_motor_reset(void) ;
-uint8_t motor_msg_parse(struct rt_can_msg msg);
+uint8_t motor_msg_parse(struct rt_can_msg *msg);
 void check_motor_miss(void);
 uint8_t get_motor_err(void);
 uint8_t get_motor_miss_err(void);

+ 3 - 0
applications/nav/dl-dwd.c

@@ -17,6 +17,8 @@
 #include "chassis_bus.h"
 #include "kinco.h"
 #include "bms.h"
+#include "kinco.h"
+
 
 #define DBG_SECTION_NAME  "dwd"
 #define DBG_LEVEL         DBG_INFO
@@ -35,6 +37,7 @@ static int DrRecvProcess(void *parser, void *msg, int sz)
     int16_t mgs = 0;
 	ag_bms_parse(can_msg);	//奥冠电池解析
 	bms_parse(can_msg);		//维旭电池解析
+	motor_msg_parse(can_msg);		//步科电机解析
     switch(can_msg->id)
     {
     case 3: