/* -----------------------------------------------------------------------------
  Filename:    desc.h
  Description: Interface of CANdesc visible to any application.
                
                Manufacturer: Vector
                EcuDocFile:   C:\1_sangshulin\SVN\V2X\30_DevelopLibrary\03_SW\99_Others\CANbedded\Geny_For_CanMatrix5_1\Tbox4.00.cdd
                Variant:      Base_Variant

  Generated by CANdelaGen, Fri Oct 16 10:47:20 2020
 
 ----------------------------------------------------------------------------- */
/* -----------------------------------------------------------------------------
  C O P Y R I G H T
 -------------------------------------------------------------------------------
  Copyright (c) 2001-2013 by Vector Informatik GmbH. All rights reserved.
 
  This software is copyright protected and proprietary to Vector Informatik 
  GmbH.
  
  Vector Informatik GmbH grants to you only those rights as set out in the 
  license conditions.
  
  All other rights remain with Vector Informatik GmbH.
 -------------------------------------------------------------------------------
 ----------------------------------------------------------------------------- */

#if !defined(__DESC_H__)
#define __DESC_H__

/* -----------------------------------------------------------------------------
    &&&~ History
 ----------------------------------------------------------------------------- */

/* 
------------------------------------------------------------------------------------------------------------------------
                                             A U T H O R   I D E N T I T Y                                              
------------------------------------------------------------------------------------------------------------------------
Initials   Name                  Company                                                                                
---------- --------------------- ---------------------------------------------------------------------------------------
Aey        Amr Elazhary          Vector Informatik GmbH                                                                 
Ktw        Katrin Thurow         Vector Informatik GmbH                                                                 
Rpk        Patrick Rieder        Vector Informatik GmbH                                                                 
Sa         Mishel Shishmanyan    Vector Informatik GmbH                                                                 
Wse        Wilfried Steudle      Vector Informatik GmbH                                                                 
------------------------------------------------------------------------------------------------------------------------
                                            R E V I S I O N   H I S T O R Y                                             
------------------------------------------------------------------------------------------------------------------------
Date       Version  Author Modification type Issue Id      Affects                        Description                    
---------- -------- ------ ----------------- ------------- ------------------------------ -------------------------------
2012-11-12  6.13.00
                    Ktw    Added             ESCAN00065352 Vector(UDS:2012)               Support 14229-1 2012           
2013-06-04  6.14.00
                    Ktw    Added             ESCAN00067881 Vector(UDS:2012)               Support Cdds of Oem Tml        
2013-09-05  6.14.01
                    Sa     Fixed             ESCAN00070242 UDS:2012                       Unexpected behavior executing service 0x2A 0x04 with concrete PDID(s)
2013-09-27  6.15.00
                    -      -                 -             -                              No relevant changes available in this version.
2013-11-29  6.15.01
                    -      -                 -             -                              No relevant changes available in this version.
2014-01-10  6.15.02
                    -      -                 -             -                              No relevant changes available in this version.
2014-01-31  6.16.00
                    Rpk    Added             ESCAN00074628 Vector(UDS:2012)               Support DEM 412 Interface      
                    Rpk    Added             ESCAN00074207 Vector(UDS:2012)               Adapt CANdesc to fully AR 4.1.2 compatible DEM API Dem_DcmGetSizeOfExtendedDataRecordByDTC behavior
                    Rpk    Fixed             ESCAN00071736 UDS:2012                       Invalid security access requests do not reset the "waiting for key" state
                    Rpk    Fixed             ESCAN00073361 UDS:2012                       False access attempt counter is not reset after the delay timer expires
2014-07-14  6.17.00
                    Rpk    Fixed             ESCAN00077591 Vector(UDS:2012)               DescRingBufferWrite triggers an assert
                    Rpk    Fixed             ESCAN00077461 Vector(UDS:2012)               Compiler error: 'g_descUsedFrzFrameRecIds' is undefined
                    Rpk    Fixed             ESCAN00076931 Vector(UDS:2012)               Service 0x19: Continuous response pending messages without final response
                    Rpk    Fixed             ESCAN00076339 Vector(UDS:2012)               CANdesc calls DEM SetDTCFilter API with wrong DTC kind for service 0x19 0x15
                    Rpk    Fixed             ESCAN00076297 Vector(UDS:2012)               Unexpected response for service 0x19 0x05 0x00
                    Rpk    Fixed             ESCAN00075946 Vector(UDS:2012)               Compiler error: DescDemApiInterpretClearResult not defined
                    Rpk    Fixed             ESCAN00077133 UDS:2012                       Wrong NRC 0x31 on Service 0x22 request which is too long
                    Rpk    Fixed             ESCAN00072108 UDS:2012                       Compiler warning: Unused variable securityInstanceIndex in function DescSecurityAccessKeyChecked
                    Rpk    Fixed             ESCAN00061617 All                            Compiler warning: warning C4244: '=' : conversion from 'DescDynDidMemBlockSize' to 'vuint16', possible loss of data
2014-08-12  6.17.01
                    Rpk    Fixed             ESCAN00077788 Vector(UDS:2012)               Compiler error: busProperty is not a member of t_descUudtNetBusInfoTag
2014-11-05  6.18.00
                    Rpk    Fixed             ESCAN00079301 UDS:2012                       ECU returns NRC 0x13 instead of 0x7E/0x31
                    Rpk    Fixed             ESCAN00080104 UDS:2012                       Compiler error: Function DescGetLevelIdxOfState is not defined
                    Rpk    Fixed             ESCAN00080018 All                            AR3 DEM interface: Activating the iteration limiter for reading DTCs from the DEM has no effect
                    Rpk    Fixed             ESCAN00080019 All                            AR4 DEM interface: Activating the iteration limiter for reading DTCs/SnapshotRecordIdentification has no effect
2015-06-23  6.19.00
                    Rpk    Fixed             ESCAN00083960 Vector(UDS:2012)               Correct comments and error directive in the Asr4 Dem Interface
                    Rpk    Fixed             ESCAN00081314 Vector(UDS:2012)               Compiler warning: DCM_RUNTIME_USAGE_LIMIT_ENABLED is not defined
                    Aey    Modified          ESCAN00084257 Vector(UDS:2012)               Service 0x19 0x05 0xFF shall return positive response for SSR 0x00
                    Aey    Modified          ESCAN00084246 Vector(UDS:2012)               Support DCM 4.2.1 Dem_DcmClearDTC return value DEM_CLEAR_MEMORY_ERROR
                    Rpk    Fixed             ESCAN00079798 UDS:2012                       Wrong API description for manufacturer and supplier notifications
                    Rpk    Fixed             ESCAN00083701 All                            Compiler error: non ASCII character used in comments
                    Rpk    Fixed             ESCAN00083450 All                            Generating unnecessary dummy DANIS TP adapter functions inside desc.c when there no TP and DANIS TP adapter are configured.
                    Rpk    Fixed             ESCAN00081716 All                            The diagnostic communication is blocked and a diagnostic response might be sent on the wrong CAN channel
2015-09-03  6.20.00
                    -      -                 -             -                              No relevant changes available in this version.
2015-10-23  6.21.00
                    Aey    Fixed             ESCAN00085340 UDS:2012                       ECU may send empty positive response for service 0x19 0x05 0x00
                    Aey    Fixed             ESCAN00073624 UDS:2012                       Service 0x19 0x04/0x06/0x10/0x18/0x19 with RecID 0xFF has different behavior depending on the PagedBuffer support
                    Aey    Fixed             ESCAN00086295 All                            Compiler warning: Infinite loop possibility
                    Aey    Fixed             ESCAN00072264 All                            candesc support of more than 8 logical channels
                    Aey    Added             ESCAN00087649 All                            Support for RcrRp in CANdesc - LinTP interface
2016-03-15  6.22.00
                    -      -                 -             -                              No relevant changes available in this version.
2016-05-19  6.23.00
                    Wse    Added             ESCAN00090258 Vector(UDS:2012)               Reset of attempt counter is configurable in GENy
                    Wse    Added             ESCAN00090212 Vector(UDS:2012)               Delete dynamical  defined DIDs when going back to default session configurable in GENy
                    Wse    Fixed             ESCAN00090447 UDS:2012                       Replace NRC kDescNrcConditionsNotCorrec (0x22) by NRC kDescNrcRequestOutOfRange (0x31) in service $19 when using Vector DEM
                    Wse    Fixed             ESCAN00083566 All                            Compiler warning: variable g_descSchedulerTimer set but never used
                    Wse    Fixed             ESCAN00083588 All                            Compiler warning: variable g_descRdpiStateCtrl is set but never used
2016-07-28  6.24.00
                    Wse    Fixed             ESCAN00090646 UDS:2012                       UUDT messages overload in combination with service $22 for DynDID
2016-10-05  6.25.00
                    Wse    Added             ESCAN00092202 Vector(UDS:2012)               Calling DescSendPosRespFBL possible for OEM=Vector
                    Wse    Fixed             ESCAN00092159 UDS:2012                       Compiler error: identifier Possibility of undefined parameter securitySeedObjIndex is undefined
                    Wse    Fixed             ESCAN00091636 UDS:2012                       Compiler warning: inconsistent storage class specification for Desc85Process
                    Wse    Fixed             ESCAN00092078 UDS:2012                       Pointer out of bounds in Desc85Process
2016-12-20  6.26.00
                    Wse    Added             ESCAN00093006 Vector(UDS:2012)               API to application added if attempt counter value changes for OEM=Vector
                    Wse    Fixed             ESCAN00093091 UDS:2012                       Check combination of attempt counter and attempt delay for all security levels in UDS2012
                    Wse    Fixed             ESCAN00055957 All                            appdesc.c missing line feed (LF) after carriage return (CR) on some lines
                    Wse    Fixed             ESCAN00092436 All                            Compiler error: (Linker Error) Symbol DescPostRoutineControlByIdentifier is undefined
                    Wse    Fixed             ESCAN00093238 All                            Null pointer read-access for busy-repeat-request (NRC 0x21) response in case of parallel client requests
2017-03-06  6.27.00
                    Wse    Fixed             ESCAN00093265 All                            Unexpected NRC 0x21 (BusyRepeatRequest) response sent to tester
2017-05-02  6.28.00
                    Wse    Fixed             ESCAN00094512 UDS:2012                       Compiler Warning: securitySeedObjIndex was declared but never referenced
                    Wse    Fixed             ESCAN00080010 UDS:2012                       Compiler error: DescInterruptDisable/DescInterruptRestore is not an expression
                    Wse    Fixed             ESCAN00095088 UDS:2012                       service $22 rejected for supported DID in case of unified PID handling
                    Wse    Fixed             ESCAN00081861 All                            Compiler warning: Truncating assignment in DescContextStateTask
                    Wse    Fixed             ESCAN00081853 All                            Compiler warning: Truncating assignment in DescPidDispatcher
                    Wse    Fixed             ESCAN00081852 All                            Compiler warning: Truncating assignment in DescUudtNetCANTxReserveResource
                    Wse    Fixed             ESCAN00081850 All                            Compiler warning: Truncating assignment in DescICNGetResponseData
                    Wse    Fixed             ESCAN00081836 All                            Compiler warning: Truncating assignment in DescConfirmation
                    Wse    Fixed             ESCAN00055156 All                            Compiler warning: truncating assignment
                    Wse    Fixed             ESCAN00081827 All                            Compiler warning: Truncating assignment in DescUsdtNetIsoTpCopyToCan
2017-07-24  6.28.01
                    Wse    Fixed             ESCAN00095783 UDS:2012                       CANdesc: array access out of bounds in function DescUudtNetCANCancelAllResponses()
2017-10-18  6.29.00
                    Wse    Added             ESCAN00097004 UDS:2012                       DescSetNegResponse can be called in ApplDescSecurityAccessGetSeed and ApplDescSecurityAccessCheckKey
2018-03-21  6.30.00
                    Wse    Added             ESCAN00098170 Vector(UDS:2012)               Support Cdds of OEM GWM        
                    Wse    Fixed             ESCAN00097832 All                            Response for service $22 incomplete in case of ring buffer used and multiple DIDs in request
                    Wse    Fixed             ESCAN00097834 All                            Handling of Gaps in a DID is not correct
                    Wse    Fixed             ESCAN00097915 All                            Response for service $22 incomplete if requested DID is handled as signal handler
                    Wse    Fixed             ESCAN00098423 All                            Response for service $22 incomplete in case of multiple DIDs in request using ring buffer mechanisms
                    Wse    Added             ESCAN00097837 All                            Variable handling of buffer size to support CAN-FD
2018-06-06  6.31.00
                    Wse    Fixed             ESCAN00099512 All                            NRC=0x78 is sent forever after request $19 04, $19 06 or $19 10
                    Wse    Added             ESCAN00098571 All                            Spontaneous messages in CAN-FD 
2018-10-10  6.32.00
                    Wse    Fixed             ESCAN00100864 Vector(UDS:2012)               Compilation error if Failed Attempt Counter Notification is configured as active
                    Wse    Fixed             ESCAN00099758 All                            Diagnostic Buffer Size too small in case of CAN-FD
2019-01-08  6.33.00
                    Wse    Added             ESCAN00101527 Vector(UDS:2012)               Support Cdds of OEM WMMotor    
                    Wse    Added             ESCAN00101528 Vector(UDS:2012)               Support Cdds of OEM KTM        
------------------------------------------------------------------------------------------------------------------------
 */


/* -----------------------------------------------------------------------------
    &&&~ Includes
 ----------------------------------------------------------------------------- */

/* include of TP interface */
#include "tpmc.h"



/* -----------------------------------------------------------------------------
    &&&~ Configuration switches
 ----------------------------------------------------------------------------- */

#if defined (V_ENABLE_USE_DUMMY_STATEMENT)
/* Everything ok */
#else
# if defined (V_DISABLE_USE_DUMMY_STATEMENT)
  /* Everything ok */
# else
  /* Define compatibile switch in case of older tools */
#  define V_ENABLE_USE_DUMMY_STATEMENT
# endif
#endif

/* Gentool GENy will be supported. */
#define DESC_ENABLE_GENTOOL_GENY
/* Flashable ECU will not be supported. */
#define DESC_DISABLE_FLASHABLE_ECU
/* Vectors FBL will not be supported. */
#define DESC_DISABLE_VECTOR_FBL_USAGE
/* Far addressing of diagnostic buffer will not be supported. */
#define DESC_DISABLE_FAR_BUFFER
/* KWP2000 diagnostic protocol will not be supported. */
#define DESC_DISABLE_PROTOCOL_KWP
/* UDS diagnostic protocol will not be supported. */
#define DESC_DISABLE_PROTOCOL_UDS
/* UDS diagnostic protocol will be supported. */
#define DESC_ENABLE_PROTOCOL_UDS2012
/* Application debug monitoring will not be supported. */
#define DESC_DISABLE_DEBUG_USER
/* Internal processes' debug monitoring will not be supported. */
#define DESC_DISABLE_DEBUG_INTERNAL


#if (TP_USE_EXTENDED_ADDRESSING == kTpOn) || \
    defined (TP_ENABLE_NORMAL_FIXED_ADDRESSING) || \
    defined (TP_ENABLE_MIXED_29_ADDRESSING)
# define DESC_ENABLE_ACCESS_TESTER_ADDRESS_API
#endif

/* Transport layer type */
#if defined (TP_ENABLE_SINGLE_CHANNEL_TP)
# define DESC_USDTNET_DISABLE_MULTI_TP
# define DESC_USDTNET_ENABLE_SINGLE_TP_OPTIMIZED
#else
# define DESC_USDTNET_ENABLE_MULTI_TP
# define DESC_USDTNET_DISABLE_SINGLE_TP_OPTIMIZED
#endif

/* LongServiceExecution will not be supported. */
#define DESC_USDTNET_DISABLE_LONGSERVICE_SUPPORT
/* Ring buffer will not be supported. */
#define DESC_USDTNET_DISABLE_RING_BUFFER
/* Far RAM buffer will not be supported. */
#define DESC_USDTNET_DISABLE_FAR_BUFFER
/* Shared buffer multi client usage will not be supported. */
#define DESC_USDTNET_DISABLE_MULTI_OWNER_SHARED_BUFFER
/* Dynamic buffer usage will not be supported. */
#define DESC_USDTNET_DISABLE_DYNAMIC_BUFFER_LENGTH
/* Static buffer allocation */
#define DESC_USDTNET_ENABLE_VECTOR_ISO_TP

/* UUDT Network will not be supported. */
#define DESC_DISABLE_UUDT_NET
/* Check before message reception will not be supported. */
#define DESC_DISABLE_CHECK_MSG_RX_ACCEPTANCE
/* Spontaneous response will be supported. */
#define DESC_ENABLE_SPONTANEOUS_RES
/* Secured data transmission API will not be supported. */
#define DESC_DISABLE_SECURED_DATA_TRANSMISSION
/* Multi channel system will not be supported. */
#define DESC_DISABLE_MULTI_CHANNEL_SUPPORT
/* Code-doubled CANdriver will not be supported. */
#define DESC_DISABLE_CODE_DOUBLED_DRIVER_API
/* Parallel reception and rejection diagnostic service will not be supported. */
#define DESC_DISABLE_BUSY_REPEAT_RESPONDER
/* Additional OBD reception path will not be supported. */
#define DESC_DISABLE_OBD_FUNC_REQUEST
/* Parallel handling of OBD service will not be supported. */
#define DESC_DISABLE_PARALLEL_OBD
/* CCL usage */
#if defined (VGEN_ENABLE_CCL)
# define DESC_ENABLE_CCL_SUPPORT
#else
# define DESC_DISABLE_CCL_SUPPORT
#endif
/* Transport layer type */
#if defined (TP_ENABLE_SINGLE_CHANNEL_TP)
# define DESC_DISABLE_MULTI_TP
# define DESC_ENABLE_SINGLE_TP_OPTIMIZED
#else
# define DESC_ENABLE_MULTI_TP
# define DESC_DISABLE_SINGLE_TP_OPTIMIZED
#endif

/* Addressing information validation */
#define DESC_DISABLE_PHYSREQ_TA_CHECK
#define DESC_DISABLE_PHYSREQ_SA_CHECK

#define DESC_DISABLE_FUNCREQ_TA_CHECK
#define DESC_DISABLE_FUNCREQ_SA_CHECK

/* Enable response on requests whic SID are in range 
 * [0x40, 0x7F]U[0xC0, 0xFF]
 */
#define DESC_ENABLE_NEG_RES_ON_SID_WITH_SET_BIT6
 /* No node power management */
#define DESC_DISABLE_NODE_POWER_CONTROL
/* In general use default session monitoring */
#define DESC_DISABLE_DEFAULT_SESSION_SLEEP_PREVENTION

/* TesterPresent monitoring will be supported. */
#define DESC_ENABLE_S1_TIME_MONITORING
/* No RCR-RP limitation will be used. */
#define DESC_DISABLE_RES_PENDING_TIME_LIMIT
#define DESC_DISABLE_RES_PENDING_COUNT_LIMIT
/* Application forced RCR-RP response transmission will be supported. */
#define DESC_ENABLE_FORCE_RCR_RP
/* Session specific P2 (P2*) timings will not be supported. */
#define DESC_DISABLE_DYNAMICAL_P2_TIMINGS
/* Disable special handling on RCR-RP limit expiration (e.g. send negative response $71) */
#define DESC_DISABLE_OEM_HANDLING_ON_RCRRP_LIMIT_EXPIRATION

/* Automaticaly managed states will be supported. */
#define DESC_ENABLE_AUTO_STATES
/* Do not ignore the SPRMIB (mask out but response will be sent) */
#define DESC_DISABLE_POS_RES_ON_SET_SPRMIB

/* Do distinguish between sub-function and identifier */
#define DESC_DISABLE_SAME_NRC_ON_SUB_FUNC_AND_PARAM_ID

/* Each main-handler will be called only once. The application shall take care about calling DescProcessingDone from somwhere at the end of the request process. */
#define DESC_DISABLE_MAINHANDLER_MULTICALL
#define DESC_DISABLE_INDIVIDUAL_MAINHANDLER_MULTICALL
#define DESC_DISABLE_PERMANENT_MAINHANDLER_MULTICALL
/* Request minimum length check will be supported. */
#define DESC_ENABLE_MIN_REQ_LEN_CHECK
/* Any pre-Handler from the SvcInst table will be supported. */
#define DESC_ENABLE_PREHANDLER_USAGE
/* Any post-Handler from the SvcInst table will be supported. */
#define DESC_ENABLE_POSTHANDLER_USAGE
/* User (unknown) service-handler will not be supported. */
#define DESC_DISABLE_GENERIC_USER_SERVICE_SUPPORT
/* User (unknown) service post-handler will not be supported. */
#define DESC_DISABLE_GENERIC_USER_POST_HANDLER_SUPPORT
/* Do check addressing of request will not be supported. */
#define DESC_DISABLE_ADDR_METHOD_CHECK
/* Do check all state groups on SID level. will be supported. */
#define DESC_ENABLE_ALL_STATEGROUPS_SID_CHECK
/* Session check before format check will be supported. */
#define DESC_ENABLE_SESSION_FORMAT_STATE_CHECK
/* Send all Nrcs after a pending was sent will be supported. */
#define DESC_ENABLE_ALL_RES_AFTER_RCRRP
/* Handle DIDs not supported in current session as not supported will be supported. */
#define DESC_ENABLE_SKIP_PID_ON_WRONG_SESSION
/* Do send NRC for wrong session only if none of the requested PIDs are supported in the session. will be supported. */
#define DESC_ENABLE_PID_NRC_ALL_ON_WRONG_SESSION
/* Handle DIDs not supported in current security state as not supported will not be supported. */
#define DESC_DISABLE_SKIP_PID_ON_WRONG_SECURITY_STATE
/* If OBD services are present enable conformance */
#if defined (DESC_ENABLE_OBD_FUNC_REQUEST)
# define DESC_ENABLE_OBDII_NR_CONFORMANCE
#endif

/* Is skip PID supported? */
#if defined (DESC_ENABLE_SKIP_PID_ON_WRONG_SESSION) || \
    defined (DESC_ENABLE_SKIP_PID_ON_WRONG_SECURITY_STATE)
# define DESC_ENABLE_SKIP_PID
#else
# define DESC_DISABLE_SKIP_PID
#endif

/* Pre-handlers will be supported. */
#define DESC_ENABLE_ANY_PREHANDLER_USAGE
/* Post-handlers will be supported. */
#define DESC_ENABLE_ANY_POSTHANDLER_USAGE
/* Use linear search for optimal runtime. */
#define DESC_DISABLE_BINARY_SVCINST_SEARCH
#define DESC_ENABLE_LINEAR_SVCINST_SEARCH
/* Sub-service protocol information will be supported. */
#define DESC_ENABLE_SUB_SVC_USAGE
/* Supplier callbacks are called will not be supported. */
#define DESC_DISABLE_SUPPLIER_CALLBACKS
/* Manufacturer callbacks are called will not be supported. */
#define DESC_DISABLE_MANUFACTURER_CALLBACKS
/* SPRMIB override in the response will not be supported. */
#define DESC_DISABLE_SPRMIB_OVERRIDE
/* Self-transition workaround will not be supported. */
#define DESC_DISABLE_SESSION_SELFTRANSITION_SIM
/* Communication control service will be supported. */
#define DESC_ENABLE_COMM_CTRL
/* Coded communication parameter type check will not be supported. */
#define DESC_DISABLE_COM_CTRL_PARAM_CHECK
/* Dynamic communication parameters will be supported. */
#define DESC_ENABLE_DYN_COM_CTRL_PARAM
/* Communication control on RX path will not be supported. */
#define DESC_DISABLE_RX_COMM_CONTROL
/* Communciation control based on subnetworks will be supported. */
#define DESC_ENABLE_COMM_CTRL_SUBNET_SUPPORT
/* Programming session OEM handling will be supported. */
#define DESC_ENABLE_PROGRAMMING_SESSION
/* Stop session service will not be supported. */
#define DESC_DISABLE_SERVICE_STOP_SESSION
/* P2 and P2Ex times report in the positive response of DiagSessionControl will be supported. */
#define DESC_ENABLE_P2_TIME_REPORT
/* Security access service will be supported. */
#define DESC_ENABLE_SECURITY_ACCESS
/* PowerOn Delay is supported will not be supported. */
#define DESC_DISABLE_POWER_ON_DELAY
/* Counter and timer are level specific will be supported. */
#define DESC_ENABLE_SA_LEVEL_SPECIFIC
/* Delay Time level specific will not be supported. */
#define DESC_DISABLE_DELAY_TIME_LEVEL_SPECIFIC
/* Power On Time level specific will not be supported. */
#define DESC_DISABLE_POWERON_TIME_LEVEL_SPECIFIC
/* Atempt Counter level specific will not be supported. */
#define DESC_DISABLE_ATTEMPT_COUNTER_LEVEL_SPECIFIC
/* On change attempt counter value notification will be supported. */
#define DESC_ENABLE_REPORT_ATT_CNTR_STATE
/* Support Attempt Counter and delay will be supported. */
#define DESC_ENABLE_SA_TIMER_AND_COUNTER
/* Start extern timer activation will be supported. */
#define DESC_ENABLE_START_SA_TIMER_EXTERN
/* Attempt counter reset on time expired will be supported. */
#define DESC_ENABLE_ATT_CNTR_RESET_ON_TIME_EXPIRE
/* Support static seed calculation will not be supported. */
#define DESC_DISABLE_SA_STATIC_SEED
/* Multiple seed length will be supported. */
#define DESC_ENABLE_MULTIPLE_SEED_LENGTH
/* Multiple key length will be supported. */
#define DESC_ENABLE_MULTIPLE_KEY_LENGTH
/* securityAccessData will not be supported. */
#define DESC_DISABLE_SECURITY_ACCESS_DATA
/* Unified PID management will not be supported. */
#define DESC_DISABLE_UNIFIED_PID_MGR
/* PidList mode simulation will not be supported. */
#define DESC_DISABLE_SIM_PID_LIST_MODE
/* PIDs pre-Handlers will not be supported. */
#define DESC_DISABLE_PID_PREHANDLER_USAGE
/* PIDs post-Handlers will not be supported. */
#define DESC_DISABLE_PID_POSTHANDLER_USAGE
/* Combinable PID with dynamic data length will be supported. */
#define DESC_ENABLE_DYN_DID_RES_LENGTH
#define DESC_DISABLE_PID_SECURITY_FILTER
/* Routine control management will be supported. */
#define DESC_ENABLE_ROUTINE_CONTROL_MODE
/* RIDs pre-Handlers will not be supported. */
#define DESC_DISABLE_RID_PREHANDLER_USAGE
/* RIDs post-Handlers will not be supported. */
#define DESC_DISABLE_RID_POSTHANDLER_USAGE
/* RIDs control operation check will not be supported. */
#define DESC_DISABLE_RID_CTRL_OPER_CHECK
/* Scheduled PID will not be supported. */
#define DESC_DISABLE_PERIODIC_MODE
/* No periodical transmission. */
#define DESC_DISABLE_SCHEDULER_UUDT_TRANSMITTER
#define DESC_DISABLE_SCHEDULER_USDT_TRANSMITTER
/* Multiple PID in single request will be supported. */
#define DESC_ENABLE_PID_LIST_MODE
/* Dynamically defined DIDs will not be supported. */
#define DESC_DISABLE_DYN_DEFINED_DID_MODE
/* Dynamically defined by Id DIDs will not be supported. */
#define DESC_DISABLE_DEF_DYN_ID_BY_PID
/* Dynamically defined by memory DIDs will not be supported. */
#define DESC_DISABLE_DEF_DYN_ID_BY_MEM
/* Dynamically defined DPIDs will not be supported. */
#define DESC_DISABLE_DYN_DEFINED_DPID_MODE
/* ResponseOnEvent service will not be supported. */
#define DESC_DISABLE_ROE_SUPPORT
/* Ring-buffer handling will not be supported. */
#define DESC_DISABLE_RES_RINGBUFFER
/* Multi variants/ VSGs are supported will not be supported. */
#define DESC_DISABLE_MULTI_VARIANT


/* -----------------------------------------------------------------------------
    &&&~ Preprocessor constants (defines)
 ----------------------------------------------------------------------------- */

/* ##V_CFG_MANAGEMENT ##CQProject : Diag_CanDesc__core CQComponent : Implementation */
#define DIAG_CANDESC__CORE_VERSION                                   0x0633
#define DIAG_CANDESC__CORE_RELEASE_VERSION                           0x00
#define DESC_VERSION                                                 0x0633
#define DESC_RELEASE_VERSION                                         0x00
/* Desc generic return codes */
#define kDescOk                                                      ((vuint8)0x00)
#define kDescFailed                                                  ((vuint8)0x01)
/*  data type according to the CPU type */
#if defined( C_CPUTYPE_8BIT )
/* 8-Bit qualifier */
# ifndef vuint8_least
#  define vuint8_least                                               vuintx
# endif
# ifndef vsint8_least
#  define vsint8_least                                               vsintx
# endif
#else
# if defined( C_CPUTYPE_16BIT )
/* 16-Bit qualifier */
#  ifndef vuint8_least
#   define vuint8_least                                              vuintx
#  endif
#  ifndef vsint8_least
#   define vsint8_least                                              vsintx
#  endif
#  ifndef vuint16_least
#   define vuint16_least                                             vuintx
#  endif
#  ifndef vsint16_least
#   define vsint16_least                                             vsintx
#  endif

# else
#  if defined( C_CPUTYPE_32BIT )
/* 32-Bit qualifier */
#   ifndef vuint8_least
#    define vuint8_least                                             vuintx
#   endif
#   ifndef vsint8_least
#    define vsint8_least                                             vsintx
#   endif
#   ifndef vuint16_least
#    define vuint16_least                                            vuintx
#   endif
#   ifndef vsint16_least
#    define vsint16_least                                            vsintx
#   endif
#   ifndef vuint32_least
#    define vuint32_least                                            vuintx
#   endif
#   ifndef vsint32_least
#    define vsint32_least                                            vsintx
#   endif
#  endif
# endif
#endif

/* Default optimized types */
#ifndef vuint8_least
# define vuint8_least                                                vuint8
#endif
#ifndef vuint16_least
# define vuint16_least                                               vuint16
#endif
#ifndef vuint32_least
# define vuint32_least                                               vuint32
#endif

#ifndef vsint8_least
# define vsint8_least                                                vsint8
#endif
#ifndef vsint16_least
# define vsint16_least                                               vsint16
#endif
#ifndef vsint32_least
# define vsint32_least                                               vsint32
#endif

/* Optimized boolean type */
#ifndef vboolean
# define vboolean                                                    vuint8_least
#endif

#ifndef V_BOOL_TRUE
# define V_BOOL_TRUE                                                 (vboolean)1
#endif

#ifndef V_BOOL_FALSE
# define V_BOOL_FALSE                                                (vboolean)0
#endif
/* CANdesc API types use the CANdesc namings convention! */
#define kDescFalse                                                   V_BOOL_FALSE
#define kDescTrue                                                    V_BOOL_TRUE
#define DESC_IGNORE_UNREF_PARAM(paramName)                           ((void)paramName)

#if !defined (VUINT8_CAST)
# if defined ( C_COMP_COSMIC_HC08 ) || defined ( C_COMP_COSMIC_HC12 ) /* any cosmic cpu */
#  define VUINT8_CAST                                                (vuint8)
#  define VSINT8_CAST                                                (vsint8)
#  define VUINT16_CAST                                               (vuint16)
#  define VSINT16_CAST                                               (vsint16)
#  define CANBITTYPE_CAST                                            (vbittype)
#  define CANSINTCPUTYPE_CAST                                        (int)
#  define CANUINTCPUTYPE_CAST                                        (unsigned int)
# else
#  define VUINT8_CAST
#  define VSINT8_CAST
#  define VUINT16_CAST
#  define VSINT16_CAST
#  define CANBITTYPE_CAST
#  define CANSINTCPUTYPE_CAST
#  define CANUINTCPUTYPE_CAST
# endif /* ( C_COMP_COSMIC_HC08 ) || defined ( C_COMP_COSMIC_HC12 ) */
#endif

#if defined (V_MEMROM0)
/* new driver ok */
#else
# define V_MEMROM0
#endif


#if defined (V_MEMROM1)
/* new driver ok */
#else
# define V_MEMROM1
#endif

#if defined (V_MEMROM2)
/* new driver ok */
#else
# define V_MEMROM2                                                   MEMORY_ROM
#endif

#if defined (V_MEMROM3)
/* new driver ok */
#else
# define V_MEMROM3
#endif
#if defined (V_MEMRAM0)
/* new driver ok */
#else
# define V_MEMRAM0
#endif

#if defined (V_MEMRAM1)
/* new driver ok */
#else
# define V_MEMRAM1
#endif

#if defined (V_MEMRAM1_FAR)
/* new driver ok */
#else
# define V_MEMRAM1_FAR
#endif

#if defined (V_MEMRAM2)
/* new driver ok */
#else
# define V_MEMRAM2
#endif

#if defined (V_MEMRAM2_FAR)
/* new driver ok */
#else
# define V_MEMRAM2_FAR
#endif

#if defined (V_MEMRAM3)
/* new driver ok */
#else
# define V_MEMRAM3
#endif
/* Define of a DESC_CONST_MEM_ABSTRACT*/
#define DESC_CONST_MEM_ABSTRACT                                      const

/* Compile memory model abstraction */
#if defined(DESC_ENABLE_FAR_BUFFER)
/* Ram Pointer to Far Ram */
# define DESC_P2FARRAM(baseType)                                     V_MEMRAM1_FAR baseType V_MEMRAM2_FAR V_MEMRAM3_FAR *
/* DESC_CONSTP2FARRAM is only used as function parameter.
Therefore, DESC_CONST_MEM_ABSTRACT is defined to const and not
explicit mapped to the ROM*/
# define DESC_CONSTP2FARRAM(baseType)                                V_MEMRAM1_FAR baseType V_MEMRAM2_FAR V_MEMRAM3_FAR * DESC_CONST_MEM_ABSTRACT
# define DESC_PUBL_DEF_VAR_FAR(baseType)                             V_MEMRAM0 V_MEMRAM1_FAR baseType V_MEMRAM2_FAR V_MEMRAM3_FAR
# define DESC_PRVT_DEF_VAR_FAR(baseType)                             V_MEMRAM0 static V_MEMRAM1_FAR baseType V_MEMRAM2_FAR
# define DESC_PUBL_DECL_VAR_FAR(baseType)                            V_MEMRAM0 extern V_MEMRAM1_FAR baseType V_MEMRAM2_FAR
#else /*DESC_ENABLE_FAR_BUFFER*/
# define DESC_P2FARRAM(baseType)                                     V_MEMRAM1 baseType V_MEMRAM2 V_MEMRAM3 *
/* DESC_CONSTP2FARRAM is only used as function parameter.
Therefore, DESC_CONST_MEM_ABSTRACT is defined to const and not
explicit mapped to the ROM*/
# define DESC_CONSTP2FARRAM(baseType)                                V_MEMRAM1 baseType V_MEMRAM2 V_MEMRAM3 * DESC_CONST_MEM_ABSTRACT
# define DESC_PUBL_DEF_VAR_FAR(baseType)                             V_MEMRAM0 V_MEMRAM1 baseType V_MEMRAM2 V_MEMRAM3
# define DESC_PRVT_DEF_VAR_FAR(baseType)                             V_MEMRAM0 static V_MEMRAM1 baseType V_MEMRAM2
# define DESC_PUBL_DECL_VAR_FAR(baseType)                            V_MEMRAM0 extern V_MEMRAM1 baseType V_MEMRAM2
#endif

#if defined(DESC_API_CALL_TYPE)
#else
  /* No paging used. */
  #define DESC_API_CALL_TYPE
#endif

#if defined(DESC_API_CALLBACK_TYPE)
#else
  /* No paging used. */
  #define DESC_API_CALLBACK_TYPE
#endif

#if defined(TP_API_CALLBACK_TYPE)
#else
  /* No paging used. */
  #define TP_API_CALLBACK_TYPE
#endif

#if defined(DRV_API_CALLBACK_TYPE)
#else
  /* No paging used. */
  #define DRV_API_CALLBACK_TYPE
#endif

#if defined(DRV_API_CALL_TYPE)
#else
  /* No paging used. */
  #define DRV_API_CALL_TYPE
#endif

/* This magic number provides inter CANdesc generation process consistency check.All CANdesc files must have the same one. */
#define DESC_PUBLIC_INTERFACE_MAGIC_NUMBER                           25928
/* ---  Debug assertion codes  --- */
#define kDescAssertWrongTpTxChannel                                  0x00
#define kDescAssertCanBufferIsNullPointer                            0x01
#define kDescAssertIndexTableInvalidReference                        0x02
#define kDescAssertSvcTableUnreachableItem                           0x03
#define kDescAssertSvcTableInvalidReference                          0x04
#define kDescAssertSvcTableInconsistentNumber                        0x05
#define kDescAssertMissingMainHandler                                0x06
/* Obsolete: 
#define kDescAssertSFMsgTooLong                                      0x07
*/
#define kDescAssertInvalidContextId                                  0x08
#define kDescAssertSvcTableIndexOutOfRange                           0x09
#define kDescAssertSvcInstTableIndexOutOfRange                       0x0A
#define kDescAssertContextIdWasModified                              0x0B
/* Obsolete: 
#define kDescAssertContextPointerWasModified                         0x0C
#define kDescAssertWrongTpRxChannel                                  0x0D
*/
#define kDescAssertProcessingDoneCallAfterResFlushing                0x0E
#define kDescAssertTooLongSingleFrameResponse                        0x0F
/* Obsolete: 
#define kDescAssertIllegalTxModeState                                0x10
*/
#define kDescAssertApplLackOfConfirmation                            0x11
/* Obsolete: 
#define kDescAssertUnconfirmedSecureServiceUsed                      0x12
*/
#define kDescAssertZeroStateValue                                    0x13
/* Obsolete: 
#define kDescAssertSecureServiceFunctionallyRequested                0x14
#define kDescAssertInvalidCanChannel                                 0x15
*/
#define kDescAssertInvalidContextMode                                0x16
#define kDescAssertUnexpectedWriteIntoRingBuffer                     0x17
#define kDescAssertRingBufferWriteExceedsTheResLen                   0x18
/* Obsolete: 
#define kDescAssertIllegalUsageOfRingBufferWithPidListMode           0x19 
#define kDescAssertIllegalUsageOfNegativeResponse                    0x1A
*/
#define kDescAssertDiagnosticBufferOverflow                          0x1B
#define kDescAssertFuncReqWoResMayNotUseRingBuffer                   0x1C
/* Obsolete: 
#define kDescAssertContextChannelRelationLost                        0x1D
*/
#define kDescAssertSchedulerTimerEventWithoutAnyPID                  0x1E
#define kDescAssertSchedulerRingBufferIsActivated                    0x1F
/* Obsolete: 
#define kDescAssertSchedulerWrongContextMode                         0x20
*/
#define kDescAssertUnknownTpTransmissionType                         0x21
#define kDescAssertIllegalAddRequestCount                            0x22
#define kDescAssertNoSidCanBeReportedInIdleMode                      0x23
#define kDescAssertInvalidUsageOfForceRcrRpApi                       0x24
/* Obsolete: 
#define kDescAssertRoeResponderWrongContextMode                      0x25
*/
#define kDescAssertPidResLenToCddDefNotMatched                       0x26
#define kDescAssertPidResLenToCurrLinearFreeSpace                    0x27
#define kDescAssertMissingDataForTransmission                        0x28
#define kDescAssertSchedulerFreeCellNotFound                         0x29
#define kDescAssertInvalidStateParameterValue                        0x2A
#define kDescAssertNoFreeICNChannel                                  0x2B
#define kDescAssertInvalidDescICNClient                              0x2C
#define kDescAssertNoFreeMsgContext                                  0x2D
#define kDescAssertUnExpectedContextWithResponse                     0x2E
#define kDescAssertIllegalCallOfRingBufferCancel                     0x2F
#define kDescAssertIllegalUsageOfRingBufferOnSupprPosRes             0x30
#define kDescAssertWrongFblPosResParameterValue                      0x31 /* former 0xA1 */

#define kDescAssertRoeUnexpectedEventNRC                             0x32
#define kDescAssertRoeUnexpectedEventSid                             0x33
/* Obsolete
#define kDescAssertRoeGeneralTransmissionError                       0x34
#define kDescAssertRoeNumEventsIsEmpty                               0x35
*/
#define kDescAssertRoeUnexpectedEventType                            0x36

#define kDescAssertMemByAddrUnexpectedType                           0x37
#define kDescAssertRoeUnexpectedResultLength                         0x38

/* DescNet assertions numbers */
#define kDescNetAssertWrongIsoTpRxChannel                            0x40
#define kDescNetAssertWrongIsoTpTxChannel                            0x41
#define kDescNetAssertWrongBusType                                   0x42

#define kDescNetAssertIllegalPduId                                   0x43
#define kDescNetAssertIllegalResponseType                            0x44

#define kDescNetAssertUnexpectedLength                               0x45

#define kDescNetAssertUnknownUudtChannel                             0x46

/* DescICNNet assertions numbers */
#define kDescAssertDescIcnIllegalTargetPointer                       0x50


/* Page buffer assertion*/
#define kDescAssertPageBufferTooSmallForResponse                     0x60

/* DEM 4 interface assertion */
#define kDescAssertPendingNotAllowed                                 0x70
#define kDescAssertIllegalState                                      0x71
#define kDescAssertIllegalParameterValue                             0x72
#define kDescAssertConfiguredPagedBufferSizeTooSmall                 0x73

/* -----------------------------------------------------------------------------
    &&&~ Negative response codes
 ----------------------------------------------------------------------------- */

#define kDescNrcGeneralReject                                        0x10
#define kDescNrcServiceNotSupported                                  0x11
#define kDescNrcSubfunctionNotSupported                              0x12
#define kDescNrcInvalidFormat                                        0x13
#define kDescNrcResponseTooLong                                      0x14
#define kDescNrcBusyRepeatRequest                                    0x21
#define kDescNrcConditionsNotCorrect                                 0x22
#define kDescNrcRequestSequenceError                                 0x24
#define kDescNrcNoResponseFromSubnetComponent                        0x25
#define kDescNrcFailurePreventsExecutionOfRequestedAction            0x26
#define kDescNrcRequestOutOfRange                                    0x31
#define kDescNrcAccessDenied                                         0x33
#define kDescNrcInvalidKey                                           0x35
#define kDescNrcExceedNumOfAttempts                                  0x36
#define kDescNrcTimeDelayNotExpired                                  0x37
#define kDescNrcUploadDownloadNotAccepted                            0x70
#define kDescNrcTransferDataSuspended                                0x71
#define kDescNrcGeneralProgrammingFailure                            0x72
#define kDescNrcWrongBlockSequenceCounter                            0x73
#define kDescNrcResponsePending                                      0x78
#define kDescNrcSubfunctionNotSupportedInActiveSession               0x7E
#define kDescNrcServiceNotSupportedInActiveSession                   0x7F
#define kDescNrcRpmTooHigh                                           0x81
#define kDescNrcRpmTooLow                                            0x82
#define kDescNrcEngineIsRunning                                      0x83
#define kDescNrcEngineIsNotRunning                                   0x84
#define kDescNrcEngineRunTimeTooLow                                  0x85
#define kDescNrcTemperatureTooHigh                                   0x86
#define kDescNrcTemperatureTooLow                                    0x87
#define kDescNrcVehicleSpeedTooHigh                                  0x88
#define kDescNrcVehicleSpeedTooLow                                   0x89
#define kDescNrcThrottleSpeedTooHigh                                 0x8A
#define kDescNrcThrottleSpeedTooLow                                  0x8B
#define kDescNrcTransmissionRangeInNeutral                           0x8C
#define kDescNrcTransmissionRangeInGears                             0x8D
#define kDescNrcBrakeSwitchNotClosed                                 0x8F
#define kDescNrcShifterLeverNotInPark                                0x90
#define kDescNrcTorqueConverterClutchLocked                          0x91
#define kDescNrcVoltageTooHigh                                       0x92
#define kDescNrcVoltageTooLow                                        0x93


#define TP_CHANNEL_PARAM_TYPE                                        vuint8
#define TP_CHANNEL_RX_PARAM_NAME                                     tpRxChannel
#define TP_CHANNEL_TX_PARAM_NAME                                     tpTxChannel

#if defined (DESC_USDTNET_ENABLE_MULTI_TP)
/* rx */
# define TP_CHANNEL_RX_FORMAL_PARAM_DEF_ONLY                         TP_CHANNEL_PARAM_TYPE TP_CHANNEL_RX_PARAM_NAME
# define TP_CHANNEL_RX_PARAM_DEF_LOCAL                               TP_CHANNEL_RX_FORMAL_PARAM_DEF_ONLY;
# define TP_CHANNEL_RX_FORMAL_PARAM_DEF_FIRST                        TP_CHANNEL_RX_FORMAL_PARAM_DEF_ONLY,
# define TP_CHANNEL_RX_PARAM_IGNORE_UNREF                            DESC_IGNORE_UNREF_PARAM(TP_CHANNEL_RX_PARAM_NAME)
/* tx */
# define TP_CHANNEL_TX_FORMAL_PARAM_DEF_ONLY                         TP_CHANNEL_PARAM_TYPE TP_CHANNEL_TX_PARAM_NAME
# define TP_CHANNEL_TX_PARAM_DEF_LOCAL                               TP_CHANNEL_TX_FORMAL_PARAM_DEF_ONLY;
# define TP_CHANNEL_TX_FORMAL_PARAM_DEF_FIRST                        TP_CHANNEL_TX_FORMAL_PARAM_DEF_ONLY,
# define TP_CHANNEL_TX_PARAM_IGNORE_UNREF                            DESC_IGNORE_UNREF_PARAM(TP_CHANNEL_TX_PARAM_NAME)
#else
/* rx */
# define TP_CHANNEL_RX_FORMAL_PARAM_DEF_ONLY                         void
# define TP_CHANNEL_RX_PARAM_DEF_LOCAL
# define TP_CHANNEL_RX_FORMAL_PARAM_DEF_FIRST
# define TP_CHANNEL_RX_PARAM_IGNORE_UNREF
/* tx */
# define TP_CHANNEL_TX_FORMAL_PARAM_DEF_ONLY                         void
# define TP_CHANNEL_TX_PARAM_DEF_LOCAL
# define TP_CHANNEL_TX_FORMAL_PARAM_DEF_FIRST
# define TP_CHANNEL_TX_PARAM_IGNORE_UNREF
#endif

#define DESC_USDTNET_CONST_MEM_ABSTRACT                              const
/* Compile memory model abstraction */
#if defined(DESC_USDTNET_ENABLE_FAR_BUFFER)
/* Ram Pointer to Far Ram */
# define DESC_USDTNET_P2FARRAM(baseType)                             V_MEMRAM1_FAR baseType V_MEMRAM2_FAR V_MEMRAM3_FAR *
/* DESC_CONSTP2FARRAM is not used until now.
DESC_USDTNET_CONST_MEM_ABSTRACT is defined to const and not
explicit mapped to the ROM*/
# define DESC_USDTNET_CONSTP2FARRAM(baseType)                        V_MEMRAM1_FAR baseType V_MEMRAM2_FAR V_MEMRAM3_FAR * DESC_USDTNET_CONST_MEM_ABSTRACT
# define DESC_USDTNET_PUBL_DEF_VAR_FAR(baseType)                     V_MEMRAM0 V_MEMRAM1_FAR baseType V_MEMRAM2_FAR V_MEMRAM3_FAR
# define DESC_USDTNET_PRVT_DEF_VAR_FAR(baseType)                     V_MEMRAM0 static V_MEMRAM1_FAR baseType V_MEMRAM2_FAR
# define DESC_USDTNET_PUBL_DECL_VAR_FAR(baseType)                    V_MEMRAM0 extern V_MEMRAM1_FAR baseType V_MEMRAM2_FAR
#else /*DESC_USDTNET_ENABLE_FAR_BUFFER*/
# define DESC_USDTNET_P2FARRAM(baseType)                             V_MEMRAM1 baseType V_MEMRAM2 V_MEMRAM3 *
/* DESC_CONSTP2FARRAM is not used until now.
DESC_USDTNET_CONST_MEM_ABSTRACT is defined to const and not
explicit mapped to the ROM*/
# define DESC_USDTNET_CONSTP2FARRAM(baseType)                        V_MEMRAM1 baseType V_MEMRAM2 V_MEMRAM3 * DESC_USDTNET_CONST_MEM_ABSTRACT
# define DESC_USDTNET_PUBL_DEF_VAR_FAR(baseType)                     V_MEMRAM0 V_MEMRAM1 baseType V_MEMRAM2 V_MEMRAM3
# define DESC_USDTNET_PRVT_DEF_VAR_FAR(baseType)                     V_MEMRAM0 static V_MEMRAM1 baseType V_MEMRAM2
# define DESC_USDTNET_PUBL_DECL_VAR_FAR(baseType)                    V_MEMRAM0 extern V_MEMRAM1 baseType V_MEMRAM2
#endif

#define kDescNumCommChannels                                         1
#define kDescNumContexts                                             1
#define kDescPrimBufferLen                                           300
#if defined (DESC_ENABLE_MULTI_CHANNEL_SUPPORT)
# define DESC_COMM_CHANNEL_FORMAL_PARAM_DEF_ONLY                     vuint8_least commChannel
# define DESC_COMM_CHANNEL_FORMAL_PARAM_DEF_FIRST                    DESC_COMM_CHANNEL_FORMAL_PARAM_DEF_ONLY,
# define DESC_COMM_CHANNEL_PARAM_VALUE                               commChannel
# define DESC_COMM_CHANNEL_PARAM_ONLY                                commChannel
# define DESC_COMM_CHANNEL_PARAM_FIRST                               DESC_COMM_CHANNEL_PARAM_ONLY,
# define DESC_COMM_CHANNEL_LOCAL_PARAM_DEF                           DESC_COMM_CHANNEL_FORMAL_PARAM_DEF_ONLY;
# define DESC_COMM_CHANNEL_PARAM_VALUE_INIT                          DESC_COMM_CHANNEL_PARAM_VALUE = kDescNumCommChannels
# define DESC_COMM_CHANNEL_PARAM_VALUE_DEC                           DESC_COMM_CHANNEL_PARAM_VALUE--
# define DESC_COMM_CHANNEL_LOOP                                      while(commChannel != 0)
# define DESC_COMM_CHANNEL_PARAM_WRAP_ONLY(channel)                  (channel)
# define DESC_COMM_CHANNEL_PARAM_WRAP_INDEX(channel)                 (channel)
#else
# define DESC_COMM_CHANNEL_FORMAL_PARAM_DEF_ONLY                     void
# define DESC_COMM_CHANNEL_FORMAL_PARAM_DEF_FIRST
# define DESC_COMM_CHANNEL_PARAM_ONLY
# define DESC_COMM_CHANNEL_PARAM_FIRST
# define DESC_COMM_CHANNEL_PARAM_VALUE                               0
# define DESC_COMM_CHANNEL_LOCAL_PARAM_DEF
# define DESC_COMM_CHANNEL_PARAM_VALUE_INIT
# define DESC_COMM_CHANNEL_PARAM_VALUE_DEC
# define DESC_COMM_CHANNEL_LOOP
# define DESC_COMM_CHANNEL_PARAM_WRAP_ONLY(channel)
# define DESC_COMM_CHANNEL_PARAM_WRAP_INDEX(channel)                 0
#endif

/* If more than one parallel request may be processed - use real context */
#if (kDescNumContexts > 1)
# define DESC_CONTEXT_PARAM_TYPE_ONLY                                vuint8                                                /* Used in CANdesc for function prototypes */
# define DESC_CONTEXT_PARAM_TYPE_FIRST                               vuint8,                                               /* Used in CANdesc for function prototypes */
# define DESC_CONTEXT_PARAM_VALUE                                    iContext                                              /* Used in CANdesc context accesses as "g_descMsgContext[DESC_CONTEXT_PARAM_VALUE].reqDataLen" in case the parameter is defined using the other optimization macros */
# define DESC_CONTEXT_PARAM_ONLY                                     iContext                                              /* Used in application/CANdesc functions as DescProcessingDone(DESC_CONTEXT_PARAM_ONLY), in case the parameter is defined using the other optimization macros */
# define DESC_CONTEXT_PARAM_FIRST                                    iContext,                                             /* Used in application/CANdesc functions as DescSetNegResponse(DESC_CONTEXT_PARAM_FIRST, kDescNrcCode), in case the parameter is defined using the other optimization macros */
# define DESC_CONTEXT_FORMAL_PARAM_DEF_ONLY                          DESC_CONTEXT_PARAM_TYPE_ONLY DESC_CONTEXT_PARAM_ONLY  /* Used in application/CANdesc functions as DescProcessingDone(DESC_CONTEXT_FORMAL_PARAM_DEF_ONLY);*/
# define DESC_CONTEXT_PARAM_DEF_LOCAL                                DESC_CONTEXT_FORMAL_PARAM_DEF_ONLY;                   /* Used in functions as a local variable definition so it can be used with all other optimization macros */
# define DESC_CONTEXT_FORMAL_PARAM_DEF_FIRST                         DESC_CONTEXT_PARAM_TYPE_ONLY DESC_CONTEXT_PARAM_ONLY, /* Used in application/CANdesc functions as ApplDescPostHandler(DESC_CONTEXT_FORMAL_PARAM_DEF_FIRST vuint8 status) */
# define DESC_CONTEXT_PARAM_WRAPPER_ONLY(contextConst)               contextConst                                          /* Used in call backs as DescProcessingDone(DESC_CONTEXT_PARAM_WRAPPER_ONLY(pMsgContext->iContext)) as universal ignore parameter macro */
# define DESC_CONTEXT_PARAM_WRAPPER_FIRST(contextConst)              contextConst,                                         /* Used in call backs as DescSetNegResponse(DESC_CONTEXT_PARAM_WRAPPER_FIRST(pMsgContext->iContext) kDescNrcConditionsNotCorrect) as universal ignore parameter macro */
# define DESC_CONTEXT_PARAM_WRAPPER_INDEX(contextConst)              contextConst                                          /* Used for accessing context specific tables */
# define DESC_CONTEXT_PARAM_DUMMY_USE                                DESC_IGNORE_UNREF_PARAM(DESC_CONTEXT_PARAM_ONLY)      /* Used to avoid compiler warnings for unreferenced variables */
#else
# define DESC_CONTEXT_PARAM_TYPE_ONLY                                void
# define DESC_CONTEXT_PARAM_TYPE_FIRST
# define DESC_CONTEXT_PARAM_VALUE                                    ((vuint8)0)
# define DESC_CONTEXT_PARAM_ONLY
# define DESC_CONTEXT_PARAM_FIRST
# define DESC_CONTEXT_FORMAL_PARAM_DEF_ONLY                          void
# define DESC_CONTEXT_FORMAL_PARAM_DEF_FIRST
# define DESC_CONTEXT_PARAM_DEF_LOCAL
# define DESC_CONTEXT_PARAM_WRAPPER_ONLY(contextConst)
# define DESC_CONTEXT_PARAM_WRAPPER_FIRST(contextConst)
# define DESC_CONTEXT_PARAM_WRAPPER_INDEX(contextConst)              0
# define DESC_CONTEXT_PARAM_DUMMY_USE
#endif

/* Diag connection number (in case of TPMC with DYN_ID usage) */
#if ! defined(kDescDiagConnection)
# define kDescDiagConnection                                         ((vuint8)0xF0)
#endif

#if ! defined(kDescDiagObdConnection)
# define kDescDiagObdConnection                                      ((vuint8)0xF1)
#endif

#if ! defined(kDescDiagAddConnection)
# define kDescDiagAddConnection                                      ((vuint8)0xF2)
#endif

/* -- Context specific activity states -- */
#define kDescContextIdle                                             ((DescContextActivity)0x00)
#define kDescContextActiveRxBegin                                    ((DescContextActivity)0x01)
#define kDescContextActiveRxEnd                                      ((DescContextActivity)0x02)
#define kDescContextActiveProcess                                    ((DescContextActivity)0x04)
#define kDescContextActiveProcessEnd                                 ((DescContextActivity)0x08)
#define kDescContextActiveTxReady                                    ((DescContextActivity)0x10)
#define kDescContextActiveTx                                         ((DescContextActivity)0x20)
#define kDescContextActivePostProcess                                ((DescContextActivity)0x40)

/* Any transmission is currently active */
#define kDescContextActiveRx                                         (DescContextActivity)(kDescContextActiveRxBegin | kDescContextActiveRxEnd)


/* ---  Addressing methods  --- */
#define kDescPhysReq                                                 ((vuint8)0x01)
#define kDescFuncReq                                                 ((vuint8)0x02)

#define kDescPrimContext                                             (vuint8) 0
#define kDescSecContext                                              (vuint8) 0
#define kDescConsecutiveFrameSize                                    63
#define kDescFirstFrameSize                                          62
#define kDescCallCycleUs                                             10000
#define kDescS1TimerTicks                                            500
/* P2 timeout in DescTask cycles. */
#define kDescP2Ticks                                                 4
/* P2Ex timeout in DescTask cycles. */
#define kDescP2StarTicks                                             499
/* P2 timeout time in 1ms resolution. */
#define kDescTimeValueP2                                             50
/* P2Ex timeout time in 10 ms resolution. */
#define kDescTimeValueP2Star                                         500
#define kDescStateValueInvalid                                       (DescStateGroup)0xFFFF

/* CANdesc supports at maximum as many states pro StateGroup as given below: */
#define kDescMaxAllowedNumStates                                     16
#define kDescNumStateSession                                         3
#define kDescStateSessionDefault                                     ((DescStateGroup)0x01)
#define kDescStateSessionProgramming                                 ((DescStateGroup)0x02)
#define kDescStateSessionExtended                                    ((DescStateGroup)0x04)
#define kDescNumStateSecurityAccess                                  5
#define kDescStateSecurityAccessLocked                               ((DescStateGroup)0x01)
#define kDescStateSecurityAccessUnlockedL1                           ((DescStateGroup)0x02)
#define kDescStateSecurityAccessUnlocked_L2                          ((DescStateGroup)0x04)
#define kDescStateSecurityAccessUnlocked_L4                          ((DescStateGroup)0x08)
#define kDescStateSecurityAccessUnlocked_L5                          ((DescStateGroup)0x10)
/* Error free diagnsotic request process */
#define kDescNrcNone                                                 ((DescNegResCode)0x00)
#define kDescExtNrcNone                                              ((vuint16)0x0000)

/* ---  Post handler status masks --- */
#define kDescPostHandlerStateOk                                      ((vuint8)0x01)
#define kDescPostHandlerStateNegResSent                              ((vuint8)0x02)
#define kDescPostHandlerStateTxFailed                                ((vuint8)0x04)

/* Default BOOT state */
#define kDescPowerOnInitParam                                        (DescInitParam)0

/**************************/
/* Communication control  */
/**************************/
/* Communication control */
#define kDescCommControlStateEnable                                  0x01
#define kDescCommControlStateDisable                                 0x00

/* CAN channel values */
#define kDescCommControlSubNetNumAll                                 0x00
#define kDescCommControlSubNetNumRx                                  0x0F

#define kDescCommControlSubNetNum01                                  0x01
#define kDescCommControlSubNetNum02                                  0x02
#define kDescCommControlSubNetNum03                                  0x03
#define kDescCommControlSubNetNum04                                  0x04
#define kDescCommControlSubNetNum05                                  0x05
#define kDescCommControlSubNetNum06                                  0x06
#define kDescCommControlSubNetNum07                                  0x07
#define kDescCommControlSubNetNum08                                  0x08
#define kDescCommControlSubNetNum09                                  0x09
#define kDescCommControlSubNetNum10                                  0x0A
#define kDescCommControlSubNetNum11                                  0x0B
#define kDescCommControlSubNetNum12                                  0x0C
#define kDescCommControlSubNetNum13                                  0x0D
#define kDescCommControlSubNetNum14                                  0x0E


/* No CAN channel shall be manipulated */
#define kDescCommControlCanChNone                                    0x0F

/* The corresponding CAN channel shall be disabled/enabled */

#define kDescCommControlCanCh01                                      0x00
#define kDescCommControlCanCh02                                      0x01
#define kDescCommControlCanCh03                                      0x02
#define kDescCommControlCanCh04                                      0x03
#define kDescCommControlCanCh05                                      0x04
#define kDescCommControlCanCh06                                      0x05
#define kDescCommControlCanCh07                                      0x06
#define kDescCommControlCanCh08                                      0x07
#define kDescCommControlCanCh09                                      0x08
#define kDescCommControlCanCh10                                      0x09
#define kDescCommControlCanCh11                                      0x0A
#define kDescCommControlCanCh12                                      0x0B
#define kDescCommControlCanCh13                                      0x0C
#define kDescCommControlCanCh14                                      0x0D

/* Message groups */
#define kDescCommControlMsgAppl                                      0x01
#define kDescCommControlMsgNm                                        0x02
#define kDescCommControlMsgTypeAll                                   ((vuint8) (kDescCommControlMsgAppl | kDescCommControlMsgNm))
#define kDescMaxNumberOfAttempts                                     3
#define kDescSecureTimer                                             1000
#define kDescPowerOnSecureTimer                                      0
#if defined (DESC_ENABLE_SA_LEVEL_SPECIFIC)
# define DESC_LEVEL_FORMAL_PARAM_DEF_ONLY                            DescStateGroup securityLevel
# define DESC_LEVEL_FORMAL_PARAM_DEF_FIRST                           DescStateGroup securityLevel,
# define DESC_LEVEL_CONTEXT_PARAM_VALUE                              securityLevel
# define DESC_LEVEL_CONTEXT_PARAM_VALUE_SET                          securityLevel
# define DESC_LEVEL_CONTEXT_PARAM_VALUE_SET_FIRST                    securityLevel,
#else
# define DESC_LEVEL_FORMAL_PARAM_DEF_ONLY                            void
# define DESC_LEVEL_FORMAL_PARAM_DEF_FIRST
# define DESC_LEVEL_CONTEXT_PARAM_VALUE                              ((vuint8)1)
# define DESC_LEVEL_CONTEXT_PARAM_VALUE_SET
# define DESC_LEVEL_CONTEXT_PARAM_VALUE_SET_FIRST
#endif
#if defined (DESC_ENABLE_REPORT_ATT_CNTR_STATE)
# define kDescSecAccAttCtrChgOnTimeExpire                            (DescSecAccAttCtrChgEvType)0
# define kDescSecAccAttCtrChgOnTooManyInvalidKeys                    (DescSecAccAttCtrChgEvType)1
# define kDescSecAccAttCtrChgOnInvalidKey                            (DescSecAccAttCtrChgEvType)2
# define kDescSecAccAttCtrChgOnValidKey                              (DescSecAccAttCtrChgEvType)3
# define kDescSecAccAttCtrChgOnTooManySeedsWithoutKey                (DescSecAccAttCtrChgEvType)4
# define kDescSecAccAttCtrChgOnSeedWithoutKey                        (DescSecAccAttCtrChgEvType)5
# define kDescSecAccAttCtrChgOnApplRequest                           (DescSecAccAttCtrChgEvType)6
# define kDescSecAccAttCtrChgOnKeyLengthInvalid                      (DescSecAccAttCtrChgEvType)7
# define kDescSecAccAttCtrChgOnKeyWrongLevel                         (DescSecAccAttCtrChgEvType)8
# define kDescSecAccAttCtrChgInvalid                                 (DescSecAccAttCtrChgEvType)255
#endif

#define kDescNumMaxPidList                                           5


/* -----------------------------------------------------------------------------
    &&&~ Datatype definitions
 ----------------------------------------------------------------------------- */

/* CANdesc internal boolean type (used for better code readability and code optimum) */
typedef vboolean DescBool;
#if defined (DESC_USE_ANSI_C_BIT_TYPE)
typedef unsigned int DescBitType;
#else
typedef vbittype     DescBitType;
#endif


typedef struct t_AddrInfoIsoTpTag
{
  vuint8  Dummy;

#if defined (TP_ENABLE_NORMAL_ADDRESSING)       || \
    defined (TP_ENABLE_MIXED_11_ADDRESSING)
# if defined (TP_ENABLE_DYNAMIC_CHANNELS)
  vuint16 TransmitID;
  vuint16 ReceiveID;
# else
# endif
#endif
#if (TP_USE_EXTENDED_ADDRESSING == kTpOn) || \
    defined (TP_ENABLE_NORMAL_FIXED_ADDRESSING) || \
    defined(TP_FUNC_ENABLE_EXTENDED_ADDRESSING) || \
    defined (TP_ENABLE_MIXED_29_ADDRESSING)
  vuint8 SourceAddress;
  vuint8 TargetAddress;
#endif
#if ( kCanNumberOfChannels > 1 ) /* more than one canChannel ? */
  vuint8 CanChannel;
#endif
#if (TP_USE_EXTENDED_ADDRESSING == kTpOn)
# if (TP_USE_MULTIPLE_BASEADDRESS == kTpOn)
  vuint16 BaseAddress;
# endif
#endif
} t_AddrInfoIsoTp;

/* USDT Net result return type */
typedef enum
{
  kDescUsdtNetworkOk = 0,
  kDescUsdtNetworkFailed = 1,
  kDescUsdtNetBufferUnderrun = 2,
  kDescUsdtNetworkAbort = 3
} t_descUsdtNetResult;

/* CANdesc internal handle type */
typedef vuint8 t_descHandle;

/* USDT Net bus handle type */
typedef vuint8 t_descUsdtNetBusHandle;

typedef enum
{
  kDescUsdtNetReqTypePhysical,
  kDescUsdtNetReqTypeFunctional,
  kDescUsdtNetReqTypeInternal
} t_descUsdtNetReqType;

typedef enum
{
  kDescUsdtResponseNone,
  kDescUsdtResponsePositive,
  kDescUsdtResponseRingBuffer,
  kDescUsdtResponseNegative,
  kDescUsdtResponseNegativeRCR_RP,
  kDescUsdtResponseNegativeApplRCR_RP,
  kDescUsdtResponseRoe,
  kDescUsdtResponsePeriodic,
  kDescUsdtResponseSpontaneous,
  kDescUsdtResponseSpontaneousAppl
} t_descUsdtNetResType;


typedef DESC_USDTNET_P2FARRAM(vuint8) DescUsdtNetMsg;

typedef enum
{
  kDescUsdtNetBusTypeNone, 
  kDescUsdtNetBusTypeIsoTp
} t_descUsdtNetBusType;
typedef union t_descUsdtNetAddrInfoTag
{
  t_AddrInfoIsoTp isoTp;
} t_descUsdtNetAddrInfo;
typedef struct
{
  vuint8                comChannel; /* relevant only on multi-channel systems (e.g. multi CAN channels) */
  vuint8                testerId;   /* in some cases the tester address (ID) is from importance - store here if you have it */
  t_descUsdtNetBusType  busType;        /* from DescUsdtNetDispatcher.h */
  t_descUsdtNetAddrInfo addressingInfo; /* from DescUsdtNetDispatcher.h */
#if defined (DESC_USDTNET_ENABLE_DYNAMIC_BUFFER_LENGTH)
  vuint16               availBufferLength;
#endif
#if defined(TP_ENABLE_DYNAMIC_CHANNELS) && defined(TP_ENABLE_CANFD)
  vuint8                canType; /* CAN or CAN-FD */
#endif
} t_descUsdtNetBus;

typedef enum
{
  kDescSendFblPosRespEcuHardReset,
  kDescSendFblPosRespDscDefault
} t_descFblPosRespType;

typedef vuint8                                        DescContextActivity;
typedef vuint8                                        DescMsgItem;

typedef DESC_P2FARRAM(DescMsgItem)                    DescMsg;
typedef DESC_CONSTP2FARRAM(DescMsgItem)               DescConstPtr;
typedef vuint16                                       DescMsgLen;

#if (kDescNumCommChannels <= 8)
typedef vuint8      DescComChannelBitMaskMemType;
typedef vuint8_least    DescComChannelBitMaskOptType;
#elif (kDescNumCommChannels <= 16)
typedef vuint16      DescComChannelBitMaskMemType;
typedef vuint16_least    DescComChannelBitMaskOptType;
#else
# error "Too many CAN-channels!!!"
#endif

/* Some groups can have more than 8 states */
typedef unsigned int DescStateGroup;

/* Negative response codes is normally single Byte */
typedef vuint8 DescNegResCode;
/* Additional information about a request */
typedef struct
{
  DescBitType reqType   :2; /* 0x01: Phys 0x02: Func */
  DescBitType resOnReq  :2; /* 0x01: Phys 0x02: Func */
  DescBitType suppPosRes:1; /* 0x00: No   0x02: Yes  */
} DescMsgAddInfo;

/* Context information of a request */
typedef struct
{
  DescMsg             reqData;
  DescMsgLen          reqDataLen;
  DescMsg             resData;
  DescMsgLen          resDataLen;
  DescMsgAddInfo      msgAddInfo;
  DESC_CONTEXT_PARAM_DEF_LOCAL /* No iContext in non-parallel system */
  t_descUsdtNetBus    busInfo;
} DescMsgContext;

/* Main handler function pointer type */
typedef void DESC_API_CALL_TYPE (*DescMainHandler)     (DescMsgContext*);

/* not used */
typedef vuint8 DescInitParam;

/**************************/
/* Communication control  */
/**************************/
typedef struct
{
#if defined (DESC_ENABLE_RX_COMM_CONTROL)
  DescBitType  dummy_gap           :2; /* Alignment gap */
  DescBitType  rxPathState         :2; /* Enable/Disable */
#endif
  DescBitType  txPathState         :2; /* Enable/Disable */
  DescBitType  msgTypes            :2; /* Appl OR/AND NM */
  DescBitType  subNetNumber        :4; /* Subnetwork channel number */
  DescBitType  reqCommChannel      :4; /* up to 15 CAN channels */
  DescBitType  commCtrlChannel     :4; /* up to 15 CAN channels (former commChannelCtrlTx)*/
}DescOemCommControlInfo;


#if defined (DESC_ENABLE_REPORT_ATT_CNTR_STATE)
typedef vuint8 DescSecAccAttCtrChgEvType;
#endif

typedef enum
{
  kDescSaStatusOk = 0,
  kDescSaStatusNok = 1
}DescSecurityAccessStatus;

typedef struct
{
  DescStateGroup            securityLevel;
  DescSecurityAccessStatus  status;
  vuint8                    dataLen;
  DescMsg                   dataPtr;
#if defined (DESC_ENABLE_SECURITY_ACCESS_DATA)
  vuint16                   securityAccessDataRecordLength;
  DescMsg                   dataPtrSecurityAccessData;
#endif
  DESC_CONTEXT_PARAM_DEF_LOCAL /* No iContext in non-parallel system */
} DescSecurityAccessContext;



/* -----------------------------------------------------------------------------
    &&&~ Function prototypes
 ----------------------------------------------------------------------------- */

#if defined (TP_ENABLE_DYNAMIC_CHANNELS)
/* Rx path phys */
TP_MEMORY_MODEL_DATA vuint8* TP_API_CALLBACK_TYPE DescGetBuffer(TP_CHANNEL_RX_FORMAL_PARAM_DEF_FIRST vuint32 dataLength);
void    TP_API_CALLBACK_TYPE DescRxErrorIndication(TP_CHANNEL_RX_FORMAL_PARAM_DEF_FIRST vuint8 status);
void    TP_API_CALLBACK_TYPE DescPhysReqInd(TP_CHANNEL_RX_FORMAL_PARAM_DEF_FIRST vuint32 dataLen);

/* Rx path func */
# if defined(TP_FUNC_ENABLE_RECEPTION) && \
     !defined (TP_ENABLE_EXTENDED_ADDRESSING)
TP_MEMORY_MODEL_DATA vuint8* TP_API_CALLBACK_TYPE DescGetFuncBuffer(vuint16 dataLength);
void TP_API_CALLBACK_TYPE DescFuncReqInd(vuint16 dataLen);
# endif

/* Tx path */
vuint8 TP_API_CALLBACK_TYPE DescCopyToCAN(TpCopyToCanInfoStructPtr infoStruct);
vuint8 TP_API_CALLBACK_TYPE DescTxErrorIndication(TP_CHANNEL_TX_FORMAL_PARAM_DEF_FIRST vuint8 status);
void   TP_API_CALLBACK_TYPE DescConfirmation(TP_CHANNEL_TX_FORMAL_PARAM_DEF_FIRST vuint8 status);
#endif

/* CAN-type handling in TP */
#if defined(TP_ENABLE_DYNAMIC_CHANNELS) && defined(TP_ENABLE_CANFD)
  vuint8 DescGetCanType();
#endif


#if defined (DESC_ENABLE_SPONTANEOUS_RES)
/* ---- Extended functionality ---- */
DescBool DescSendSpontaneousResponse(DescMsg resData, DescMsgLen resLen, t_descUsdtNetBus* pBusInfo, t_descUsdtNetResType repType);
#endif

void DESC_API_CALL_TYPE DescSendPosRespFBL(t_descFblPosRespType posRespSId);

/* Reports the current diagnostic activity state (e.g. Idle, ActiveRx, ActiveProcess, ActiveTx.*/
DescContextActivity DESC_API_CALL_TYPE DescGetActivityState(DESC_CONTEXT_FORMAL_PARAM_DEF_ONLY);

#if defined (DESC_ENABLE_ACCESS_TESTER_ADDRESS_API)
vuint8 DESC_API_CALL_TYPE DescGetTesterAddress(DESC_CONTEXT_FORMAL_PARAM_DEF_ONLY);
#endif

/*Get access to the current communication parameters */
t_descUsdtNetBus* DESC_API_CALL_TYPE DescGetCurrentBusInfo (DESC_CONTEXT_FORMAL_PARAM_DEF_ONLY);

#if defined (DESC_ENABLE_FORCE_RCR_RP)
/* Force CANdesc to send RCR-RP response */
void DESC_API_CALL_TYPE DescForceRcrRpResponse(DESC_CONTEXT_FORMAL_PARAM_DEF_ONLY);
#endif

#if defined (DESC_ENABLE_AUTO_STATES)
/* If needed - reset the whole state machine (only the states defined in the CDD!!!) */
void DESC_API_CALL_TYPE DescStateInit(void);
#endif

DescStateGroup DESC_API_CALL_TYPE DescGetStateSession(void);
void DESC_API_CALL_TYPE DescSetStateSession(DescStateGroup descState);
DescStateGroup DESC_API_CALL_TYPE DescGetStateSecurityAccess(void);
void DESC_API_CALL_TYPE DescSetStateSecurityAccess(DescStateGroup descState);
#if defined(DESC_ENABLE_AUTO_STATES)
/* Converts session id (sub-function) to session state */
DescStateGroup DESC_API_CALL_TYPE DescGetSessionStateOfSessionId(DescMsgItem sessionId);
/* Converts session state to session id (sub-function) */
DescMsgItem DESC_API_CALL_TYPE DescGetSessionIdOfSessionState(DescStateGroup sessionState);
/* Get access to the session specific timings */
void DESC_API_CALL_TYPE DescGetSessionTimings(DescStateGroup sessionState, vuint16* p2Time_1ms, vuint16* p2ExTime_10ms);
#endif

#if defined (DESC_ENABLE_MAINHANDLER_MULTICALL)
/* Use this function if you want your application to be polled for a certain service */
void DESC_API_CALL_TYPE DescStartRepeatedServiceCall(DESC_CONTEXT_FORMAL_PARAM_DEF_FIRST DescMainHandler mainHandler);
#endif
/* Activate linear response transmission */
void DESC_API_CALL_TYPE DescProcessingDone(DESC_CONTEXT_FORMAL_PARAM_DEF_ONLY);
/* Set a diagnostic error */
void DESC_API_CALL_TYPE DescSetNegResponse(DESC_CONTEXT_FORMAL_PARAM_DEF_FIRST DescNegResCode errorCode);
#if defined(DESC_ENABLE_GENERIC_USER_SERVICE_SUPPORT)
/* Returns the current service's Sid */
DescMsgItem DESC_API_CALL_TYPE DescGetServiceId(DESC_CONTEXT_FORMAL_PARAM_DEF_ONLY);
#endif

/* Initilize the CANdesc on PowerOnReset using this function */
void DESC_API_CALL_TYPE DescInitPowerOn(DescInitParam initParam);
/* Initilize the CANdesc if needed during the ECU  runtime using this function (status reset) */
void DESC_API_CALL_TYPE DescInit(DescInitParam initParam);

/* DescTask function must be call cyclically in the specified period of time */
void DESC_API_CALL_TYPE DescTask(void);

void DESC_API_CALL_TYPE DescTimerTask(void);
void DESC_API_CALL_TYPE DescStateTask(void);

/* Returns true if the positive response will be supressed. */
DescBool DESC_API_CALL_TYPE DescIsSuppressPosResBitSet(DESC_CONTEXT_FORMAL_PARAM_DEF_ONLY);

/* Confirmation for seed generation */
void DescSecurityAccessSeedReady(DESC_CONTEXT_FORMAL_PARAM_DEF_ONLY);
/* Confirmation for key validation */
void DescSecurityAccessKeyChecked(DESC_CONTEXT_FORMAL_PARAM_DEF_ONLY);

#if defined (DESC_ENABLE_SA_TIMER_AND_COUNTER)
/* Attempt counter access */
vuint8 DescGetAttemptCounterValue(DESC_LEVEL_FORMAL_PARAM_DEF_ONLY);
void DescSetAttemptCounterValue(DESC_LEVEL_FORMAL_PARAM_DEF_FIRST vuint8 value);

# if defined (DESC_ENABLE_START_SA_TIMER_EXTERN)
void DescStartSecureTimer(DESC_LEVEL_FORMAL_PARAM_DEF_ONLY);
void DescStartSecureTimerValue(DESC_LEVEL_FORMAL_PARAM_DEF_FIRST vuint16 value);
# endif
#endif



/* -----------------------------------------------------------------------------
    &&&~ ROM definitions
 ----------------------------------------------------------------------------- */

/* Version information */
V_MEMROM0 extern V_MEMROM1 vuint8 V_MEMROM2 g_descMainVersion;
V_MEMROM0 extern V_MEMROM1 vuint8 V_MEMROM2 g_descSubVersion;
V_MEMROM0 extern V_MEMROM1 vuint8 V_MEMROM2 g_descBugFixVersion;



/* -----------------------------------------------------------------------------
    &&&~ Macro definitions
 ----------------------------------------------------------------------------- */

#if defined (DESC_ENABLE_FAR_BUFFER)
/* Copy RAM->FAR RAM */
# define DescCopyNByteRAM(t,s,l)                                     (VStdMemCpyRamToFarRam((t),(s),(l)))
/* Copy ROM->FAR RAM */
# define DescCopyNByteROM(t,s,l)                                     (VStdMemCpyRomToFarRam((t),(s),(l)))

# define DescMsgCopyRamToRam(t,s,l)                                  (VStdMemCpyRamToRam((t),(s),(l)))
# define DescMsgCopyFarRamToRam(t,s,l)                               (VStdMemCpyFarRamToRam((t),(s),(l)))
# define DescMsgCopyRamToFarRam(t,s,l)                               (VStdMemCpyRamToFarRam((t),(s),(l)))
# define DescMsgCopyFarRamToFarRam(t,s,l)                            (VStdMemCpyFarRamToFarRam((t),(s),(l)))
# define DescMsgCopyRomToRam(t,s,l)                                  (VStdMemCpyRomToRam((t),(s),(l)))
# define DescMsgCopyRomToFarRam(t,s,l)                               (VStdMemCpyRomToFarRam((t),(s),(l)))
#else
/* TMS320 specifics */
# if defined (VStdMemCpyRamToRamElement)
#  define DescWrapCpyRamToRam(t,s,l)                                 (VStdMemCpyRamToRamElement((t),(s),(l)))
#  define DescWrapCpyRomToRam(t,s,l)                                 (VStdMemCpyRomToRamElement((t),(s),(l)))
# else
#  define DescWrapCpyRamToRam(t,s,l)                                 (VStdMemCpyRamToRam((t),(s),(l)))
#  define DescWrapCpyRomToRam(t,s,l)                                 (VStdMemCpyRomToRam((t),(s),(l)))
# endif
/* Copy RAM->RAM */
# define DescCopyNByteRAM(t,s,l)                                     (DescWrapCpyRamToRam((t),(s),(l)))
/* Copy ROM->RAM */
# define DescCopyNByteROM(t,s,l)                                     (DescWrapCpyRomToRam((t),(s),(l)))

# define DescMsgCopyRamToRam(t,s,l)                                  (DescWrapCpyRamToRam((t),(s),(l)))
# define DescMsgCopyFarRamToRam(t,s,l)                               (DescWrapCpyRamToRam((t),(s),(l)))
# define DescMsgCopyRamToFarRam(t,s,l)                               (DescWrapCpyRamToRam((t),(s),(l)))
# define DescMsgCopyFarRamToFarRam(t,s,l)                            (DescWrapCpyRamToRam((t),(s),(l)))
# define DescMsgCopyRomToRam(t,s,l)                                  (DescWrapCpyRomToRam((t),(s),(l)))
# define DescMsgCopyRomToFarRam(t,s,l)                               (DescWrapCpyRomToRam((t),(s),(l)))
#endif

#define DescSendApplSpontaneousResponse(d,l,b)                       (DescSendSpontaneousResponse((d), (l), (b) , (kDescUsdtResponseSpontaneousAppl)))

/* Global initialization of the state machine */
#if defined (DESC_ENABLE_AUTO_STATES)
/* Func prototype is used */
#else
# define DescStateInit()                                             /* Not used */
#endif

/* Data assemble/deassemble macros */
/* compose from byte stream a 16 bit data */
#define DescMake16Bit(hiByte,loByte)                                 ((vuint16)((((vuint16)(hiByte))<<8)| \
                                                                     ((vuint16)(loByte))))
/* compose from byte stream a 32 bit data */
#define DescMake32Bit(hiHiByte,hiLoByte,loHiByte,loLoByte)           ((vuint32)((((vuint32)(hiHiByte))<<24)| \
                                                                     (((vuint32)(hiLoByte))<<16)| \
                                                                     (((vuint32)(loHiByte))<<8) | \
                                                                     ((vuint32)(loLoByte))))
/* decompose 16 bit data in byte stream */
#define DescGetHiByte(data)                                          ((vuint8)(((vuint16)(data))>>8))
#define DescGetLoByte(data)                                          ((vuint8)(data))

/* decompose 32 bit data in byte stream */
#define DescGetHiHiByte(data)                                        ((vuint8)(((vuint32)(data))>>24))
#define DescGetHiLoByte(data)                                        ((vuint8)(((vuint32)(data))>>16))
#define DescGetLoHiByte(data)                                        ((vuint8)(((vuint32)(data))>>8))
#define DescGetLoLoByte(data)                                        ((vuint8)(data))

/**************************/
/* Communication control  */
/**************************/
/* Acknowledge the communication control */
#define DescCommCtrlChecked(DESC_CONTEXT_PARAM_ONLY)                 (DescProcessingDone(DESC_CONTEXT_PARAM_ONLY))
/* Communication control anti-panic solution :)*/
void DESC_API_CALL_TYPE DescEnableCommunication(void);

/**************************/
/* Session control        */
/**************************/
/* Acknowledge the session transition */
#if defined (DESC_ENABLE_PERMANENT_MAINHANDLER_MULTICALL)
void DescSessionTransitionChecked(DESC_CONTEXT_FORMAL_PARAM_DEF_ONLY);
#else
/* Acknowledge the session transition */
# define DescSessionTransitionChecked(DESC_CONTEXT_PARAM_ONLY)       (DescProcessingDone(DESC_CONTEXT_PARAM_ONLY))
#endif



#endif /* __DESC_H__ */
