
#ifndef __F_CAN_APP_H__
#define __F_CAN_APP_H__	  


#include "f_System.h"


// CAN初始化步骤
#define CAN_INIT_STEP_RESET_PARAM  		0          		// CAN初始化参数复位
#define CAN_INIT_STEP_WAIT            	1          		// CAN初始化等待
#define CAN_INIT_STEP_ING            	2          		// CAN初始化中
#define CAN_INIT_STEP_SUCCESS        	100          	// CAN初始化成功


#define CAN_MODE_NONE					0
#define CAN_MODE_CANID					1
#define CAN_MODE_DATA					2


typedef struct
{
	Uint16 channel:4;
	Uint16 COB_ID:12;//3	
}CAN_FILTER_BITS;

typedef union
{
	Uint16   			all;
    CAN_FILTER_BITS		bit;
}CAN_FILTER;

typedef struct
{
    Uint32 id;
    Uint16 rtr;
    Uint16 lenth;
    Uint8 data[8];
}CAN_MSG_STRU;

struct RPDO_STATE
{
	Uint8 rpdo1:1;
	Uint8 rpdo2:1;
	Uint8 rpdo3:1;
	Uint8 rsvd:5;
};




typedef struct
{
    Uint8  count;
    Uint32 cobId;
    Uint8  type;
    Uint16 inhibitTime;
}CAN_RPDO_STRU;



typedef struct
{
    Uint8 count;
    Uint32 object[8];
}CAN_PDO_MAPPING_STRU;

typedef struct
{
    Uint8  count;
    Uint32 cob_id_client;                                   //  client->server
    Uint32 cob_id_server;
}CAN_SDO_STRU;

typedef struct
{
	Uint16 Status;
	Uint16 InitOk;
}CAN_STATE;

typedef struct
{
	Uint16 BauteRate;
	Uint16 NodeID;
	int16 InitCmd;
}CAN_PARAM;


#define MASK_ALL                    0x7FF
#define MASK_TYPE                   0x780
#define MASK_ADDR                   0x07F


extern CAN_STATE CanState;
extern CAN_PARAM CanParam;

extern Uint16 SystemStatus;



extern void CanMainProcess(void);


#endif // __F_CAN_APP_H__



