#ifndef _ISO15765_3_CFG_H_
#define _ISO15765_3_CFG_H_

// TODO XXX FIXME: this should probably go to ISO15765_3.H
//#include "Timer.h"
//#include "ProjectCfg.h"
#include "DiagnosticR/UDS/UDS_CoreServices_CB.h"
/* ISO15765_3 VARIANTS */
/* Pure UDS Standard */
#define ISO15765_3_UDS          (0x00)
/* RSA Variant*/
#define ISO15765_3_RSA          (0x01)
/* Fiat customizations */
#define ISO15765_3_FIAT         (0x02)
#define ISO15765_3_GAC			(0x03)
#define ISO15765_3_VARIANT  (ISO15765_3_UDS)

/* ISO15765_3 MODE */
#define ISO15765_3_APP  (0x00)
#define ISO15765_3_BL   (0x01) 
#define ISO_3_MODE      (ISO15765_3_APP)



/* FICOSA_SYSTEM_SUPPLIER_SESSION */
/* 0x60 - 0x7E systemSupplierSpecific: this range of values is reserved for system-supplier-specific use.*/
/* ISO 14229-1:2006(E) pag 39 */
#define UDS_SYSTEM_SUPPLIER_SPECIFIC_SESSION_ID ((UI_8)0x60)

/* Size of the buffer that must store the largest frame for the 		*/
/* diagnostic server instance (ISO15765_3)								*/
/* The size of the buffer must be declared using the macro 				*/
/* SIZE_ALLOC_BUFFER to assure that no overflows will happen during     */
/* transmission or reception of frames larger than single frames        */
/* Defined Candela A68_GSM_Ficosa.75.cdd -> ECU Information -> Supported Interfaces -> Diagnose CAN */
#define TP_DIAG_FUN_RX_BUFFER   ((UI_16)(8))
#define TP_DIAG_RX_BUFFER       ((UI_16)(4096))
#define TP_DIAG_TX_BUFFER       ((UI_16)(4096))
#define TP_DIAG_FUN_RX_LEN      (SIZE_ALLOC_BUFFER(TP_DIAG_FUN_RX_BUFFER))
#define TP_DIAG_RX_LEN          (SIZE_ALLOC_BUFFER(TP_DIAG_RX_BUFFER))
#define TP_DIAG_TX_LEN          (SIZE_ALLOC_BUFFER(TP_DIAG_TX_BUFFER))

/*
 * ISO15765_3_MIN_ADDRESS_LENGTH_MULTIDEVICE:
 *      Addresses with less bytes will be considered directed to DEVICE_0.
 */
#define ISO15765_3_MIN_ADDRESS_LENGTH_MULTIDEVICE       ((UI_8)4)

/* Used ISO15765_2 stack in order to send and receive */
/* the diagnostics */
#define DIAG_ISO15765_2_HDL     (ISO15765_2_REPROGONCAN_HANDLER)

/*****************************************************************************/
/* TIMING																	 */
/*****************************************************************************/
/* Max time allowed to answer a request. In milliseconds					 */
#define P2_MAX		((UI_16)50)
/* Max time between a UDS_ERR_RESPONSE_PENDING and the next answer. In ms	 */
#define P2_EXT_MAX	((UI_16)200)
/* Max counter between a UDS_ERR_RESPONSE_PENDING and the next answer. 	 */
#define P2_EXT_MAX_COUNTER	((UI_16)150)
/* Session Expiration Timeout. In ms										 */
#define S3_MAX		((UI_16)5000)

/*****************************************************************************/
/* DATA TYPES																 */
/*****************************************************************************/
/* Specify the Download Addresses size:										 */
/*   Possible values: ISO3_16BIT_ADDRESS, ISO3_32BIT_ADDRESS				 */
#define DOWNLOAD_ADDRESS_SIZE	(ISO3_32BIT_ADDRESS)

/*****************************************************************************/
/* UDS SERVICES 															 */
/*****************************************************************************/
/* SECURITY ACCESS ENABLED/DISABLED */
#define SERVICE_DISABLED (0x00)
#define SERVICE_ENABLED  (0x01)

#define LIN_ASSIGN_FRAME_IDENTIFIER_STATUS				(SERVICE_DISABLED) 
#define LIN_ASSIGN_FRAME_IDENTIFIER_RANGE_STATUS		(SERVICE_DISABLED) /*NOT IMPLEMENTED YET */
#define LIN_READ_BY_IDENTIFIER_STATUS					(SERVICE_DISABLED)
#define LIN_ASSIGN_NAD_STATUS							(SERVICE_DISABLED) /*NOT IMPLEMENTED YET */
#define LIN_CONDITIONAL_CHANGE_NAD_STATUS				(SERVICE_DISABLED) /*NOT IMPLEMENTED YET */

#define UDS_SERVICE_SESSION_CONTROL_STATUS              (SERVICE_ENABLED)
#define UDS_SERVICE_ECU_RESET_STATUS                    (SERVICE_ENABLED)
#define UDS_SERVICE_SECURITY_ACCESS_STATUS              (SERVICE_ENABLED)
#define UDS_SERVICE_TESTER_PRESENT_STATUS               (SERVICE_ENABLED)
#define UDS_SERVICE_CONTROL_DTC_SETTING_STATUS          (SERVICE_ENABLED)
#define UDS_SERVICE_READ_DATA_BY_IDENTIFIER_STATUS      (SERVICE_ENABLED)
#define UDS_SERVICE_READ_MEMORY_BY_ADDRESS_STATUS       (SERVICE_DISABLED)//NOT IMPLEMENTED YET
#define UDS_SERVICE_WRITE_DATA_BY_IDENTIFIER_STATUS     (SERVICE_ENABLED)
#define UDS_SERVICE_WRITE_MEMORY_BY_ADDRESS_STATUS      (SERVICE_DISABLED)//NOT IMPLEMENTED YET
#define UDS_SERVICE_CLEAR_DIAGNOSTIC_INFORMATION_STATUS (SERVICE_ENABLED)
#define UDS_SERVICE_READ_DTC_INFORMATION_STATUS         (SERVICE_ENABLED)
#define UDS_SERVICE_IO_CTRL_BY_ID_STATUS                (SERVICE_ENABLED)
#define UDS_SERVICE_ROUTINE_CONTROL_STATUS              (SERVICE_ENABLED)
#define UDS_SERVICE_REQUEST_DOWNLOAD_STATUS             (SERVICE_DISABLED)
#define UDS_SERVICE_TRANSFER_DATA_STATUS                (SERVICE_DISABLED)
#define UDS_SERVICE_REQUEST_TRANSFER_EXIT_STATUS        (SERVICE_DISABLED)
#define UDS_SERVICE_COMMUNICATION_CONTROL_STATUS        (SERVICE_ENABLED)

#if (LIN_ASSIGN_FRAME_IDENTIFIER_STATUS == SERVICE_ENABLED)
/*****************************************************************************
 * ASSIGN FRAME IDENTIFIER		(0xB7)									     
 *****************************************************************************
 * This service IS ONLY VALID in LIN version 2.0
 * CALLBACKS:																 
 *    LIN_ASSIGN_FRAME_IDENTIFIER_CALLBACK(UI_8 supplierID_LSB, UI_8 supplierID_MSB, UI_8 messageID_LSB, UI_8 messageID_MSB, UI_8 new_pid):
 *    'supplierID' defines the product vendor identifier.
 *	  'messageID' defines the message identifier as in <Configurable frames> section in Lin Description File.
 *    'new_pid' defines the new pid to identify the frame with the selected messageID.
 *    A response shall be sent if the assignation is successful.
 ****************************************************************************/ 
#define LIN_SERVICE_ASSIGN_FRAME_IDENTIFIER   (UDS_DEFAULT_SESSION_MASK)
#define LIN_ASSIGN_FRAME_IDENTIFIER_CALLBACK 	(LinAssignFrameId)
#endif

#if (LIN_ASSIGN_FRAME_IDENTIFIER_RANGE_STATUS == SERVICE_ENABLED)
/*****************************************************************************
 * ASSIGN FRAME IDENTIFIER RANGE	(0xB7)									     
 *****************************************************************************
 * This service IS MANDATORY in all three LIN diagnostics classes
 * (See 4.2.5.5 on LIN Spec 2.2)
 * CALLBACKS:																 
 *    LIN_ASSIGN_FRAME_IDENTIFIER_RANGE_CALLBACK(UI_8 index, const UI_8* new_pid_list):
 *    'index' defines the protected identifier (pid) start from the pid list available.
 *	  'new_pid_lis' defines a buffer where are specified the four new pids for change
 *        counting from index.
 *  	  - 0x00: Disable service.
 * 		  - 0xFF: Do not change PID.
 *        - 0xXX: Change pid.
 *    The system shall only response if NAD matched.
 ****************************************************************************/ 
#define LIN_SERVICE_ASSIGN_FRAME_IDENTIFIER_RANGE   (UDS_DEFAULT_SESSION_MASK)
#define LIN_ASSIGN_FRAME_IDENTIFIER_RANGE_CALLBACK 	(LinAssignFrameIdRange)
#endif


#if (LIN_READ_BY_IDENTIFIER_STATUS == SERVICE_ENABLED)
/*****************************************************************************
 * READ BY IDENTIFIER	(0xB2)									     
 *****************************************************************************
 * This service IS MANDATORY in all three LIN diagnostics classes for ID = 0x00
 * The rest of identifier are optional.
 * (See 4.2.6.1 on LIN Spec 2.2)
 * CALLBACKS:																 
 *    LIN_READ_BY_IDENTIFIER_CALLBACK(UI_8 id):
 *    'id' defines the identifier requested.
 *  	  - 0x00: LIN Product identification: SupplierID, FunctionID & Variant.
 * 		  - 0x01: Serial Number.
 *        - 0x32-0x63: User defined.
 *		  - The rest of identifiers are reserved.
 *    The system shall accordingly to each request. (See 4.2.6.1 on LIN Spec 2.2)
 ****************************************************************************/ 
#define LIN_SERVICE_READ_BY_IDENTIFIER			    (UDS_DEFAULT_SESSION_MASK)
#define LIN_READ_BY_IDENTIFIER_CALLBACK				(LinReadByID)
#endif 


#if (LIN_ASSIGN_NAD_STATUS == SERVICE_ENABLED)
/*****************************************************************************
 * LIN ASSIGN NAD	(0xB0)									     
 *****************************************************************************
 * This service CAN be enabled/disabled	
 * (See 4.2.5.1 on LIN Spec 2.2)
 * CALLBACKS:																 
 *    LIN_ASSIGN_NAD_CALLBACK(UI_16 supplierId, UI_16 functionId, UI_8 new_nad):
 *       - 'supplierId' and 'functionId' must be the same as defined in the system, 
 *    	   otherwise the NAD won't be assigned.
 *       - 'new_nad' is the new NAD to be assigned
 *	 The system shall response with the initial NAD to confirm the change.
 ****************************************************************************/ 
#define LIN_SERVICE_ASSIGN_NAD			    (UDS_DEFAULT_SESSION_MASK)
#define LIN_ASSIGN_NAD_CALLBACK				(LinAssignNAD)
#endif 


#if (LIN_CONDITIONAL_CHANGE_NAD_STATUS == SERVICE_ENABLED)
/*****************************************************************************
 * LIN CONDITIONAL CHANGE NAD	(0xB3)									     
 *****************************************************************************
 * This service CAN be enabled/disabled	
 * (See 4.2.5.2 on LIN Spec 2.2)
 * CALLBACKS:																 
 *    LIN_CONDITIONAL_CHANGE_NAD_CALLBACK(UI_8 id, UI_8 byte, UI_8 mask, UI_8 invert, UI_8 new_nad):
 *       1. 'id' Get the identifier specified by the function LinReadByID.
 * 		 2. Extract the data byte selected by Byte (Byte = 1 corresponds to the first byte, D1).
 * 		 3. Do a bitwise XOR with Invert.
 *		 4. Do a bitwise AND with Mask.
 * 		 5. If the final result is zero then change the NAD to New NAD.
 *	 The system shall response with the new NAD to confirm the change.
 ****************************************************************************/ 
#define LIN_SERVICE_CONDITIONAL_CHANGE_NAD			    (UDS_DEFAULT_SESSION_MASK)
#define LIN_CONDITIONAL_CHANGE_NAD_CALLBACK				(LinConditionalChangeNAD)
#endif 


#if (UDS_SERVICE_SESSION_CONTROL_STATUS == SERVICE_ENABLED)
/*****************************************************************************
 * DIAGNOSTICS SESSION CONTROL	(0x10)									     
 *****************************************************************************
 * This service CAN be enabled/disabled								     
 * CALLBACKS:																 
 * .- UDS_INI_SESSION_CALLBACK: The user MAY implement this callback.	     
 *	  Called when layer 3 changes session	
 * DEFINES:
 * .- UDS_USER_DEFINED_SESSION. Valid User Defined Session ID
 ****************************************************************************/ 
#define UDS_SERVICE_SESSION_CONTROL (UDS_ALL_SESSION_MASK)
//TODO: Check allowed session
//#define UDS_USER_DEFINED_SESSION (UDS_DEFAULT_SESSION)
#define UDS_USER_DEFINED_SESSION (UDS_SYSTEM_SUPPLIER_SPECIFIC_SESSION_ID)

#define UDS_INI_SESSION_CALLBACK (UdsIniSession)

#endif

#if (UDS_SERVICE_ECU_RESET_STATUS == SERVICE_ENABLED)
/****************************************************************************
 * ECU RESET (0x11)									     				     
 ****************************************************************************
 * This service CAN be enabled/disabled								     	 
 * CALLBACKS:																 
 *   BOOL CHECK_RESET_POSSIBLE(UI_8 reset_type): 
 * 		Asks the user if this reset type is allowed at this point in time. 
 *      Return TRUE if yes	     
 *   void EXECUTE_RESET(UI_8 reset_type): 
 * 		Execute the reset type requested
 ****************************************************************************/ 
#define UDS_SERVICE_ECU_RESET   (UDS_DEFAULT_SESSION_MASK | UDS_EXT_DIAG_SESSION_MASK | UDS_PROGRAMMING_SESSION_MASK | UDS_SYSTEM_SUPPLIER_SPECIFIC_SESSION_MASK)
#define CHECK_RESET_POSSIBLE	(UdsCheckResetIsPossible)
#define EXECUTE_RESET			(UdsExecuteResetNow)

#endif

#if (UDS_SERVICE_SECURITY_ACCESS_STATUS == SERVICE_ENABLED)
/*****************************************************************************
 * SECURITY ACCESS(0x27)							     				     
 ****************************************************************************
 * This service can be enabled/disabled								     	 
 * CALLBACKS:		
 *   void UDS_SECURITY_REQUEST_SEED_CALLBACK(UI_8* p_local_seed):
 * 	   Generate a Random Seed and place it in p_local_seed (4 bytes)
 *   BOOL UDS_SECURITY_CHECK_KEY_CALLBACK(UI_8* p_local_seed, UI_8* p_tool_key):
 *     Check the key returned by the tool. Return TRUE is ok
 * DEFINES
 *     UDS_SERVICE_SECURITY_ACCESS: set the session which accepts this service.
 *     SECURITY_INIT_DELAY: Set to SECURITY_DELAY, to introduce 10 secs
 *     delay after Reset, before accepting security resets. Set to
 *     SECURITY_NO_DELAY if no delay is wanted.
 *	   MAX_SECURITY_ATTEMPTS: Number of failed attempts before starting the penalty
 *	   SECURITY_PENALTY_TIME: Time to wait before next attempt. 
 *     SECURITY_SEED_SIZE: Number of bytes of the security seed (max = 4)
 *     SECURITY_KEY_SIZE: Number of bytes of the security seed (max = 4)
 *     UDS_SECURITY_COUNTER_NVM_CALLBACK: Callback to store a new value of the counter in NVM.
 *			- Signature: void UDS_SECURITY_COUNTER_NVM_CALLBACK(UI_8 *value)
 *          - (legacy) If not defined, then value will not be stored in NVM.
 *     UDS_SECURITY_COUNTER_NVM_LOAD_CALLBACK: Callback to retrieve the value of the counter from NVM, tipically
 *          at the beginning of the execution.
 *			- Signature: UI_8 UDS_SECURITY_COUNTER_NVM_LOAD_CALLBACK(void)
 *          - (legacy) If not defined, then value will be loaded as zero (check startup strategy for penalty delay
 *              using SECURITY_INIT_DELAY).
 ****************************************************************************/
//#define UDS_SERVICE_SECURITY_ACCESS         (UDS_EXT_DIAG_SESSION_MASK | UDS_PROGRAMMING_SESSION_MASK | UDS_SYSTEM_SUPPLIER_SPECIFIC_SESSION_MASK)
////#define UDS_SECURITY_REQUEST_SEED_CALLBACK              (UdsSecurityGetSeed)
//#define UDS_SECURITY_CHECK_KEY_CALLBACK                 (UdsSecurityCheckKey)
#define SECURITY_INIT_DELAY 				(SECURITY_DELAY)
//#define MAX_SECURITY_ATTEMPTS				((UI_8) 	3)
#define SECURITY_PENALTY_TIME				((UI_16) 20000)
#define SECURITY_SEED_SIZE					((UI_8) 	16)
#define SECURITY_KEY_SIZE					((UI_8) 	16)
#define UDS_SECURITY_COUNTER_NVM_CALLBACK   (UdsSecurityNvmCallback)
#define UDS_SECURITY_COUNTER_NVM_LOAD_CALLBACK (UdsSecurityLoadNvmCallback)

#endif

#if (UDS_SERVICE_TESTER_PRESENT_STATUS == SERVICE_ENABLED)
/*****************************************************************************
 * TESTER PRESENT (0x3E)							     				     
 *****************************************************************************
 * This service CAN be enabled/disabled								     	 
 * No User CALLBACK Needed													 
 ****************************************************************************/  
#define UDS_SERVICE_TESTER_PRESENT  (UDS_ALL_SESSION_MASK)

#endif


#if (UDS_SERVICE_READ_DATA_BY_IDENTIFIER_STATUS == SERVICE_ENABLED)
/*****************************************************************************
 * READ DATA BY ID(0x22)								     				 
 *****************************************************************************
 * This service CAN be enabled/disabled								     	 
 * CALLBACKS:																 
 *   void UDS_SERVICE_READ_DATA_BY_IDENTIFIER_CALLBACK(UI_8 id_high,
 *     UI_8 id_low): Pass the ID to the user to                  
 *     process the request. The user is responsible for checking the security
 *     status for each parameter, and to send the appropiate response.		 
 *****************************************************************************/  
#define UDS_SERVICE_READ_DATA_BY_IDENTIFIER (UDS_ALL_SESSION_MASK)
#define UDS_SERVICE_READ_DATA_BY_IDENTIFIER_CALLBACK (UdsReadDataByIdentifier)

#endif

#if (UDS_SERVICE_READ_MEMORY_BY_ADDRESS_STATUS == SERVICE_ENABLED)
/*****************************************************************************
 * READ MEMORY BY ADDRESS(0x23)							     				 
 *****************************************************************************
 * This service CAN be enabled/disabled								     	 
 * CALLBACKS:
 *   void UDS_SERVICE_READ_MEMORY_BY_ADDRESS_CALLBACK(UI_8 mem_size_len, 
 *      UI_8 mem_addr_len, UI_8* mem_addr, UI_8* mem_size): The user must 
 *      retrieve the requested memory address buffer and return it to the host
 *****************************************************************************/  
#define UDS_SERVICE_READ_MEMORY_BY_ADDRESS    (UDS_DEFAULT_SESSION_MASK | UDS_PROGRAMMING_SESSION_MASK | UDS_EXT_DIAG_SESSION_MASK)
#define UDS_SERVICE_READ_MEMORY_BY_ADDRESS_CALLBACK (UdsReadMemoryByAddress)

#endif


#if (UDS_SERVICE_WRITE_DATA_BY_IDENTIFIER_STATUS == SERVICE_ENABLED)
/*****************************************************************************
 * WRITE DATA BY IDENTIFIER(0x2E)							     			 
 *****************************************************************************
 * This service CAN be enabled/disabled								     	 
 * CALLBACKS:																 
 *   UI_8 UDS_SERVICE_WRITE_DATA_BY_IDENTIFIER_CALLBACK (UI_16 id,           
 *     UI_8* p_buf, UI_16 size): This callback is                            
 *     responsible for starting the writting process to get the data written 
 *     in the apporpiate memory position / device and to 	 
 *     return the command that must be sent back to the tool				 
 *     id: The id to modify													 
 *     p_buf: Id data as sent by the diagnostics tool						 
 *     size: Amount of ID data bytes received								 
 *****************************************************************************/  
#define UDS_SERVICE_WRITE_DATA_BY_IDENTIFIER  (UDS_EXT_DIAG_SESSION_MASK|UDS_SYSTEM_SUPPLIER_SPECIFIC_SESSION_MASK)
#define UDS_SERVICE_WRITE_DATA_BY_IDENTIFIER_CALLBACK (UdsWriteDataByIdentifier)

#endif

#if (UDS_SERVICE_WRITE_MEMORY_BY_ADDRESS_STATUS == SERVICE_ENABLED)
/*****************************************************************************
 * WRITE MEMORY BY ADDRES(0x3D)							     			 
 *****************************************************************************
 * This service CAN be enabled/disabled								     	 
 * CALLBACKS:																 
 *   void UDS_SERVICE_WRITE_DATA_BY_IDENTIFIER_CALLBACK (UI_8 id_high,
 *	   UI_8 id_low, UI_8* p_buf, UI_16 size):
 *     This callback is used by the user to write the data identified with id
 *     in the appropiate mamory / device. The data sent by the host is passed
 *     in p_buf/size
 *****************************************************************************/  
#define UDS_SERVICE_WRITE_MEMORY_BY_ADDRESS   (UDS_DEFAULT_SESSION_MASK | UDS_PROGRAMMING_SESSION_MASK | UDS_EXT_DIAG_SESSION_MASK)
#define UDS_SERVICE_WRITE_MEMORY_BY_ADDRESS_CALLBACK (UdsWriteMemoryByAddr)

#endif


#if (UDS_SERVICE_CONTROL_DTC_SETTING_STATUS == SERVICE_ENABLED)
/*****************************************************************************
 * CONTROL DTC SETTING (0x85)							     				 
 *****************************************************************************
 * This service CAN be enabled/disabled								     	 
 * CALLBACKS:																 
 *   UI_8 UDS_SERVICE_CONTROL_DTC_SETTING_CALLBACK(UI_8 dtc_setting_mode,
 *     UI_8* buf_data_rx, I_16 size): 
 * 	   size: size of the dtc option record received						     
 *     buf_data_rx: pointer to the dtc option record received						 
 *     This callback is responsible for sending the appropiate response 	 
 ****************************************************************************/  
//#define UDS_SERVICE_CONTROL_DTC_SETTING   (UDS_EXT_DIAG_SESSION_MASK|UDS_SYSTEM_SUPPLIER_SPECIFIC_SESSION_MASK)
#define UDS_SERVICE_CONTROL_DTC_SETTING_CALLBACK (UdsControlDtcSetting)

#endif


#if (UDS_SERVICE_CLEAR_DIAGNOSTIC_INFORMATION_STATUS == SERVICE_ENABLED)
/*****************************************************************************
 * CLEAR DTC INFORMATION(0x14)							     			 
 *****************************************************************************
 * This service CAN be enabled/disabled								     	 
 * CALLBACKS:		
 *   void UDS_SERVICE_CLEAR_DIAGNOSTIC_INFORMATION_CALLBACK(UI_8* p_dtc_group)
 *   Clear all DTC codes identified by the p_dtc_group reference
 *****************************************************************************/  
#define UDS_SERVICE_CLEAR_DIAGNOSTIC_INFORMATION    (UDS_ALL_SESSION_MASK) 
#define UDS_SERVICE_CLEAR_DIAGNOSTIC_INFORMATION_CALLBACK   (UdsClearDtc)

#endif


#if (UDS_SERVICE_READ_DTC_INFORMATION_STATUS == SERVICE_ENABLED)
/*****************************************************************************
 * READ DTC INFORMATION(0x19)							     			 
 *****************************************************************************
 * This service CAN be enabled/disabled								     	
 * CALLBACKS:																 
 *   UI_8 UDS_SERVICE_READ_DTC_INFORMATION_CALLBACK (UI_16 id,        
 *     UI_8* p_buf, UI_16 size): 
 * 	   Retrieve and send the Diagnostics Info identified by id.
 *****************************************************************************/  
#define UDS_SERVICE_READ_DTC_INFORMATION   (UDS_ALL_SESSION_MASK)
#define UDS_SERVICE_READ_DTC_INFORMATION_CALLBACK (UdsReadDtc)

#endif


#if (UDS_SERVICE_IO_CTRL_BY_ID_STATUS == SERVICE_ENABLED)
/*****************************************************************************
 * I/O CONTROL BY ID(0x2F)							     			 
 *****************************************************************************
 * This service CAN be enabled/disabled								     	 
 * CALLBACKS:																 
 *   UI_8 UDS_INPUT_OUTPUT_CONTROL_BY_ID(UI_8 *data_buffer, UI_8 size)
*****************************************************************************/  
#define UDS_SERVICE_IO_CTRL_BY_ID   (UDS_EXT_DIAG_SESSION_MASK|UDS_SYSTEM_SUPPLIER_SPECIFIC_SESSION_MASK)
#define UDS_SERVICE_IO_CTRL_BY_ID_CALLBACK (UdsInputOutputControlByIdentifier)

#endif


#if (UDS_SERVICE_ROUTINE_CONTROL_STATUS == SERVICE_ENABLED)
/****************************************************************************
 * ROUTINE CONTROL(0x31)							     			 
 ****************************************************************************
 * This service CAN be enabled/disabled	
 * CALLBACKS:
 *   UI_8 UDS_SERVICE_ROUTINE_CONTROL_START_CALLBACK(UI_8 id_high, UI_8 id_low, 
 *   UI_16 size, UI_8 *data_buffer); 
 *   Host wants to start a control routine. 
 *   User is responsible for returning the appropiate response code.
 ****************************************************************************/
#define UDS_SERVICE_ROUTINE_CONTROL (UDS_EXT_DIAG_SESSION_MASK|UDS_SYSTEM_SUPPLIER_SPECIFIC_SESSION_MASK)
#define UDS_SERVICE_ROUTINE_CONTROL_CALLBACK (UdsControlRoutine)

#endif


#if (UDS_SERVICE_REQUEST_DOWNLOAD_STATUS == SERVICE_ENABLED)
/*****************************************************************************
 * REQUEST DOWNLOAD(0x34)
 *****************************************************************************
 * This service CAN be enabled/disabled		
 * CALLBACK:
 *   UI_8 DEVICE_0_REQUEST_DOWNLOAD_CALLBACK(t_addr base_addr, t_addr last_addr)
 *   The host wnats to start a download from address dl_base with a size
 *   of dl_size in bytes. Calculate if this is possible. And give an answer
 *   Define one callback for each device in the system that may receive
 *   data through a downlonad.
 ****************************************************************************/
#define UDS_SERVICE_REQUEST_DOWNLOAD                    (UDS_PROGRAMMING_SESSION_MASK)
/*#define DEVICE_0_REQUEST_DOWNLOAD_CALLBACK (UdsPlm2BLRequestDownload)*/

#endif


#if (UDS_SERVICE_TRANSFER_DATA_STATUS == SERVICE_ENABLED)
/*****************************************************************************
 * TRANSFER DATA(0x36)							     			 
 *****************************************************************************
 * This service CAN be enabled/disabled								     	 
 * CALLBACKS
 *   UI_8 DEVICE_0_TRANSFER_DATA_CALLBACK(UI_8* pData, UI_16 size)
 *   A data block is sent by the host, program it in the right memory.
 *   The right destination address is responsability of the user callback
 *   Define one callback per each device that can receive the data
 ****************************************************************************/
#define UDS_SERVICE_TRANSFER_DATA   (UDS_PROGRAMMING_SESSION_MASK)
/*#define DEVICE_0_TRANSFER_DATA_CALLBACK (UdsPlm2BLTransferData)*/

#endif


#if (UDS_SERVICE_REQUEST_TRANSFER_EXIT_STATUS == SERVICE_ENABLED)
/*****************************************************************************
 * TRANSFER EXIT(0x37)
 *****************************************************************************
 * This service CAN be enabled/disabled								     	 
 * CALLBACK:
 *   UI_8 DEVICE_0_REQUEST_TRANSFER_EXIT_CALLBACK(UI_8* pData, UI_16 size)
 *   The host informs us that the download process is finished
 ****************************************************************************/
#define UDS_SERVICE_REQUEST_TRANSFER_EXIT   (UDS_PROGRAMMING_SESSION_MASK)
/*#define DEVICE_0_REQUEST_TRANSFER_EXIT_CALLBACK (UdsPlm2BLTransferExit)*/

#endif

#if (UDS_SERVICE_COMMUNICATION_CONTROL_STATUS == SERVICE_ENABLED)
/*****************************************************************************
 * COMMUNICATION CONTROL	(0x28)									     
 *****************************************************************************
 * This service CAN be enabled/disabled								     
 * CALLBACKS:																 
 * .- UDS_COMMUNICATION_CONTROL_CALLBACK: The user MAY implement this callback.	     
 * DEFINES:
 * .- UDS_COMMUNICATION_CONTROL. Session in which the service will be supported
 ****************************************************************************/ 
#define UDS_SERVICE_COMMUNICATION_CONTROL   (UDS_EXT_DIAG_SESSION_MASK|UDS_SYSTEM_SUPPLIER_SPECIFIC_SESSION_MASK)
#define UDS_COMMUNICATION_CONTROL_CALLBACK  (UdsCommunicationControl)

#endif
#endif
