#ifndef TP_CONFIG_H #define TP_CONFIG_H #include #include #include #include "uds_config.h" #include "uds_did.h" #include "uds_dtc.h" #include "uds_can_interface.h" #include "diagnosis_mid.h" #include "tp_15765_2.h" #include "tp_config.h" #include "uds_interface.h" #include "uds_manage.h" #include "uds_services.h" #include "uds_types.h" /*! * @file tp_config.h * @brief TP layer file according to the 15765-2. * */ #include "uds_types.h" // lbin_20190117 #define CALL_RATE_TP 1 /*!< Call rate of the periodic task */ #define N_As_TIME_OUT 70 /*!< default value : max as per standard = 1000msec */ #define N_Ar_TIME_OUT 70 /*!< default value : max as per standard = 1000msec */ #define N_Bs_TIME_OUT 150 /*!< default value : max as per standard = 1000msec */ #define N_Cr_TIME_OUT 150 /*!< default value : max as per standard = 1000msec */ #define N_As_TIMER_COUNT N_As_TIME_OUT/CALL_RATE_TP /*!< As TIMER COUNT*/ #define N_Ar_TIMER_COUNT N_Ar_TIME_OUT/CALL_RATE_TP /*!< Ar TIMER COUNT */ #define N_Bs_TIMER_COUNT N_Bs_TIME_OUT/CALL_RATE_TP /*!< Bs TIMER COUNT */ #define N_Cr_TIMER_COUNT N_Cr_TIME_OUT/CALL_RATE_TP /*!< Cr TIMER COUNT */ #if (BOOTLOADER_CODE_FLAG == 0) #define TP_RX_BLOCK_SIZE_MAX 0 /*!< default block size for receive. */ #define TP_RX_SEPARATION_TIME_MIN 0 /*!< default STmin for receive. lbin */ #else #define TP_RX_BLOCK_SIZE_MAX 0 /*!< default block size for receive. */ #define TP_RX_SEPARATION_TIME_MIN 0 /*!< default STmin for receive. lbin */ #endif #define TP_BUFFER_SIZE 2050//255 /*!< TP buffer(common for both Rx & RX) size */ #define FRAME_DATA_SIZE 8 /*!< Frame buffer size */ /*! * Macro. Wait frame Transmit support: if 0 no wait frame tx supported * otherwise configure max wait frame tx count */ #define N_WAIT_FRAME_TX_MAX 0 /*! * Macro. If the Padding is required select as 'TRUE'. Otherwise 'FALSE' */ #define PADDING_OPERATION true /*! * Macro. Default selected as -xaa; change it to required value */ #define PADDING_BYTE 0x00 /* maximum dlc value for one CAN frame */ /* #define RX_MULTI_BUFFER_SUPPORT */ #define STmin_ZERO CALL_RATE_TP #define TP_DIAG_PHYSICAL_MSG_SUPPORT #define TP_DIAG_FUNCTIONAL_MSG_SUPPORT /*! * Macro. Max number of bytes */ #define NW_DLC_MAX_BYTES 8 /*! * Macro. number of bytes to represent N_PCI in a sinlge frame */ #define SINGLE_FRAME_N_PCI_BYTE 1 /*! * Macro. maximum number of data bytes in a single frame */ #define MAXIMUM_SINGLE_FRAME_DATA_BYTE 7 /*! * Macro. Two N_PCI + six data bytes in a first frame */ #define FIRST_FRAME_N_PCI_PLUS_DATA_BYTE 8 /*! * Macro. maximum number of data bytes in a consecutive frame */ #define CONSECUTIVE_FRAME_N_PCI_BYTE 1 /*! * Macro. data bytes in a consecutive frame */ #define CONSECUTIVE_FRAME_DATA_BYTE 7 /*! * Macro. One N_PCI + seven data bytes in a consecutive frame */ #define CONSECUTIVE_FRAME_N_PCI_PLUS_DATA_BYTE 8 /*! * Macro. Three N_PCI bytes in a flow control frame */ #define FLOW_CONTROL_N_PCI_PLUS_DATA_BYTE 3 /*! * Enum Type. PCI Type */ typedef enum TPN_PCI_Type_Tag { SINGLE_FRAME = 0x00, /*!< N_PCI type for single frame */ FIRST_FRAME = 0x10, /*!< N_PCI type for first frame */ CONSECUTIVE_FRAME = 0x20, /*!< N_PCI type for consecutive frame */ FLOW_CONTROL_FRAME = 0x30 /*!< N_PCI type for flow control frame */ }TPN_PCI_Type_T; /*! * Enum Type. TP Request Tpye */ typedef enum TPRequestTpye_Tag { PHYSICAL_ADDRESS_TYPE = 0, /*!< PHYSICAL ADDRESS TYPE */ FUNCTIONAL_ADDRESS_TYPE /*!< FUNCTIONAL ADDRESS TYPE */ }TPRequestTpye_T; /*! * Enum Type. TP Result Tpye */ typedef enum TPResult_Tag { N_OK = 0, /*!< Result OK */ N_TIMEOUT_A, /*!< Timeout A */ N_TIMEOUTBs, /*!< Timeout Bs */ N_TIMEOUTCr, /*!< Timeout Cr */ N_WRONG_SN, /*!< Wrong SN */ N_INVALID_FS, /*!< Invaild FS */ N_UNEXP_PDU, /*!< Unexpected PDU */ N_WFT_OVRN, /*!< WFT Overrun */ N_BUFFER_OVFLW, /*!< Buffer Overflow */ N_WRONG_DLC, /*!< Wrong DLC */ N_ERROR, /*!< ERROR */ TP_BUFFER_OVER_FLOW, /*!< TP Buffer Overflow */ TP_BUFFER_NOT_FILLED, /*!< TP BUFFER not filled */ TP_RX_LENGTH_INVALID /*!< TP Invalid RX Length */ } TPResult_T; extern bool TpRxFlg; extern uint16_t TP_Rx_Message_Length; /*!< Receive Message Length */ extern uint16_t TP_Rx_Index; extern uint8_t TP_Buffer[TP_BUFFER_SIZE]; /*!< TP Buffer */ extern void TP_Init( void ); extern void TP_Periodic_Task( void ); extern void TP_Transmit_Buffer_Filled(void); extern void TP_Receive_Buffer_Read(void); extern uint16_t TP_Get_Message_Buffer_Size(void); extern uint8_t * TP_Get_Message_Buffer_Pointer(void); extern uint8_t TP_Get_Request_Type(void); extern void TP_N_USData_Request(uint16_t TPTransmitMessageLength); extern void TP_N_Change_Parameters_Request(uint8_t Parameter, uint16_t ParameterValue); uint8_t *TP_Get_Tx_Message_Buffer_Pointer (void); extern void TP_D_UUData_Confirm(void); extern void TP_D_UUData_Indication_Physical(void); extern void TP_D_UUData_Indication_Functional(void); #define UCB_TP_Transmit_Buffer_Empty HAL_UDS_Transmit_Buffer_Empty #ifdef RX_MULTI_BUFFER_SUPPORT #define UCB_TP_Receive_Buffer_Filled DG_TP_Receive_Buffer_Filled #endif #define UCB_TP_N_USData_Confirm HAL_UDS_Response_Confirm #define UCB_TP_N_USData_FF_Indication HAL_UDS_FF_Indication #define UCB_TP_N_USData_Indication HAL_UDS_Indication #define UCB_TP_N_Change_Parameter_Confirm HAL_UDS_Change_Parameter_Confirm #define UCB_TP_N_USData_FF_Confirmation HAL_UDS_FF_Confirmation extern void UCB_TP_Transmit_Buffer_Empty(void); #ifdef RX_MULTI_BUFFER_SUPPORT extern void UCB_TP_Receive_Buffer_Filled(void); #endif extern void UCB_TP_N_USData_Confirm(uint8_t N_Result); extern void UCB_TP_N_USData_FF_Indication(uint16_t TPReceivexMessageLength); extern void UCB_TP_N_USData_Indication(uint16_t TPReceivexMessageLength, uint8_t N_Result); extern void UCB_TP_N_Change_Parameter_Confirm(uint8_t Parameter, uint8_t ParameterChangeResult); extern void UCB_TP_N_USData_FF_Confirmation(void); void TP_Task(void); #endif /*============================================================================*/ /* CAN : Controller Area Network */ /* DLC : Data Length Code (number of data bytes in a CAN message) */ /* ID : Identifier */ /* BS : Block Size */ /* CF : Consecutive frame */ /* confirm : Confirmation service primitive */ /* ECU : Electronic Control Unit - generic term for any electronic control */ /* unit */ /* FC : Flow Control */ /* FF : First frame */ /* FF_DL : First frame data length */ /* FS : Flow Status */ /*indication : Indication service primitive */ /* Mtype : Message Type */ /*N : Network */ /* N_AE : Network Address Extension */ /* N_AI : Address Information */ /* N_Ar : Network layer timing parameter Ar */ /* N_As : Network layer timing parameter As */ /* N_Br : Network layer timing parameter Br */ /* N_Bs : Network layer timing parameter Bs */ /* N_ChangeParameter : Network layer service name */ /* N_Cr : Network layer timing parameter Cr */ /* N_Cs : Network layer timing parameter Cs */ /* N_Data : Network Data */ /* N_PCI : Network Protocol Control Information */ /* N_PCItype : Network Protocol Control Information Type */ /* N_PDU : Network Protocol Data Unit */ /* N_USData : Network layer Unacknowledged Segmented Data transfer service */ /* name */ /* NWL : Network Layer */ /* request : Request service primitive */ /* SF : Single frame */ /* SF_DL : Single frame data length */ /* SN : Sequence Number */ /* STmin : Separation Time min. */ /* N_As : Time for transmission of the CAN frame(anu N_PDU) on the sender side*/ /* N_Ar : Time for transmission of the CAN frame(anu N_PDU) on the receiver */ /*side */ /* N_Bs : Time until reception of the next flow control N_PDU */ /* N_Cr : Time until reception of the next consecutive frame N_PDU */ /*============================================================================*/