
#include "Dcm_Cfg_Prot.h"
#include "DcmDspUds_Iocbi_Inf.h"
#include "Rte_Dcm.h"
/*TESTCODE-START
#include "DcmTest.h"
TESTCODE-END*/
#if ( (DCM_CFG_DSPUDSSUPPORT_ENABLED != DCM_CFG_OFF) && (DCM_CFG_DSP_IOCBI_ENABLED != DCM_CFG_OFF) )

#define DCM_START_SEC_CODE /*Adding this for memory mapping*/
#include "Dcm_MemMap.h"

/**
 * @ingroup DCM_TPL
 * DcmAppl_DcmCheckControlMaskAndState :-\n
 * This api will be invoked from IOCBI service, if the control mask or control status bits are present in the request.\n
 * The application shall return E_OK, if the bits are valid.Nrc 0x31 will be triggered to the tester, if E_OK is not returned from the application
 * @param[in]  nrDID_u16: Currently active DID
 * @param[in]  dataIoParam_u8: Requeste IO parameter value
 * @param[in]  adrCtlStateAndMask_pcst: Control state and control mask bytes received from tester
 * @param[in]  dataCtlStateAndMaskLen_u16: Control state and control mask byte length
 * @retval     E_OK :       if control mask and control status bytes are valid
 * @retval     E_NOT_OK :   if control mask and control status bytes are not valid
 *
 */
Std_ReturnType DcmAppl_DcmCheckControlMaskAndState(uint16 nrDID_u16, uint8 dataIoParam_u8,
													const uint8 * adrCtlStateAndMask_pcst,uint16 dataCtlStateAndMaskLen_u16
													)
{

	Std_ReturnType retVal;
	/*Customer specific code can be added here*/


	/* Sample code for calculation of the size of control mask
	 * Customer can add his own algorithm for calculating the mask
	 */
	uint16 dataControlMaskLen_u16;
	Dcm_DIDIndexType_tst idxIocbiDidIndexType_st;
	retVal = E_OK;
	(void)nrDID_u16;
	(void)dataIoParam_u8;
	(void)adrCtlStateAndMask_pcst;
	(void)dataCtlStateAndMaskLen_u16;
	if (Dcm_Prv_GetIndexOfDID (nrDID_u16,&idxIocbiDidIndexType_st) == E_OK)
	{
		dataControlMaskLen_u16 = (uint16)((uint16)((uint32)(Dcm_DIDConfig[idxIocbiDidIndexType_st.idxIndex_u16].nrSig_u16-1u)/8u)+1u);
	}
	else
	{
		retVal = E_NOT_OK;
	}

	/*TESTCODE-START
	retVal=DcmTest_DcmAppl_DcmCheckControlMaskAndState(nrDID_u16,dataIoParam_u8,adrCtlStateAndMask_pcst,dataCtlStateAndMaskLen_u16);
	TESTCODE-END*/

	return(retVal);
}
#define DCM_STOP_SEC_CODE /*Adding this for memory mapping*/
#include "Dcm_MemMap.h"
#endif /* (DCM_CFG_DSPUDSSUPPORT_ENABLED != DCM_CFG_OFF) && (DCM_CFG_DSP_IOCBI_ENABLED != DCM_CFG_OFF) */

