/**************************************************************************//**
 *
 *  \copyright  This software is the property of  Technologies. Any
 *              information contained in this doc should not be reproduced,
 *              or used, or disclosed without the written authorization from
 *               Technologies.
 *
 *  \brief      This is the head file of the adapter module based on uds
 *              platform.
 *
 *  \file       bl_adpt_uds_platform.h
 *  \ingroup    communication_adapter_module
 *  \author     
 *
 *  \version    5.1.0
 *  \date       27/03/2018
 *
 *  \par        Changelist
 *      Version  | Date       | Authors          | CR# | Descriptions
 *      -------- | ---------- | ---------------- | --- | ------------
 *      01.00.00 | 25/03/2018 | xucong      | N/A | Boot010001
 *
 *****************************************************************************/
#ifndef _BL_ADPT_UDS_PLATFORM_H_
#define _BL_ADPT_UDS_PLATFORM_H_
#include "bl_typedefs.h"
#include "bl_adapter.h"

/*****************************************************************************
 *  QAC Suppression
 *****************************************************************************/
/*PRQA S 3210,3447,4152 EOF*/
/*
 * 3210:The global identifier is declared but is not used.
 * The functions are used in the bl_dcm_cfg.c file.
 * The g_UdsPlatformAdapter is used in the bl_process_driver_cfg.c file.
 *
 * MISRA-C:2004 8.8(3447):The identifier has external linkage but this
 * declaration is not in a header file.
 * The function Declarations are in the header file.
 *
 * 4152:The identifier may cause confusion.
 * Adpt_UdsCallbackGetSeedForLevel1 is LEVEL One.
 * Adpt_UdsCallbackVerifyKeyForLevel1 is LEVEL One.
 *
 */

/*****************************************************************************
 *  Macro Definitions
 *****************************************************************************/

/*****************************************************************************
 *  Type Declarations
 *****************************************************************************/

/*****************************************************************************
 *  Structure Definitions
 *****************************************************************************/



/*****************************************************************************
 *  External Global Variable Declarations
 *****************************************************************************/
/** \brief A adapter for uds platform spec*/
extern const bl_Adapter_t g_UdsPlatformAdapter;
/*****************************************************************************
 *  External Function Prototype Declarations
 *****************************************************************************/
/** \brief Initialize the uds module.*/
extern bl_Return_t Adpt_UdsInit(void);
/** \brief Periodic callback of the adapter.*/
extern void Adpt_UdsPeriodicCallback(void);
/** \brief Callback of the adapter.*/
extern void Adpt_UdsCallback(void);
/** \brief Callback of default session.*/
extern bl_ResponseCode_t Adpt_UdsCallback1001(bl_BufferSize_t size,
                                              bl_Buffer_t *buffer,
                                              bl_BufferSize_t *respSize);
/** \brief Callback of programming session.*/
extern bl_ResponseCode_t Adpt_UdsCallback1002(bl_BufferSize_t size,
                                              bl_Buffer_t *buffer,
                                              bl_BufferSize_t *respSize);
/** \brief Callback of extended session.*/
extern bl_ResponseCode_t Adpt_UdsCallback1003(bl_BufferSize_t size,
                                              bl_Buffer_t *buffer,
                                              bl_BufferSize_t *respSize);
/** \brief Callback of extended session.*/
extern bl_ResponseCode_t Adpt_UdsCallback1004(bl_BufferSize_t size,
                                              bl_Buffer_t *buffer,
                                              bl_BufferSize_t *respSize);

/** \brief Callback of reset.*/
extern bl_ResponseCode_t Adpt_UdsCallback1101(bl_BufferSize_t size,
                                              bl_Buffer_t *buffer,
                                              bl_BufferSize_t *respSize);
extern bl_ResponseCode_t Adpt_UdsCallback1103(bl_BufferSize_t size,
                     bl_Buffer_t *buffer,
                     bl_BufferSize_t *respSize);
/*  22 0200 */
bl_ResponseCode_t Adpt_UdsCallBackReadPgmSuccCounter(bl_BufferSize_t size,
                          bl_Buffer_t *buffer,
                          bl_BufferSize_t *respSize);

/*  22 0201 */
bl_ResponseCode_t Adpt_UdsCallBackReadPgmAttmpCounter(bl_BufferSize_t size,
                          bl_Buffer_t *buffer,
                          bl_BufferSize_t *respSize);


/*  22 F1 80 */
extern bl_ResponseCode_t Adpt_UdsCallBackReadBootSW_ID(bl_BufferSize_t size,
                                                  bl_Buffer_t *buffer,
                                                  bl_BufferSize_t *respSize);

/*  22 F181 */
bl_ResponseCode_t Adpt_UdsCallBackRead_F181_vmapp_softid_ID(bl_BufferSize_t size,
                          bl_Buffer_t *buffer,
                          bl_BufferSize_t *respSize);

/*  22 F182 */
bl_ResponseCode_t Adpt_UdsCallBackRead_F182_ecu_calnum(bl_BufferSize_t size,
                          bl_Buffer_t *buffer,
                          bl_BufferSize_t *respSize);

/*  22 F1 86 */
extern bl_ResponseCode_t Adpt_UdsCallBackReadActiveSession(bl_BufferSize_t size,
                                                  bl_Buffer_t *buffer,
                                                  bl_BufferSize_t *respSize);

/*  22 F187 */
bl_ResponseCode_t Adpt_UdsCallBackReadSparaPartNumber(bl_BufferSize_t size,
                          bl_Buffer_t *buffer,
                          bl_BufferSize_t *respSize);
/*  22 F188 */
bl_ResponseCode_t Adpt_UdsCallBackRead_F188_ECU_SW(bl_BufferSize_t size,
                          bl_Buffer_t *buffer,
                          bl_BufferSize_t *respSize);
/*  22 F189 */
bl_ResponseCode_t Adpt_UdsCallBackReadfe02_count(bl_BufferSize_t size,
                          bl_Buffer_t *buffer,
                          bl_BufferSize_t *respSize);

/*  22 F18A */
bl_ResponseCode_t Adpt_UdsCallBackRead_f18A_supplier(bl_BufferSize_t size,
                          bl_Buffer_t *buffer,
                          bl_BufferSize_t *respSize);

/*  22 F18B */
bl_ResponseCode_t Adpt_UdsCallBackRead_f18B_ecu_manu_date(bl_BufferSize_t size,
                          bl_Buffer_t *buffer,
                          bl_BufferSize_t *respSize);
/*  22 F18C */
bl_ResponseCode_t Adpt_UdsCallBackRead_f18C_ecu_sn(bl_BufferSize_t size,
                          bl_Buffer_t *buffer,
                          bl_BufferSize_t *respSize);

/*  22 F190 */
bl_ResponseCode_t Adpt_UdsCallBackRead_f190_vin(bl_BufferSize_t size,
                          bl_Buffer_t *buffer,
                          bl_BufferSize_t *respSize);

/*  22 F191 */
bl_ResponseCode_t Adpt_UdsCallBackRead_f191_ecu_hw_num(bl_BufferSize_t size,
                          bl_Buffer_t *buffer,
                          bl_BufferSize_t *respSize);
/*  22 F192 */
bl_ResponseCode_t Adpt_UdsCallBackRead_f192_hw_part_num(bl_BufferSize_t size,
                          bl_Buffer_t *buffer,
                          bl_BufferSize_t *respSize);

/*  22 F1 93 */
extern bl_ResponseCode_t Adpt_UdsCallBackReadECU_HW_Number(bl_BufferSize_t size,
                                                  bl_Buffer_t *buffer,
                                                  bl_BufferSize_t *respSize);
/*  22 F194 */
bl_ResponseCode_t Adpt_UdsCallBackRead_f194_ecu_sw_num(bl_BufferSize_t size,
                          bl_Buffer_t *buffer,
                          bl_BufferSize_t *respSize);

/*  22 F195 */
bl_ResponseCode_t Adpt_UdsCallBackRead_f195_sw_version_num(bl_BufferSize_t size,
                          bl_Buffer_t *buffer,
                          bl_BufferSize_t *respSize);


/** \brief Callback of reading fingerprint.*/
extern bl_ResponseCode_t Adpt_UdsCallBackReadFingerprint(bl_BufferSize_t size,
                                                     bl_Buffer_t *buffer,
                                                     bl_BufferSize_t *respSize);

/*  22 F199 */
bl_ResponseCode_t Adpt_UdsCallBackReadProgrammingDate(bl_BufferSize_t size,
												  bl_Buffer_t *buffer,
												  bl_BufferSize_t *respSize);

/*  22 F19E */
bl_ResponseCode_t Adpt_UdsCallBackRead_f19E_odx_id(bl_BufferSize_t size,
                          bl_Buffer_t *buffer,
                          bl_BufferSize_t *respSize);


/*  22 F1F1 */
bl_ResponseCode_t Adpt_UdsCallBackRead_F1F1_ecu_cal_num(bl_BufferSize_t size,
                          bl_Buffer_t *buffer,
                          bl_BufferSize_t *respSize);
/*  22 F1F2*/
bl_ResponseCode_t Adpt_UdsCallBackRead_F1F2_boot_sw_id(bl_BufferSize_t size,
                          bl_Buffer_t *buffer,
                          bl_BufferSize_t *respSize);
/*  22 Fe00*/
bl_ResponseCode_t Adpt_UdsCallBackRead_01a0_manulifecount(bl_BufferSize_t size,
                          bl_Buffer_t *buffer,
                          bl_BufferSize_t *respSize);
/*  22 Fe01*/
bl_ResponseCode_t Adpt_UdsCallBackRead_FE01_device_id(bl_BufferSize_t size,
                          bl_Buffer_t *buffer,
                          bl_BufferSize_t *respSize);

bl_ResponseCode_t Adpt_UdsCallBackWrite_01a0_manulifecount(bl_BufferSize_t size,
                           bl_Buffer_t *buffer,
                           bl_BufferSize_t *respSize);
bl_ResponseCode_t Adpt_UdsCallBackWrite_fe01_backdoo_access_key(bl_BufferSize_t size,
                           bl_Buffer_t *buffer,
                           bl_BufferSize_t *respSize);
/** \brief Callback of getting seed.*/
extern bl_ResponseCode_t Adpt_UdsCallbackGetSeedForLevel1(bl_BufferSize_t size,
                                                     bl_Buffer_t *buffer,
                                                     bl_BufferSize_t *respSize);
/** \brief Callback of verifying key.*/
extern bl_ResponseCode_t Adpt_UdsCallbackVerifyKeyForLevel1(bl_BufferSize_t size,
                                                     bl_Buffer_t *buffer,
                                                     bl_BufferSize_t *respSize);
extern bl_ResponseCode_t Adpt_UdsCallbackGetSeedForLevel5(bl_BufferSize_t size,
                           bl_Buffer_t *buffer,
                           bl_BufferSize_t *respSize);

extern bl_ResponseCode_t Adpt_UdsCallbackVerifyKeyForLevel5(bl_BufferSize_t size,
                           bl_Buffer_t *buffer,
                           bl_BufferSize_t *respSize);
/** \brief Callback of getting seed.*/
extern bl_ResponseCode_t Adpt_UdsCallbackGetSeedForLevel23(bl_BufferSize_t size,
                                                     bl_Buffer_t *buffer,
                                                     bl_BufferSize_t *respSize);
/** \brief Callback of verifying key.*/
extern bl_ResponseCode_t Adpt_UdsCallbackVerifyKeyForLevel24(bl_BufferSize_t size,
                                                     bl_Buffer_t *buffer,
                                                     bl_BufferSize_t *respSize);
/** \brief Callback of enable or disable communication.*/
extern bl_ResponseCode_t Adpt_UdsCallback28(bl_BufferSize_t size,
                                              bl_Buffer_t *buffer,
                                              bl_BufferSize_t *respSize);
/** \brief Callback of writting fingerprint.*/
extern bl_ResponseCode_t Adpt_UdsCallBackWriteFingerprint(bl_BufferSize_t size,
                                                     bl_Buffer_t *buffer,
                                                     bl_BufferSize_t *respSize);
/** \brief Callback of writting programming date.*/
extern bl_ResponseCode_t Adpt_UdsCallBackWriteProgrammingDate(bl_BufferSize_t size,
                                                     bl_Buffer_t *buffer,
                                                     bl_BufferSize_t *respSize);

bl_ResponseCode_t Adpt_UdsCallBackWrite_F18C(bl_BufferSize_t size,
                           bl_Buffer_t *buffer,
                           bl_BufferSize_t *respSize);


bl_ResponseCode_t Adpt_UdsCallBackWrite_F190(bl_BufferSize_t size,
                           bl_Buffer_t *buffer,
                           bl_BufferSize_t *respSize);


/** \brief Callback of checking programming contiditions.*/
extern bl_ResponseCode_t Adpt_UdsCallbackCheckProgramCond(bl_BufferSize_t size,
                                                     bl_Buffer_t *buffer,
                                                     bl_BufferSize_t *respSize);
/** \brief Callback of erasing memory.*/
extern bl_ResponseCode_t Adpt_UdsCallbackEraseMemory(bl_BufferSize_t size,
                                                     bl_Buffer_t *buffer,
                                                     bl_BufferSize_t *respSize);
/** \brief Callback of checksum.*/
extern bl_ResponseCode_t Adpt_UdsCallbackCheckSum(bl_BufferSize_t size,
                                                  bl_Buffer_t *buffer,
                                                  bl_BufferSize_t *respSize);
/** \brief Callback of checking compatibility.*/
extern bl_ResponseCode_t Adpt_UdsCallbackCheckCompatibility(bl_BufferSize_t size,
                                                     bl_Buffer_t *buffer,
                                                     bl_BufferSize_t *respSize);
/** \brief Callback of stayinboot.*/
extern bl_ResponseCode_t Adpt_UdsCallbackStayInBoot(bl_BufferSize_t size,
                                                    bl_Buffer_t *buffer,
                                                    bl_BufferSize_t *respSize);
/** \brief Callback of requesting download.*/
extern bl_ResponseCode_t Adpt_UdsCallback34(bl_BufferSize_t size,
                                            bl_Buffer_t *buffer,
                                            bl_BufferSize_t *respSize);
/** \brief Callback of transferring data.*/
extern bl_ResponseCode_t Adpt_UdsCallback36(bl_BufferSize_t size,
                                            bl_Buffer_t *buffer,
                                            bl_BufferSize_t *respSize);
/** \brief Callback of requesting transfer exit.*/
extern bl_ResponseCode_t Adpt_UdsCallback37(bl_BufferSize_t size,
                                            bl_Buffer_t *buffer,
                                            bl_BufferSize_t *respSize);
/** \brief Callback of keeping session.*/
extern bl_ResponseCode_t Adpt_UdsCallback3E(bl_BufferSize_t size,
                                            bl_Buffer_t *buffer,
                                            bl_BufferSize_t *respSize);
/** \brief Callback of switching on or off dtc.*/
extern bl_ResponseCode_t Adpt_UdsCallback85(bl_BufferSize_t size,
                                            bl_Buffer_t *buffer,
                                            bl_BufferSize_t *respSize);
/** \brief Callback of timeout.*/
extern void Adpt_UdsTimeOutCallBack(void);
/** \brief Callback is used when the reprogramming Flag is valid.*/
extern void Adpt_ReprogramValidProcess(void);
extern void Adpt_Res_default_ValidProcess(void);
/** \brief Callback is used when the reset Flag is valid.*/
extern void Adpt_SystemResetProcess(void);

#if (RTE_FUN_STAY_IN_BOOT == BL_FUN_ON)
/** \brief Callback is used when the application is valid.*/
extern void Adpt_AppValidProcess(void);
#endif

void Adpt_ReprogramValid_nores_Process(void);

extern bl_u8_t g_cur_request_level ;  //當前請求的等級


#endif

