#ifndef _CAN_XHY_H_
#define _CAN_XHY_H_


#include "mc9s12xhy256.h"


#define CANMsg_Export_100_CYCLE 49//100 //100MS   //49*2.048    =100.352

typedef unsigned char INT8U;
typedef unsigned int INT16U;
typedef unsigned long INT32U;
//CAN���÷���ʱ���ص�״̬ö��
typedef enum
{
   CAN_Set_Complete = 0,
   CAN_Set_ERROR_BUSOFF,
   CAN_Set_ERROR_OverMaxLen,
   CAN_Set_ERROR_OverFlow,

} _CAN_SetState;

typedef struct
{
	INT8U BUFF[8];
	INT8U Len;
	INT32U SendID; //����/����ID
} _CAN_TX_BUF_TYPE;


//////////////////////�̶�����///////////////////////////////////////////////////////////

////////////////////////��������/////////////////////////////////////////////////////////
//CAN0��ʼ��
extern void MSCAN0_Init(void);
//CAN0����,�ж��е���
extern void CAN0_TX_DATA_BUF(void);
//CAN0  buf �д����͵���������
extern void CAN0_TX_BUF_Clear(void);
//���÷�������
extern _CAN_SetState CAN0_TX_BUF_Set(INT8U *pdata, INT32U ID, INT8U Len);
//��ȡ��ǰ�Ƿ�BUSOFF    //1�Ѿ�busoff��//0 û��
extern unsigned char GetBusOffState(void);
//CAN0 ���з���ȡ��
extern void AbortAllCan0Tx(void);
//CAN0����͹���ģʽ
extern void MSCAN0_Enter_Low_Power_Mode(void);
//CAN0�˳��͹���ģʽ
extern void MSCAN0_Exit_Low_Power_Mode(void);


//��ȡCAN0 ��׼֡ID
extern INT16U MSCAN0_GET_Stand_ID(void);
//��ȡCAN0 ��չ֡ID
extern INT32U MSCAN0_GET_Extended_ID(void);
//��ȡCAN0 ��չ֡PNG
extern INT32U MSCAN0_GET_Extended_PNG(INT32U ID);
extern INT8U MSCAN0_Get_Wake_Up_Flag(void);
extern INT8U MSCAN0_Is_Exist_Frame(void);
extern INT8U MSCAN0_Set_Exist_Frame(void);

////////////////�ⲿ�ӿ��ṩ////////////////////////////////////////////////////////////////////////////////////////////////////////
extern void MSCAN0_TJA1042_STB_SET(INT8U ON_OFF);
extern INT8U MSCAN0_TJA1042_STB_GET(void);
////////////////////////////////////////////////////////////////////////////////////////

//extern void CAN_APP_TX_Time_Reset(void);
//extern void CAN_Tx_Service(void);
void NM_D_BusOff_Recover(void);
//extern void CAN_TX_Data_K30_Init(void );  
extern void BusoffRecover(void);



#endif