#ifdef GLOBALS_TP_DIAGNO
#define EXTERN_TP_DIAGNO
#else
#define EXTERN_TP_DIAGNO extern
#endif

#ifndef _TP_DIAGNO_H_
#define _TP_DIAGNO_H_

#include "uds_includes.h"

#define SingleFrame 0x00
#define FirstFrame 0x10
#define ConsecutiveFrame 0x20
#define FlowControlFrame 0x30
#define FC_WAIT 0x31

typedef struct
{
    uint32_t id;
    uint8_t msg[8];
    uint8_t dlc;
} _SendCanMsg;
EXTERN_TP_DIAGNO volatile _SendCanMsg g_txCanMsg;

extern volatile _N_USData N_US_R_MultiData;
extern volatile _N_USData N_US_S_MultiData;
extern volatile _N_RSPData N_RSPData;
extern volatile _N_US_Data_FF N_US_R_Data_FF;
extern volatile _N_US_Data_FF N_US_S_Data_FF;
extern volatile _N_USSFData N_USSFData[2];
extern volatile uint16_t N_RecLen;

EXTERN_TP_DIAGNO uint8_t TP_CalMsgLen(uint16_t BIT_DATA, uint8_t SnLoop);
EXTERN_TP_DIAGNO void TP_AbnormalInResSF_handle(void);
EXTERN_TP_DIAGNO void TP_AbnormalInResFC_handle(void);
EXTERN_TP_DIAGNO void TP_AbnormalInResCF_handle(void);
EXTERN_TP_DIAGNO void TP_AbnormalInReqFC_handle(void);
EXTERN_TP_DIAGNO void TP_NormalRecFC_handle(void);
EXTERN_TP_DIAGNO void TP_Buffer_handle(void);
EXTERN_TP_DIAGNO void TP_UnknownlPDU_handle(void);
EXTERN_TP_DIAGNO void TP_ReciveSF_handle(void);
EXTERN_TP_DIAGNO void TP_ReciveMultiF_handle(void);
EXTERN_TP_DIAGNO void TP_AbnormalInReqFF_handle(void);
EXTERN_TP_DIAGNO void TP_NormalSendFC_Fun(void);
EXTERN_TP_DIAGNO void TP_TooShortDLC_handle(_LinkData *LK_Data);
EXTERN_TP_DIAGNO void TP_TransmitPDU(void);
EXTERN_TP_DIAGNO void TP_TransmitNegatePDU(_ErrorFrame *Err);

EXTERN_TP_DIAGNO void TP_SetSTminTimer(uint32_t Second, _DiagClock *T);
EXTERN_TP_DIAGNO uint8_t TP_STminTimerOver(_DiagClock *T);

EXTERN_TP_DIAGNO void TP_SetBsTimer(uint32_t Second, _DiagClock *T);
EXTERN_TP_DIAGNO uint8_t TP_BsTimerOver(_DiagClock *T);

EXTERN_TP_DIAGNO void TP_SetCrTimer(uint32_t Second, _DiagClock *T);
EXTERN_TP_DIAGNO uint8_t TP_CrTimerOver(_DiagClock *T);

#endif /* _TP_DIAGNO_H_ */
