#if !defined(CANIF_CFG_H)
#define CANIF_CFG_H

/***包含头文件***/
#include "ComTypes.h"
/*#include "Com.h"
#include "CanTP.h"
#include "CanNM.h"
#include "mcu.h"*/

/*----------------------------------------------------------------------------------

                                    模块配置项开始

-----------------------------------------------------------------------------------*/
#define CANIF_MAINFUCTION_CALL_CYCLE   10u  /*ms*/
#define CAN_BUS_WAKE_MASK              0x01u
#define CAN_LOCAL_WAKE_MASK            0x02u

#define CANIF_CFG_MAX_RX_HANDLE        (CanIf_PduIdType)2
#define CANIF_CFG_MAX_TX_HANDLE        (CanIf_PduIdType)1
#define CANIF_CFG_MAX_CONTROLLER       (CanIf_PduIdType)1

#define CANIF_CFG_NM_TX_HANDLE_INDEX   (CANIF_CFG_MAX_TX_HANDLE - 2)
#define CANIF_CFG_DIAG_TX_HANDLE_INDEX (CANIF_CFG_MAX_TX_HANDLE - 1)

extern void DisableCanIf_Interrupt(void);
extern void EnableCanIf_Interrupt(void);
#define CanIf_EnterCritical() DisableCanIf_Interrupt()      
#define CanIf_LeaveCritical() EnableCanIf_Interrupt()
/*----------------------------------------------------------------------------------

                                    模块配置项结束

-----------------------------------------------------------------------------------*/
/*****************************************************/
/***CanIf模块类据类型***/
typedef unsigned char CanIf_WakeUpSourceType;   /*at most,support 8 wakeupsources*/
typedef unsigned char CanIf_PduIdType;
typedef unsigned char CanIf_HwHandleType;
typedef unsigned char CanIf_CanDlcType;
typedef unsigned char CanIf_CanDataType;
typedef unsigned int  CanIf_CanIdType;
typedef unsigned char CanIf_uint8Type;
typedef unsigned int  CanIf_CanTxCycleType;

typedef void (*CanIf_RxIndicationType)(CanIf_HwHandleType LeCanIf_e_Hrh, CanIf_CanIdType LeCanIf_e_CanId, CanIf_CanDlcType LeCanIf_e_CanDlc, CanIf_CanDataType* LeCanIf_e_CanSduPtr);
typedef void (*CanIf_RxErrorType)(CanIf_HwHandleType LeCanIf_e_Hrh, CanIf_CanIdType LeCanIf_e_CanId, CanIf_CanDlcType LeCanIf_e_CanDlc, CanIf_CanDataType* LeCanIf_e_CanSduPtr);
typedef void (*CanIf_TxConfirmationType)(CanIf_HwHandleType LeCanIf_e_Hrh, CanIf_CanIdType LeCanIf_e_CanId);
typedef void (*CanIf_TxErrorType)(CanIf_HwHandleType LeCanIf_e_Hrh, CanIf_CanIdType LeCanIf_e_CanId);

typedef enum 
{
    CANIF_ERROR_ACTIVE = 0,
    CANIF_ERROR_PASSIVE,
    CANIF_ERROR_BUSOFF
     
}CanIf_ControllerErrorType;

typedef enum 
{
    CANIF_CS_NORMAL = 0u,
    CANIF_CS_STOP
        
}CanIf_ControllerModeType;

typedef enum
{
    TX_MODE_NONE = 0u,
    TX_MODE_PERIODIC,
    TX_MODE_MIXED,
    TX_MODE_EVENT	
	
}CanIf_CanBoxTxModeType;

typedef enum
{
    SIGNAL_FILTER_NONE = 0u,
    SIGNAL_FILTER_ALWAYS	
	
}CanIf_CanSignalFilterModeType;

typedef struct
{                      
    CanIf_CanIdType                  eTxCanId;                  /*  */
    CanIf_CanDlcType                 eTxCanDlc;                 /*  */             
    CanIf_HwHandleType               eControllerID;             /* Number of Controllers */
    ComUint16                        eCanTxCycleOffset;
    CanIf_CanSignalFilterModeType    eSignalFilterMode;
    CanIf_CanBoxTxModeType           eCanTxMode;                /* Tx Mode */
    CanIf_uint8Type                  eEventCnt;
    CanIf_uint8Type                  eEventCycle;
    CanIf_CanTxCycleType             eCanTxCycle;               /* Tx Cycle*/
    CanIf_TxConfirmationType         eCanIf_TxConfirmationFct;  /* TxConfirmation Fct */  
    CanIf_TxErrorType                eCanIf_TxErrorFct;         /* TxError Fct */  
    CanIf_uint8Type                  eQueuedIndex;                   
                                 
}CanIf_CanTxConfigTabeType;
extern const CanIf_CanTxConfigTabeType SeCanIf_t_CanTxConfigTabe[CANIF_CFG_MAX_TX_HANDLE];
#define CANIF_CFG_CANTX_TABLE(index,field)  (SeCanIf_t_CanTxConfigTabe[(index)].field)

typedef struct
{                     
    CanIf_CanIdType         eRxCanId;      /* Number of Rx PDUs */
    CanIf_CanDlcType        eRxCanDlc;     /* Number of Tx PDUs */             
    CanIf_HwHandleType      eControllerID; /* Number of Controllers */
    CanIf_RxIndicationType  eCanIf_RxIndicationFct;/* Indication Fct */  
    CanIf_RxErrorType       eCanIf_RxErrorFct;/* Indication Fct */                     
                                 
}CanIf_CanRxConfigTabeType;
extern const CanIf_CanRxConfigTabeType SeCanIf_t_CanRxConfigTabe[CANIF_CFG_MAX_RX_HANDLE];
#define CANIF_CFG_CANRX_TABLE(index,field)  (SeCanIf_t_CanRxConfigTabe[(index)].field)

typedef struct
{
	CanIf_CanIdType   eCanIf_CanId;
	CanIf_CanDlcType  eCanIf_CanDlc;
	CanIf_uint8Type   eCanIf_Txdata[8];
	CanIf_uint8Type   eQueued;

}CanIf_TxQueueType;

typedef struct
{                     
    CanIf_PduIdType       eMaxRxPDUHandle;    /* Number of Rx PDUs */
    CanIf_PduIdType       eMaxTxPDUHandle;    /* Number of Tx PDUs */             
    CanIf_uint8Type       eMaxController;     /* Number of Controllers */
                                  
}CanIf_ConfigType;
extern const CanIf_ConfigType SeCanIf_t_Config;
#define CANIF_CFG_GENERIC(eMaxRxPDUHandle)  (SeCanIf_t_Config.eMaxRxPDUHandle)

/*****************************************************/

#endif /* CANIF_CFG_H */





















