
/******************************************************************************/
/* Williams Advanced Engineering Limited                     Copyright(C) 2021*/
/* Grove                                                  All rights reserved */
/*                                                                            */
/******************************************************************************/


//#include "Ios_CheckBootLoaderSignature.h"
//#undef boolean
//#undef Std_VersionInfoType
#include "Std_Types.h"
#include "FBL_PortUserCode.h"
#include "DcmAppl.h"
#include "FBL_DataMPrvCfg.h"
#include "FBL_DataMCfg.h"

// Removing of compiler warnings and errors because of type re-declaration between hal_stdtypes.h and Std_Types.h
#define _BOOLEAN_DECLARED
#define _UINT8_DECLARED
#define _UINT16_DECLARED
#define _UINT32_DECLARED
#define _UINT64_DECLARED
#define _SINT8_DECLARED
#define _SINT16_DECLARED
#define _SINT32_DECLARED
#define _SINT64_DECLARED
#define _FLOAT32_DECLARED
#define _FLOAT64_DECLARED
#define _STD_RETURN_TYPE_DECLARED
#define _STDVERSION_DECLARED

#include "sys_core.h"
#include "crc_tbl.h"
#include "NvM_Cfg.h"
#include "NvM.h"
#include "Ios_BootLoaderVersion.h"
#include "Ios_RunTimeInstance.h"
#include "Ios_CheckBootLoaderSignature.h"



/*ZIST-2233 :Update Sequence version */
uint8 Boot_update_sequence_version[1] = {BOOT_LOADER_SPEC_VERSION};/* CF00 */

/*ZIST-2242 :Boot loader version */
#pragma RETAIN(Boot_loader_version)
uint8 Boot_loader_version[4] __attribute__ ((section(".boot_info_section"))) = {BOOT_VERSION_MAJOR,BOOT_VERSION_MINOR,BOOT_VERSION_REVISION,BOOT_VERSION_BUILD_ID};/* E000*//* Major-Minor-Revision-build */

/* Zist-5006 :Application Update Counter */
extern uint8 Fbl_DataM_RamMirrorNV_ApplicationUpdateCounterBlock[];/* E001 */
/* Zist-3320 :Application Update Counter */
extern uint8 Fbl_DataM_RamMirrorNV_CalibrationUpdateCounterBlock[];/* E001 */
/* Zist-5000 :Application Region Count */
uint8 Application_region_cnt[1] = {FBL_DATAM_APPLICATION_REGION_NUMBER_OF_REGIONS};/* E003 */
/* Zist -5001 :Calibration Region Count */
uint8 Calibration_region_cnt[1] = {FBL_DATAM_CALIBRATION_REGION_NUMBER_OF_REGIONS};
/* ZIST-5002:Application Checksum Id(N) */


uint8 DcmDspDataBuffer_E010[4];

uint8 DcmDspDataBuffer_E020[1];

uint8 DcmDspDataBuffer_E030[3];

uint8 DcmDspDataBuffer_E040[4];

uint8 DcmDspDataBuffer_E110[4];

uint8 DcmDspDataBuffer_E120[1];

uint8 DcmDspDataBuffer_E130[3];

uint8 DcmDspDataBuffer_E140[4];

uint8 DcmDspDataBuffer_F010[1];

uint8 DcmDspDataBuffer_F013[2];

uint8 DcmDspDataBuffer_F0FD[4];

uint8 DcmDspDataBuffer_F0FE[4];

uint8 DcmDspDataBuffer_F0FF[4];

uint8 DcmDspDataBuffer_F188[1];

uint8 DcmDspDataBuffer_F189[3];

uint8 DcmDspDataBuffer_F18B[8];



/*ZIST-2233 :Update Sequence version */
Std_ReturnType DcmDspDataReadFunc_CF00 (Dcm_OpStatusType OpStatus,uint8 * Data)
{

    uint8 byte_position;
    for(byte_position = 0; byte_position < 1; byte_position++)
    {
        Data[byte_position] = Boot_update_sequence_version[byte_position];
    }
    
    return E_OK;

}
/*ZIST-2242 :Boot loader version */
Std_ReturnType DcmDspDataReadFunc_E000 (Dcm_OpStatusType OpStatus,uint8 * Data)
{

    uint8 byte_position;
    /* Major,Minor,Revision,Build */
    for(byte_position = 0; byte_position < 4; byte_position++)
    {
        Data[byte_position] = Boot_loader_version[byte_position];
    }
    
    return E_OK;

}

/* ZIST-2234 -Application Update Counter */
Std_ReturnType DcmDspDataReadFunc_E001 (Dcm_OpStatusType OpStatus,uint8 * Data)
{

    Std_ReturnType rtn;
    rtn = Fbl_DataM_NvmApplicationUpdateCounterReadFunc(Data);
    return rtn;
}

/* ZIST-3320 -Calibration Update Counter */
Std_ReturnType DcmDspDataReadFunc_E002 (Dcm_OpStatusType OpStatus,uint8 * Data)
{

//    Std_ReturnType rtn;
//    rtn = Fbl_DataM_NvmCalibrationUpdateCounterReadFunc(Data);
    return E_NOT_OK;

}

/* ZIST-5000 - Application Region cnt */
Std_ReturnType DcmDspDataReadFunc_E003 (Dcm_OpStatusType OpStatus,uint8 * Data)
{

    uint8 byte_position;
    
    for(byte_position = 0; byte_position < 1; byte_position++)
    {
        Data[byte_position] = Application_region_cnt[byte_position];
    }
    
    return E_OK;

}

/* ZIST-5001 - Calibration Region cnt */
Std_ReturnType DcmDspDataReadFunc_E004 (Dcm_OpStatusType OpStatus,uint8 * Data)
{

//    uint8 byte_position;
//
//    for(byte_position = 0; byte_position < 1; byte_position++) {
//        Data[byte_position] = Calibration_region_cnt[byte_position];
//    }
    
    return E_NOT_OK;

}

/* ZIST-5002:Application Checksum Id(N) */
Std_ReturnType DcmDspDataReadFunc_E010 (Dcm_OpStatusType OpStatus,uint8 * Data)
{

    uint8 byte_position;
	uint8 bRecordIndex;
	uint8 bCrcTableNumRecs = 0;
	volatile uint64  u64SignatureRef = 0U;
	static CRC_TABLE* CrcTable;
	CrcTable = (CRC_TABLE*)APP_CRC_TABLE_ADDRESS;
    bCrcTableNumRecs = NUM_RECORDS_APP_CRC_TABLE;

    for(bRecordIndex = 0;bRecordIndex < bCrcTableNumRecs;bRecordIndex++)
	{
		u64SignatureRef += CrcTable->recs[bRecordIndex].crc_value;
	}
	for(byte_position = 0; byte_position < 4; byte_position++) {
        //Data[byte_position] = DcmDspDataBuffer_E010[byte_position];
		Data[byte_position] = ((u64SignatureRef>>byte_position)&0xFF);
    }
    
    return E_OK;

}

/* ZIST-5040 :Application Build Type(n) */
Std_ReturnType DcmDspDataReadFunc_E020 (Dcm_OpStatusType OpStatus,uint8 * Data)
{

    uint8 byte_position;
	static MEM_BLOCK_INFO* App_block_info_build_type;

	_coreDisableFlashEcc_();

	App_block_info_build_type = (MEM_BLOCK_INFO*)APP_INFO_ADDRESS;
    
    for(byte_position = 0; byte_position < 1; byte_position++) {
        Data[byte_position] = App_block_info_build_type->build_type;
    }
    _coreEnableFlashEcc_();
    
    return E_OK;

}

/* ZIST-5005 :Application Version Id */
 /* Currently not used as we have only one application region */
Std_ReturnType DcmDspDataReadFunc_E030 (Dcm_OpStatusType OpStatus,uint8 * Data)
{


    static MEM_BLOCK_INFO* App_block_info_version;

    _coreDisableFlashEcc_();

    App_block_info_version = (MEM_BLOCK_INFO*)APP_INFO_ADDRESS;
    
    
    Data[0] = App_block_info_version->major_version;
    Data[1] = App_block_info_version->minor_version;
    Data[2] = App_block_info_version->revision;

    _coreEnableFlashEcc_();

    return E_OK;

}

/* ZIST-5006 :Application update counter (n) */
Std_ReturnType DcmDspDataReadFunc_E040 (Dcm_OpStatusType OpStatus,uint8 * Data)
{

    uint8 byte_position;
    
    for(byte_position = 0; byte_position < 4; byte_position++) {
        Data[byte_position] = Fbl_DataM_RamMirrorNV_ApplicationUpdateCounterBlock[byte_position];
    }
    
    return E_OK;

}

/* ZIST-5003 :Calibration checksum (n) */
Std_ReturnType DcmDspDataReadFunc_E110 (Dcm_OpStatusType OpStatus,uint8 * Data)
{

//    uint8 byte_position;
//	uint8 bRecordIndex;
//	uint8 bCrcTableNumRecs = 0;
//	volatile uint64  u64SignatureRef = 0U;
//	static CRC_TABLE* CrcTable;
//	CrcTable = (CRC_TABLE*)CAL_CRC_TABLE_ADDRESS;
//    bCrcTableNumRecs = NUM_RECORDS_CAL_CRC_TABLE;
//
//    for(bRecordIndex = 0;bRecordIndex < bCrcTableNumRecs;bRecordIndex++)
//	{
//		u64SignatureRef += CrcTable->recs[bRecordIndex].crc_value;
//	}
//	for(byte_position = 0; byte_position < 4; byte_position++) {
//        //Data[byte_position] = DcmDspDataBuffer_E010[byte_position];
//		Data[byte_position] = ((u64SignatureRef>>byte_position)&0xFF);
//    }
    
    return E_NOT_OK;
}

/* ZIST-5008 :Calibration build Type(n) */
Std_ReturnType DcmDspDataReadFunc_E120 (Dcm_OpStatusType OpStatus,uint8 * Data)
{

//    uint8 byte_position;
//	static MEM_BLOCK_INFO* Cal_block_info_build_type;
//	Cal_block_info_build_type = (MEM_BLOCK_INFO*)CAL_INFO_ADDRESS;
//
//    for(byte_position = 0; byte_position < 1; byte_position++) {
//        Data[byte_position] = Cal_block_info_build_type->build_type;
//    }
    
    return E_NOT_OK;

}

/* ZIST-5009 :Calibration Version */
Std_ReturnType DcmDspDataReadFunc_E130 (Dcm_OpStatusType OpStatus,uint8 * Data)
{


//    static MEM_BLOCK_INFO* Cal_block_info_version;
//
//    _coreDisableFlashEcc_();
//    Cal_block_info_version = (MEM_BLOCK_INFO*)APP_INFO_ADDRESS;
//
//
//    Data[0] = Cal_block_info_version->major_version;
//    Data[1] = Cal_block_info_version->minor_version;
//    Data[2] = Cal_block_info_version->revision;
//
//    _coreEnableFlashEcc_();
//
//    return E_OK;
    
    return E_NOT_OK;

}

/* ZIST-5007 :Calibration update version */
Std_ReturnType DcmDspDataReadFunc_E140 (Dcm_OpStatusType OpStatus,uint8 * Data)
{

    uint8 byte_position;
    
    for(byte_position = 0; byte_position < 4; byte_position++)
    {
        Data[byte_position] = Fbl_DataM_RamMirrorNV_CalibrationUpdateCounterBlock[byte_position];
    }
    
    return E_OK;

}
/*ZIST:2214 :Current Run Mode */
Std_ReturnType DcmDspDataReadFunc_F010 (Dcm_OpStatusType OpStatus,uint8 * Data)
{

        Data[0] = BOOT_RUN_MODE;

    return E_OK;

}

/*ZIST:3384 :Run time instancing */
Std_ReturnType DcmDspDataReadFunc_F013 (Dcm_OpStatusType OpStatus,uint8 * Data)
{

    

    Data[0] = 0;/* Reserved */

    if(fnIosGetRunTimeInstance() == RUNTIME_INST_BMS1)
        Data[1] = ECU_INSTANCE_ID_NORTH;
    else
        Data[1] = ECU_INSTANCE_ID_SOUTH;
	
    return E_OK;

}

/*ZIST:3384 :Run time instancing */
/* RUN time instancing not supported by UDS */
Std_ReturnType DcmDspDataWriteFunc_F013 (const uint8 * Data,Dcm_OpStatusType OpStatus,Dcm_NegativeResponseCodeType * ErrorCode)
{

    uint8 byte_position;
    
    for(byte_position = 0; byte_position < 2; byte_position++) {
        DcmDspDataBuffer_F013[byte_position] = Data[byte_position];
    }
    
    *ErrorCode = E_OK;
    return E_OK;
}

/* ZIST-5056 :Boot loader checksum */
Std_ReturnType DcmDspDataReadFunc_F0FD (Dcm_OpStatusType OpStatus,uint8 * Data)
{

    uint8 byte_position;
	uint32 Boot_loader_checksum;
	Boot_loader_checksum = (uint32)fnIosGetBootLoaderSignatureValue();
    

    for(byte_position = 0; byte_position < 4; byte_position++)
	{
        Data[byte_position] = ((Boot_loader_checksum>>(byte_position*8))&0xFF);
    }
    
    return E_OK;

}

/* ZIST-3318 :Calibration checksum(ID0) */
Std_ReturnType DcmDspDataReadFunc_F0FE (Dcm_OpStatusType OpStatus,uint8 * Data)
{

//    uint8 byte_position;
//	uint8 bRecordIndex;
//	uint8 bCrcTableNumRecs = 0;
//	volatile uint64  u64SignatureRef = 0U;
//	static CRC_TABLE* CrcTable;
//	CrcTable = (CRC_TABLE*)CAL_CRC_TABLE_ADDRESS;
//    bCrcTableNumRecs = NUM_RECORDS_CAL_CRC_TABLE;
//
//    for(bRecordIndex = 0;bRecordIndex < bCrcTableNumRecs;bRecordIndex++)
//	{
//		u64SignatureRef += CrcTable->recs[bRecordIndex].crc_value;
//	}
//	for(byte_position = 0; byte_position < 4; byte_position++) {
//        //Data[byte_position] = DcmDspDataBuffer_E010[byte_position];
//		Data[byte_position] = ((u64SignatureRef>>byte_position)&0xFF);
//    }
    
    return E_NOT_OK;

}
/* ZIST-2221 :Application checksum ID0 */
Std_ReturnType DcmDspDataReadFunc_F0FF (Dcm_OpStatusType OpStatus,uint8 * Data)
{

    uint8 byte_position;
	uint8 bRecordIndex;
	uint8 bCrcTableNumRecs = 0;
	volatile uint64  u64SignatureRef = 0U;
	static CRC_TABLE* CrcTable;

	_coreDisableFlashEcc_();
	CrcTable = (CRC_TABLE*)APP_CRC_TABLE_ADDRESS;
    bCrcTableNumRecs = NUM_RECORDS_APP_CRC_TABLE;

    for(bRecordIndex = 0;bRecordIndex < bCrcTableNumRecs;bRecordIndex++)
	{
		u64SignatureRef += CrcTable->recs[bRecordIndex].crc_value;
	}
	for(byte_position = 0; byte_position < 4; byte_position++)
	{
        //Data[byte_position] = DcmDspDataBuffer_E010[byte_position];
		Data[byte_position] = ((u64SignatureRef>>(byte_position*8))&0xFF);
    }
    
    return E_OK;
}

/*ZIST-2219 :Hardware Part Number */
Std_ReturnType DcmDspDataReadFunc_F187 (Dcm_OpStatusType OpStatus,uint8 * Data)
{

    uint8 byte_position;
    
    for(byte_position = 0; byte_position < 32; byte_position++) {
        Data[byte_position] = Fbl_DataM_RamMirrorNV_HardwarePartNumberBlock[byte_position];
    }
    
    return E_OK;
}

/*ZIST-2219 :Hardware Part Number */
Std_ReturnType DcmDspDataWriteFunc_F187 (const uint8 * Data,Dcm_OpStatusType OpStatus,Dcm_NegativeResponseCodeType * ErrorCode)
{

    if ( OpStatus == DCM_INITIAL)
    {
        Fbl_DataM_NvmHardwarePartNumberWriteFunc(Data);
        *ErrorCode = DCM_PENDING;
    }

    else if( OpStatus == DCM_PENDING)
    {
        if(Fbl_DataM_NvmHardwarePartNumberIsPersisted() == TRUE)
        {
            *ErrorCode = E_OK;
        }
        else
        {
            *ErrorCode = DCM_PENDING;
        }
    }
    return E_OK;
}

/* ZIST-2226: Application Build Type -ID0 */
Std_ReturnType DcmDspDataReadFunc_F188 (Dcm_OpStatusType OpStatus,uint8 * Data)
{

    uint8 byte_position;
	static MEM_BLOCK_INFO* App_block_info_build_type;

	_coreDisableFlashEcc_();
	App_block_info_build_type = (MEM_BLOCK_INFO*)APP_INFO_ADDRESS;
    
    for(byte_position = 0; byte_position < 1; byte_position++)
    {
        Data[byte_position] = App_block_info_build_type->build_type;
    }
    
    _coreEnableFlashEcc_();

    return E_OK;

}

/* ZIST-2228: Application version -ID0 */
Std_ReturnType DcmDspDataReadFunc_F189 (Dcm_OpStatusType OpStatus,uint8 * Data)
{


    static MEM_BLOCK_INFO* App_block_info_version;

    _coreDisableFlashEcc_();
    App_block_info_version = (MEM_BLOCK_INFO*)APP_INFO_ADDRESS;
    
    
    Data[0] = App_block_info_version->major_version;
    Data[1] = App_block_info_version->minor_version;
    Data[2] = App_block_info_version->revision;

    _coreEnableFlashEcc_();

    return E_OK;

}

/* ZIST-2222 :Hardware Manufacture Date */
/* NVM Object not yet present */ 
Std_ReturnType DcmDspDataReadFunc_F18B (Dcm_OpStatusType OpStatus,uint8 * Data)
{

    uint8 byte_position;
    
    for(byte_position = 0; byte_position < 8; byte_position++)
    {
        Data[byte_position] = Fbl_DataM_RamMirrorNV_HardwareManufacturingDateBlock[byte_position];
    }
    
    return E_OK;

}

/* ZIST-2222 :Hardware Manufacture Date */
/* NVM Object not yet present */ 
Std_ReturnType DcmDspDataWriteFunc_F18B (const uint8 * Data,Dcm_OpStatusType OpStatus,Dcm_NegativeResponseCodeType * ErrorCode)
{

    uint8 byte_position;
	Std_ReturnType result = E_OK;
    
    for(byte_position = 0; byte_position < 8; byte_position++) {
        DcmDspDataBuffer_F18B[byte_position] = Data[byte_position];
    }
	result = Fbl_DataM_NvmHardwareManufacturingDateWriteFunc(DcmDspDataBuffer_F18B);
    
    *ErrorCode = result;
    return E_OK;
}

/* ZIST-2224 :Hardware serial Number */
Std_ReturnType DcmDspDataReadFunc_F18C (Dcm_OpStatusType OpStatus,uint8 * Data)
{

    Std_ReturnType rtn;
    rtn = Fbl_DataM_NvmHardwareSerialNumberReadFunc(Data);
    return rtn;

}

/* ZIST-2224 :Hardware serial Number */
Std_ReturnType DcmDspDataWriteFunc_F18C (const uint8 * Data,Dcm_OpStatusType OpStatus,Dcm_NegativeResponseCodeType * ErrorCode)
{

    if ( OpStatus == DCM_INITIAL)
    {
        Fbl_DataM_NvmHardwareSerialNumberWriteFunc(Data);
        *ErrorCode = DCM_PENDING;
    }

    else if( OpStatus == DCM_PENDING)
    {
        if(Fbl_DataM_NvmHardwareSerialNumberIsPersisted() == TRUE)
        {
            *ErrorCode = E_OK;
        }
        else
        {
            *ErrorCode = DCM_PENDING;
        }
    }
    return E_OK;
}

/* ZIST-2225 :Read Component Id */
Std_ReturnType DcmDspDataReadFunc_F191 (Dcm_OpStatusType OpStatus,uint8 * Data)
{
    //Std_ReturnType rtn;

    //rtn = Fbl_DataM_NvmCompnentIDReadFunc(Data);
    Data[0] = 0;
    Data[1] = HW_COMPONENT_ID;
    return E_OK;

}

/* ZIST-2223 :Read Hardware ID */
Std_ReturnType DcmDspDataReadFunc_F193 (Dcm_OpStatusType OpStatus,uint8 * Data)
{
    //Std_ReturnType rtn;

    //rtn = Fbl_DataM_NvmHardwareIDReadFunc(Data);
    *Data = HW_REVISION_ID;
    return E_OK;

}

/* ZIST-2223 :Write Hardware ID */
Std_ReturnType DcmDspDataWriteFunc_F193 (const uint8 * Data,Dcm_OpStatusType OpStatus,Dcm_NegativeResponseCodeType * ErrorCode)
{

    if ( OpStatus == DCM_INITIAL)
    {
        Fbl_DataM_NvmHardwareIDWriteFunc(Data);
        *ErrorCode = DCM_PENDING;
    }
    else if( OpStatus == DCM_PENDING)
    {
        if(Fbl_DataM_NvmHardwareIDIsPersisted() == TRUE)
        {
            *ErrorCode = E_OK;
        }
        else
        {
            *ErrorCode = DCM_PENDING;
        }
    }
    return E_OK;
}

/* ZIST-2231:Application Updator Fingerprint */
Std_ReturnType DcmDspDataReadFunc_F198 (Dcm_OpStatusType OpStatus,uint8 * Data)
{
    Std_ReturnType rtn;

    rtn = Fbl_DataM_NvmApplicationUpdaterFingerprintReadFunc(Data);
    return rtn;

}

/* ZIST-2231:Application Updator Fingerprint */
Std_ReturnType DcmDspDataWriteFunc_F198 (const uint8 * Data,Dcm_OpStatusType OpStatus,Dcm_NegativeResponseCodeType * ErrorCode)
{

    if ( OpStatus == DCM_INITIAL)
    {
        Fbl_DataM_NvmApplicationUpdaterFingerprintWriteFunc(Data);
        *ErrorCode = DCM_PENDING;
    }
    else if( OpStatus == DCM_PENDING)
    {
        if(Fbl_DataM_NvmApplicationUpdaterFingerprintIsPersisted() == TRUE)
        {
            *ErrorCode = E_OK;
        }
        else
        {
            *ErrorCode = DCM_PENDING;
        }
    }
    return E_OK;
}

/* ZIST-F199:Application update time stamp */
Std_ReturnType DcmDspDataReadFunc_F199 (Dcm_OpStatusType OpStatus,uint8 * Data)
{

    Std_ReturnType rtn;
    rtn = Fbl_DataM_NvmApplicationUpdateTimestampReadFunc(Data);
    return rtn;

}

/* ZIST-F199:Application update time stamp */
Std_ReturnType DcmDspDataWriteFunc_F199 (const uint8 * Data,Dcm_OpStatusType OpStatus,Dcm_NegativeResponseCodeType * ErrorCode)
{

    if ( OpStatus == DCM_INITIAL)
    {
        Fbl_DataM_NvmApplicationUpdateTimestampWriteFunc(Data);
        *ErrorCode = DCM_PENDING;
    }

    else if( OpStatus == DCM_PENDING)
    {
        if(Fbl_DataM_NvmApplicationUpdateTimestampIsPersisted() == TRUE)
        {
            *ErrorCode = E_OK;
        }
        else
        {
            *ErrorCode = DCM_PENDING;
        }
    }
    return E_OK;
}

/*ZIST-3236:Calibration updator Fingerprint */
Std_ReturnType DcmDspDataReadFunc_F19A (Dcm_OpStatusType OpStatus,uint8 * Data)
{

//    Std_ReturnType rtn;
//    rtn = Fbl_DataM_NvmCalibrationUpdaterFingerprintReadFunc(Data);
    return E_NOT_OK;

}

/*ZIST-3236:Calibration updator Fingerprint */
Std_ReturnType DcmDspDataWriteFunc_F19A (const uint8 * Data,Dcm_OpStatusType OpStatus,Dcm_NegativeResponseCodeType * ErrorCode)
{
//    if ( OpStatus == DCM_INITIAL)
//    {
//        Fbl_DataM_NvmCalibrationUpdaterFingerprintWriteFunc(Data);
//        *ErrorCode = DCM_PENDING;
//    }
//
//    else if( OpStatus == DCM_PENDING)
//    {
//        if(Fbl_DataM_NvmCalibrationUpdaterFingerprintIsPersisted() == TRUE)
//        {
//            *ErrorCode = E_OK;
//        }
//        else
//        {
//            *ErrorCode = DCM_PENDING;
//        }
//    }
    return E_NOT_OK;

}

/*ZIST-3327 :Calibration Updator timestamp */
Std_ReturnType DcmDspDataReadFunc_F19B (Dcm_OpStatusType OpStatus,uint8 * Data){

//    Std_ReturnType rtn;
//    rtn = Fbl_DataM_NvmCalibrationUpdateTimestampReadFunc(Data);
    return E_NOT_OK;

}

/*ZIST-3327 :Calibration Updator timestamp */
Std_ReturnType DcmDspDataWriteFunc_F19B (const uint8 * Data,Dcm_OpStatusType OpStatus,Dcm_NegativeResponseCodeType * ErrorCode)
{
//    if ( OpStatus == DCM_INITIAL)
//    {
//        Fbl_DataM_NvmCalibrationUpdateTimestampWriteFunc(Data);
//        *ErrorCode = DCM_PENDING;
//    }
//
//    else if( OpStatus == DCM_PENDING)
//    {
//        if(Fbl_DataM_NvmCalibrationUpdateTimestampIsPersisted() == TRUE)
//        {
//            *ErrorCode = E_OK;
//        }
//        else
//        {
//            *ErrorCode = DCM_PENDING;
//        }
//    }
    return E_NOT_OK;
}

/* NvM_SecretKey    F0A0
 *
 */
Std_ReturnType DcmDspDataWriteFunc_F0A0 (const uint8 * Data,Dcm_OpStatusType OpStatus,Dcm_NegativeResponseCodeType * ErrorCode)
{
    uint32 uSecretKeyUpdateCntr=0;

    if ( OpStatus == DCM_INITIAL)
    {
        Fbl_DataM_NvmSecretKeyWriteFunc(Data);
        Fbl_DataM_NvmSecretKeyUpdateCounterReadFunc((uint8*) &uSecretKeyUpdateCntr);
        uSecretKeyUpdateCntr++;
        Fbl_DataM_NvmSecretKeyUpdateCounterWriteFunc((uint8*) &uSecretKeyUpdateCntr);

        *ErrorCode = DCM_PENDING;
    }

    else if( OpStatus == DCM_PENDING)
    {
        if((Fbl_DataM_NvmSecretKeyIsPersisted() == TRUE) && (Fbl_DataM_NvmSecretKeyUpdateCounterIsPersisted() == TRUE))
        {
            *ErrorCode = E_OK;
        }
        else
        {
            *ErrorCode = DCM_PENDING;
        }
    }
    return E_OK;
}

/* Nvm_SecretKeyUpdateCounter   F0A1
 *
 */
Std_ReturnType DcmDspDataReadFunc_F0A1 (Dcm_OpStatusType OpStatus,uint8 * Data)
{

    Std_ReturnType rtn;

    rtn = Fbl_DataM_NvmSecretKeyUpdateCounterReadFunc(Data);

    return rtn;

}

Std_ReturnType DcmDspDataReadFunc_F186 (Dcm_OpStatusType OpStatus,uint8 * Data){

	return Dcm_DidServices_F186_ReadData(Data);

}

