#ifndef _COMMUNICATION_H__
#define _COMMUNICATION_H__
#include "libs/types.h"

typedef enum {
	Cmd_Start = 0x1, //start/stop
	Cmd_Ready,       //ready / unready
	Cmd_Hall_Cali,
	Cmd_Limit_Speed,
	Cmd_Limit_Current,
	Cmd_PI_Param
}motor_cmd_t;
#define MY_CAN_ADDR 0x30
#pragma  pack (push,1)  
typedef struct
{
	uint8_t src:7;
	uint8_t dir:1; //0->out, 1 ->in，如果发现收到的是0,可能是红外那边自环过来的，需要丢弃
}cmd_head_t;

typedef struct {
	cmd_head_t head;
	uint8_t key;
	uint8_t data[0];
}cmd_frame_t;
#pragma pack(pop)

#pragma  pack (push,1) 
typedef struct {
	u8 start; //0x1=start, 0x00=stop
	u16 speed; //目标速度
	s16 current;//启动电流
	u16 ramp_time;//斜波时间
}cmd_start_t;

typedef struct {
	u8 ready; //0x1=ready, 0x00=unready
}cmd_ready_t;

typedef struct {
	u8  start;
	s16 current;
}cmd_hall_cali_t;

#pragma pack(pop)


#endif /* _COMMUNICATION_H__ */

