/*!
* @file     CDD_Crc.c
*
* @version  1.0.0
*
* @brief    Code file of CRC driver
*
* @attention
*
* Project Name      : AUTOSAR MCAL
*
* Platform          : Arm
*
* Autosar Standard  : Classic Platform 4.4.0
*
* Compiled Version  : G32A10xx_MCAL_1_0_0_01-Otc-25
*
* Copyright (C) 2026 Geehy Semiconductor
*
* You may not use this file except in compliance with the
* GEEHY COPYRIGHT NOTICE (Geehy Semiconductor Software License Agreement).
*
* The program is only for reference, which is distributed in the hope
* that it will be usefull and instructional for customers to develop
* their software. Unless required by applicable law or agreed to in
* writing, the program is distributed on an "AS IS" BASIS, WITHOUT
* ANY WARRANTY OR CONDITIONS OF ANY KIND, either express or implied.
* See the Geehy Semiconductor Software License Agreement for the governing permissions
* and limitations under the License.
*/

#ifdef __cplusplus
extern "C"{
#endif

#include "CDD_Crc.h"
#include "Crc_Hw.h"

#if( STD_ON == CRC_DEV_ERR_DETECT_ENABLE )
    #include "Det.h"
#endif

/** @addtogroup G32A10xx_StdPeriphDriver
  @{
*/

/** @defgroup CRC_Driver
  * @brief CRC driver modules
  @{
*/

/** @defgroup CRC_Macros
  @{
*/
/**************************************************************************
                  VENDOR ID & AUTOSAR VERSION INFO
**************************************************************************/
/** Vendor ID (vendorId) of the dedicated implementation of this module according to the AUTOSAR vendor list. */
#define CDD_CRC_VENDOR_ID                        0x00C1U
/** Major version number of AUTOSAR release on which the appropriate implementation is based on. */
#define CDD_CRC_AR_RELEASE_MAJOR_VERSION         0x04U
/** Minor version number of AUTOSAR release on which the appropriate implementation is based on. */
#define CDD_CRC_AR_RELEASE_MINOR_VERSION         0x04U
/** Revision version number of AUTOSAR release on which the appropriate implementation is based on. */
#define CDD_CRC_AR_RELEASE_REVISION_VERSION      0x00U
/** Major version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define CDD_CRC_SW_MAJOR_VERSION                 0x01U
/** Minor version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define CDD_CRC_SW_MINOR_VERSION                 0x00U
/** Patch level version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define CDD_CRC_SW_PATCH_VERSION                 0x00U

/**@} end of group CRC_Macros */

/**************************************************************************
                    VERSION INFOMATION VERIFICATION
**************************************************************************/
#ifdef ENABLE_INTERMODULE_MCAL_CHECK
    #if(STD_ON == CRC_DEV_ERR_DETECT_ENABLE)
        /* Make sure the AUTOSAR major version number is the same between CDD_Crc.c and Det.h */
        #if (CDD_CRC_AR_RELEASE_MAJOR_VERSION != DET_H_AR_RELEASE_MAJOR_VERSION)
            #error "AUTOSAR Major Version Number mismatch between CDD_Crc.c and Det.h"
        #endif
        /* Make sure the AUTOSAR minor version number is the same between CDD_Crc.c and Det.h */
        #if (CDD_CRC_AR_RELEASE_MINOR_VERSION != DET_H_AR_RELEASE_MINOR_VERSION)
            #error "AUTOSAR Minor Version Number mismatch between CDD_Crc.c and Det.h"
        #endif
    #endif
#endif

/* Make sure the vendor id is the same between CDD_Crc.c and CDD_Crc.h */
#if (CDD_CRC_VENDOR_ID != CDD_CRC_H_VENDOR_ID)
    #error "Vendor id mismatch between CDD_Crc.c and CDD_Crc.h"
#endif
/* Make sure the AUTOSAR major version number is the same between CDD_Crc.c and CDD_Crc.h */
#if (CDD_CRC_AR_RELEASE_MAJOR_VERSION != CDD_CRC_H_AR_RELEASE_MAJOR_VERSION)
    #error "AUTOSAR Major Version Number mismatch between CDD_Crc.c and CDD_Crc.h"
#endif
/* Make sure the AUTOSAR minor version number is the same between CDD_Crc.c and CDD_Crc.h */
#if (CDD_CRC_AR_RELEASE_MINOR_VERSION != CDD_CRC_H_AR_RELEASE_MINOR_VERSION)
    #error "AUTOSAR Minor Version Number mismatch between CDD_Crc.c and CDD_Crc.h"
#endif
/* Make sure the AUTOSAR revision version number is the same between CDD_Crc.c and CDD_Crc.h */
#if (CDD_CRC_AR_RELEASE_REVISION_VERSION != CDD_CRC_H_AR_RELEASE_REVISION_VERSION)
    #error "AUTOSAR Revision Version Number mismatch between CDD_Crc.c and CDD_Crc.h"
#endif
/* Make sure the software major version number is the same between CDD_Crc.c and CDD_Crc.h */
#if (CDD_CRC_SW_MAJOR_VERSION != CDD_CRC_H_SW_MAJOR_VERSION)
    #error "Software Major Version Number mismatch between CDD_Crc.c and CDD_Crc.h"
#endif
/* Make sure the software minor version number is the same between CDD_Crc.c and CDD_Crc.h */
#if (CDD_CRC_SW_MINOR_VERSION != CDD_CRC_H_SW_MINOR_VERSION)
    #error "Software Minor Version Number mismatch between CDD_Crc.c and CDD_Crc.h"
#endif
/* Make sure the software patch version number is the same between CDD_Crc.c and CDD_Crc.h */
#if (CDD_CRC_SW_PATCH_VERSION != CDD_CRC_H_SW_PATCH_VERSION)
    #error "Software Patch Version Number mismatch between CDD_Crc.c and CDD_Crc.h"
#endif

/* Make sure the vendor id is the same between CDD_Crc.c and Crc_Hw.h */
#if (CDD_CRC_VENDOR_ID != CRC_HW_H_VENDOR_ID)
    #error "Vendor id mismatch between CDD_Crc.c and Crc_Hw.h"
#endif
/* Make sure the AUTOSAR major version number is the same between CDD_Crc.c and Crc_Hw.h */
#if (CDD_CRC_AR_RELEASE_MAJOR_VERSION != CRC_HW_H_AR_RELEASE_MAJOR_VERSION)
    #error "AUTOSAR Major Version Number mismatch between CDD_Crc.c and Crc_Hw.h"
#endif
/* Make sure the AUTOSAR minor version number is the same between CDD_Crc.c and Crc_Hw.h */
#if (CDD_CRC_AR_RELEASE_MINOR_VERSION != CRC_HW_H_AR_RELEASE_MINOR_VERSION)
    #error "AUTOSAR Minor Version Number mismatch between CDD_Crc.c and Crc_Hw.h"
#endif
/* Make sure the AUTOSAR revision version number is the same between CDD_Crc.c and Crc_Hw.h */
#if (CDD_CRC_AR_RELEASE_REVISION_VERSION != CRC_HW_H_AR_RELEASE_REVISION_VERSION)
    #error "AUTOSAR Revision Version Number mismatch between CDD_Crc.c and Crc_Hw.h"
#endif
/* Make sure the software major version number is the same between CDD_Crc.c and Crc_Hw.h */
#if (CDD_CRC_SW_MAJOR_VERSION != CRC_HW_H_SW_MAJOR_VERSION)
    #error "Software Major Version Number mismatch between CDD_Crc.c and Crc_Hw.h"
#endif
/* Make sure the software minor version number is the same between CDD_Crc.c and Crc_Hw.h */
#if (CDD_CRC_SW_MINOR_VERSION != CRC_HW_H_SW_MINOR_VERSION)
    #error "Software Minor Version Number mismatch between CDD_Crc.c and Crc_Hw.h"
#endif
/* Make sure the software patch version number is the same between CDD_Crc.c and Crc_Hw.h */
#if (CDD_CRC_SW_PATCH_VERSION != CRC_HW_H_SW_PATCH_VERSION)
    #error "Software Patch Version Number mismatch between CDD_Crc.c and Crc_Hw.h"
#endif

/**************************************************************************
                            LOCAL VARIABLE
**************************************************************************/
#if( STD_ON == CRC_DEV_ERR_DETECT_ENABLE )
    #define CRCU_START_SEC_VAR_INIT_UNSPECIFIED
    #include "Crc_MemMap.h"
    /** @defgroup CRC_Variable
      @{
    */
        /** Save the state of CRC */
        static VAR(Crc_ModuleStateType, CRCU_VAR) s_crcState = CRC_MODULE_UNINITIALIZED;
    /**@} end of group CRC_Variable */
    #define CRCU_STOP_SEC_VAR_INIT_UNSPECIFIED
    #include "Crc_MemMap.h"
#endif

/**************************************************************************
                                GLOBAL FUNCTION
**************************************************************************/
#define CRCU_START_SEC_CODE
#include "Crc_MemMap.h"

/** @defgroup CRC_Fuctions
  @{
*/

/*!
* @brief This function is used to initialize CRC module
*
* @param[in]       None
* @param[out]      None
* @param[inout]    None
*
* @retval E_OK:     CRC module initialization successful
* @retval E_NOT_OK: CRC module initialization failed
*/
FUNC(Std_ReturnType, CRCU_CODE) Crc_Init(void)
{
    VAR(Std_ReturnType, AUTOMATIC) result = E_OK;

#if( STD_ON == CRC_DEV_ERR_DETECT_ENABLE )
    if (s_crcState == CRC_MODULE_INITIALIZED)
    {
        (void)Det_ReportError((uint16)CDD_CRC_H_MODULE_ID, CRC_INSTANCE_ID, CRC_INIT_ID, CRC_E_ALREADY_INITIALIZED);
        result = E_NOT_OK;
    }
    else
#endif
    {
        /* Set CRC_INDATA register */
        Crc_Hw_WriteIDRegister(CRC_INDATA_REG_VALUE);
        /* Reset CRC_DATA register */
        Crc_Hw_ResetDATA();
        /* Set REVI bit */
        Crc_Hw_SelectReverseInputData(CRC_INPUT_REVERSE_MODE);
        /* Set REVO bit */
        Crc_Hw_OperationReverseOutputData(CRC_OUTPUT_REVERSE_MODE);
        /* Set CRC_INITVAL register */
        Crc_Hw_WriteInitRegister(CRC_INITVAL_REG_VALUE);
#if( STD_ON == CRC_DEV_ERR_DETECT_ENABLE )
        /* Set CRC State as initialized */
        s_crcState = CRC_MODULE_INITIALIZED;
#endif
    }

    return result;
}

/*!
* @brief This function is used to deinitialize CRC module
*
* @param[in]       None
* @param[out]      None
* @param[inout]    None
*
* @retval E_OK:     CRC module deinitialization successful
* @retval E_NOT_OK: CRC module deinitialization failed
*/
FUNC(Std_ReturnType, CRCU_CODE) Crc_DeInit(void)
{
    VAR(Std_ReturnType, AUTOMATIC) result = E_OK;

#if( STD_ON == CRC_DEV_ERR_DETECT_ENABLE )
    if (s_crcState == CRC_MODULE_UNINITIALIZED)
    {
        (void)Det_ReportError((uint16)CDD_CRC_H_MODULE_ID, CRC_INSTANCE_ID, CRC_DEINIT_ID, CRC_E_UNINIT);
        result = E_NOT_OK;
    }
    else
#endif
    {
        /* Reset CRC_DATA register */
        (void)Crc_Hw_CalculateCRC(0xFFFFFFFFU);
        /* Reset CRC_INDATA register */
        Crc_Hw_WriteIDRegister(0);
        /* Reset CRC_INITVAL register */
        Crc_Hw_WriteInitRegister(0xFFFFFFFFU);
        /* Reset input reverse mode as no */
        Crc_Hw_SelectReverseInputData(CRC_REVERSE_INPUT_DATA_NO);
        /* Reset output reverse mode as false */
        Crc_Hw_OperationReverseOutputData(FALSE);
#if( STD_ON == CRC_DEV_ERR_DETECT_ENABLE )
        /* Set CRC State as uninitialized */
        s_crcState = CRC_MODULE_UNINITIALIZED;
#endif
    }

    return result;
}

/*!
* @brief This function is used to reset CRC_DATA register
*
* @param[in]       None
* @param[out]      None
* @param[inout]    None
*
* @retval E_OK:     Successfully reset CRC_DATA register
* @retval E_NOT_OK: Failed to reset CRC_DATA register
*/
FUNC(Std_ReturnType, CRCU_CODE) Crc_ResetDataReg(void)
{
    VAR(Std_ReturnType, AUTOMATIC) result = E_OK;

#if( STD_ON == CRC_DEV_ERR_DETECT_ENABLE )
    if (s_crcState == CRC_MODULE_UNINITIALIZED)
    {
        (void)Det_ReportError((uint16)CDD_CRC_H_MODULE_ID, CRC_INSTANCE_ID, CRC_RESETDATAREG_ID, CRC_E_UNINIT);
        result = E_NOT_OK;
    }
    else
#endif
    {
        /* Reset CRC_DATA register */
        Crc_Hw_ResetDATA();
    }

    return result;
}

/*!
* @brief This function is used to set input reverse mode
*
* @param[in]       Mode     Target input reverse mode:
*                           CRC_REVERSE_INPUT_DATA_NO  : Bit order not affected
*                           CRC_REVERSE_INPUT_DATA_8B  : Bit reversal done by byte
*                           CRC_REVERSE_INPUT_DATA_16B : Bit reversal done by half-word
*                           CRC_REVERSE_INPUT_DATA_32B : Bit reversal done by word
* @param[out]      None
* @param[inout]    None
*
* @retval E_OK:     Successfully set input reverse mode
* @retval E_NOT_OK: Failed to set input reverse mode
*/
FUNC(Std_ReturnType, CRCU_CODE) Crc_SetInputReverseMode(VAR(Crc_ReverseInputDataType, AUTOMATIC) Mode)
{
    VAR(Std_ReturnType, AUTOMATIC) result = E_OK;

#if( STD_ON == CRC_DEV_ERR_DETECT_ENABLE )
    if (s_crcState == CRC_MODULE_UNINITIALIZED)
    {
        (void)Det_ReportError((uint16)CDD_CRC_H_MODULE_ID, CRC_INSTANCE_ID, CRC_SETINPUTREVERSEMODE_ID, CRC_E_UNINIT);
        result = E_NOT_OK;
    }
    else if ( (Mode != CRC_REVERSE_INPUT_DATA_NO)  && (Mode != CRC_REVERSE_INPUT_DATA_8B) && 
              (Mode != CRC_REVERSE_INPUT_DATA_16B) && (Mode != CRC_REVERSE_INPUT_DATA_32B) )
    {
        (void)Det_ReportError((uint16)CDD_CRC_H_MODULE_ID, CRC_INSTANCE_ID, CRC_SETINPUTREVERSEMODE_ID, CRC_E_PARA);
        result = E_NOT_OK;
    }
    else
#endif
    {
        /* Set REVI bit */
        Crc_Hw_SelectReverseInputData(Mode);
    }

    return result;
}

/*!
* @brief This function is used to set output reverse mode
*
* @param[in]       Flag     whether to enable the output reverse function :
*                           TRUE  : enable the output reverse function
*                           FALSE : disable the output reverse function
* @param[out]      None
* @param[inout]    None
*
* @retval E_OK:     Successfully set output reverse mode
* @retval E_NOT_OK: Failed to set output reverse mode
*/
FUNC(Std_ReturnType, CRCU_CODE) Crc_SetOutputReverseMode(VAR(boolean, AUTOMATIC) Flag)
{
    VAR(Std_ReturnType, AUTOMATIC) result = E_OK;

#if( STD_ON == CRC_DEV_ERR_DETECT_ENABLE )
    if (s_crcState == CRC_MODULE_UNINITIALIZED)
    {
        (void)Det_ReportError((uint16)CDD_CRC_H_MODULE_ID, CRC_INSTANCE_ID, CRC_SETOUTPUTREVERSEMODE_ID, CRC_E_UNINIT);
        result = E_NOT_OK;
    }
    else if ( (Flag != TRUE) && (Flag != FALSE) )
    {
        (void)Det_ReportError((uint16)CDD_CRC_H_MODULE_ID, CRC_INSTANCE_ID, CRC_SETOUTPUTREVERSEMODE_ID, CRC_E_PARA);
        result = E_NOT_OK;
    }
    else
#endif
    {
        /* Set REVO bit */
        Crc_Hw_OperationReverseOutputData(Flag);
    }

    return result;
}

/*!
* @brief This function is used to set CRC_INITVAL register value
*
* @param[in]       InitValue    Target value to CRC_INITVAL register
* @param[out]      None
* @param[inout]    None
*
* @retval E_OK:     Successfully set CRC_INITVAL register
* @retval E_NOT_OK: Failed to set CRC_INITVAL register
*/
FUNC(Std_ReturnType, CRCU_CODE) Crc_SetInitReg(VAR(uint32, AUTOMATIC) InitValue)
{
    VAR(Std_ReturnType, AUTOMATIC) result = E_OK;

#if( STD_ON == CRC_DEV_ERR_DETECT_ENABLE )
    if (s_crcState == CRC_MODULE_UNINITIALIZED)
    {
        (void)Det_ReportError((uint16)CDD_CRC_H_MODULE_ID, CRC_INSTANCE_ID, CRC_SETINITREG_ID, CRC_E_UNINIT);
        result = E_NOT_OK;
    }
    else
#endif
    {
        /* Set CRC_INITVAL register */
        Crc_Hw_WriteInitRegister(InitValue);
    }

    return result;
}

/*!
* @brief This function is used to calculate crc value according to a uint32 value
*
* @param[in]       Data                Target value to used calculate crc value
* @param[out]      pCalculateValues    struct to store crc value
* @param[inout]    None
*
* @retval E_OK:     Successfully calculate crc value according to a uint32 value
* @retval E_NOT_OK: Failed to calculate crc value according to a uint32 value
*/
FUNC(Std_ReturnType, CRCU_CODE) Crc_CalculateCRC(VAR(uint32, AUTOMATIC) Data,
                                               P2VAR(Crc_CalculateResultType, AUTOMATIC, CRC_APPL_DATA) pCalculateValues)
{
    VAR(Std_ReturnType, AUTOMATIC) result = E_OK;

#if( STD_ON == CRC_DEV_ERR_DETECT_ENABLE )
    if (pCalculateValues == NULL_PTR)
    {
        (void)Det_ReportError((uint16)CDD_CRC_H_MODULE_ID, CRC_INSTANCE_ID, CRC_CALCULATECRC_ID, CRC_E_POINTER);
        result = E_NOT_OK;
    }
    else if (s_crcState == CRC_MODULE_UNINITIALIZED)
    {
        (void)Det_ReportError((uint16)CDD_CRC_H_MODULE_ID, CRC_INSTANCE_ID, CRC_CALCULATECRC_ID, CRC_E_UNINIT);
        result = E_NOT_OK;
        /* Set pCalculateValues's member value */
        pCalculateValues->check = E_NOT_OK;
        pCalculateValues->crcValue = 0;
    }
    else
#endif
    {
#if( STD_ON == CRC_DEV_ERR_DETECT_ENABLE )
        pCalculateValues->check = E_OK;
#endif
        /* Calculate CRC value */
        pCalculateValues->crcValue = Crc_Hw_CalculateCRC(Data);
    }

    return result;
}

/*!
* @brief This function is used to calculate crc value according to a uint32 value block
*
* @param[in]       pBuffer             Target value block pointer to used calculate crc value
* @param[in]       BufferLength        element number, each element is a number of type uint32.
* @param[out]      pCalculateValues    struct to store crc value
* @param[inout]    None
*
* @retval E_OK:     Successfully calculate crc value according to a uint32 value block
* @retval E_NOT_OK: Failed to calculate crc value according to a uint32 value block
*/
FUNC(Std_ReturnType, CRCU_CODE) Crc_CalculateBlockCRC(P2CONST(uint32, AUTOMATIC, CRC_APPL_DATA) pBuffer,
                                                          VAR(uint32, AUTOMATIC) BufferLength,
                                                        P2VAR(Crc_CalculateResultType, AUTOMATIC, CRC_APPL_DATA) pCalculateValues)
{
    VAR(Std_ReturnType, AUTOMATIC) result = E_OK;

#if( STD_ON == CRC_DEV_ERR_DETECT_ENABLE )
    if (pCalculateValues == NULL_PTR)
    {
        (void)Det_ReportError((uint16)CDD_CRC_H_MODULE_ID, CRC_INSTANCE_ID, CRC_CALCULATEBLOCKCRC_ID, CRC_E_POINTER);
        result = E_NOT_OK;
    }
    else if (pBuffer == NULL_PTR)
    {
        (void)Det_ReportError((uint16)CDD_CRC_H_MODULE_ID, CRC_INSTANCE_ID, CRC_CALCULATEBLOCKCRC_ID, CRC_E_POINTER);
        result = E_NOT_OK;
        /* Set pCalculateValues's member value */
        pCalculateValues->check = E_NOT_OK;
        pCalculateValues->crcValue = 0;
    }
    else if (BufferLength == 0U)
    {
        (void)Det_ReportError((uint16)CDD_CRC_H_MODULE_ID, CRC_INSTANCE_ID, CRC_CALCULATEBLOCKCRC_ID, CRC_E_LENGTH);
        result = E_NOT_OK;
        /* Set pCalculateValues's member value */
        pCalculateValues->check = E_NOT_OK;
        pCalculateValues->crcValue = 0;
    }
    else if (s_crcState == CRC_MODULE_UNINITIALIZED)
    {
        (void)Det_ReportError((uint16)CDD_CRC_H_MODULE_ID, CRC_INSTANCE_ID, CRC_CALCULATEBLOCKCRC_ID, CRC_E_UNINIT);
        result = E_NOT_OK;
        /* Set pCalculateValues's member value */
        pCalculateValues->check = E_NOT_OK;
        pCalculateValues->crcValue = 0;
    }
    else
#endif
    {
#if( STD_ON == CRC_DEV_ERR_DETECT_ENABLE )
        pCalculateValues->check = E_OK;
#endif
        /* Calculate CRC value */
        pCalculateValues->crcValue = Crc_Hw_CalculateBlockCRC(pBuffer, BufferLength);
    }

    return result;
}

/*!
* @brief This function is used to get CRC_DATA register value
*
* @param[in]       None
* @param[out]      pRegValue    struct to store register value
* @param[inout]    None
*
* @retval E_OK:     Successfully get CRC_DATA register value
* @retval E_NOT_OK: Failed to get CRC_DATA register value
*/
FUNC(Std_ReturnType, CRCU_CODE) Crc_GetCRCValue(P2VAR(Crc_RegValueType, AUTOMATIC, CRC_APPL_DATA) pRegValue)
{
    VAR(Std_ReturnType, AUTOMATIC) result = E_OK;

#if( STD_ON == CRC_DEV_ERR_DETECT_ENABLE )
    if (pRegValue == NULL_PTR)
    {
        (void)Det_ReportError((uint16)CDD_CRC_H_MODULE_ID, CRC_INSTANCE_ID, CRC_GETCRCVALUE_ID, CRC_E_POINTER);
        result = E_NOT_OK;
    }
    else if (s_crcState == CRC_MODULE_UNINITIALIZED)
    {
        (void)Det_ReportError((uint16)CDD_CRC_H_MODULE_ID, CRC_INSTANCE_ID, CRC_GETCRCVALUE_ID, CRC_E_UNINIT);
        result = E_NOT_OK;
        /* Set pRegValue's member value */
        pRegValue->check = E_NOT_OK;
        pRegValue->regValue = 0;
    }
    else
#endif
    {
#if( STD_ON == CRC_DEV_ERR_DETECT_ENABLE )
        pRegValue->check = E_OK;
#endif
        /* Get CRC_DATA register value */
        pRegValue->regValue = Crc_Hw_ReadCRC();
    }

    return result;
}

/*!
* @brief This function is used to set CRC_INDATA register value
*
* @param[in]       InitValue    Target value to set CRC_INDATA register
* @param[out]      None
* @param[inout]    None
*
* @retval E_OK:     Successfully set CRC_INDATA register
* @retval E_NOT_OK: Failed to set CRC_INDATA register
*/
FUNC(Std_ReturnType, CRCU_CODE) Crc_SetIndataRegValue(VAR(uint8, AUTOMATIC) InitValue)
{
    VAR(Std_ReturnType, AUTOMATIC) result = E_OK;

#if( STD_ON == CRC_DEV_ERR_DETECT_ENABLE )
    if (s_crcState == CRC_MODULE_UNINITIALIZED)
    {
        (void)Det_ReportError((uint16)CDD_CRC_H_MODULE_ID, CRC_INSTANCE_ID, CRC_SETINDATAREGVALUE_ID, CRC_E_UNINIT);
        result = E_NOT_OK;
    }
    else
#endif
    {
        /* Set CRC_INDATA register */
        Crc_Hw_WriteIDRegister(InitValue);
    }

    return result;
}

/*!
* @brief This function is used to get CRC_INDATA register value
*
* @param[in]       None
* @param[out]      pRegValue    struct to store register value
* @param[inout]    None
*
* @retval E_OK:     Successfully get CRC_INDATA register value
* @retval E_NOT_OK: Failed to get CRC_INDATA register value
*/
FUNC(Std_ReturnType, CRCU_CODE) Crc_GetIndataRegValue(P2VAR(Crc_RegValueType, AUTOMATIC, CRC_APPL_DATA) pRegValue)
{
    VAR(Std_ReturnType, AUTOMATIC) result = E_OK;

#if( STD_ON == CRC_DEV_ERR_DETECT_ENABLE )
    if (pRegValue == NULL_PTR)
    {
        (void)Det_ReportError((uint16)CDD_CRC_H_MODULE_ID, CRC_INSTANCE_ID, CRC_GETINDATAREGVALUE_ID, CRC_E_POINTER);
        result = E_NOT_OK;
    }
    else if (s_crcState == CRC_MODULE_UNINITIALIZED)
    {
        (void)Det_ReportError((uint16)CDD_CRC_H_MODULE_ID, CRC_INSTANCE_ID, CRC_GETINDATAREGVALUE_ID, CRC_E_UNINIT);
        result = E_NOT_OK;
        /* Set pRegValue's member value */
        pRegValue->check = E_NOT_OK;
        pRegValue->regValue = 0;
    }
    else
#endif
    {
#if( STD_ON == CRC_DEV_ERR_DETECT_ENABLE )
        pRegValue->check = E_OK;
#endif
        /* Get CRC_INDATA register value */
        pRegValue->regValue = Crc_Hw_ReadIDRegister();
    }

    return result;
}


/*!
* @brief This function is used to get CRC software version
*
* @param[in]       None
* @param[out]      pVersionInfoPtr    used to store CRC software version
* @param[inout]    None
*
*/
#if( STD_ON == CRC_VERSION_INFO_API_ENABLE )
FUNC(void, CRCU_CODE) Crc_GetVersionInfo(P2VAR(Std_VersionInfoType, AUTOMATIC, CRCU_APPL_CONST) pVersionInfoPtr)
{
#if( STD_ON == CRC_DEV_ERR_DETECT_ENABLE )
    if (NULL_PTR == pVersionInfoPtr)
    {
        (void)Det_ReportError((uint16)CDD_CRC_H_MODULE_ID, CRC_INSTANCE_ID, CRC_GETVERSIONINFO_ID, CRC_E_POINTER);
    }
    else
#endif
    {
        pVersionInfoPtr->moduleID = (uint16)CDD_CRC_H_MODULE_ID;
        pVersionInfoPtr->vendorID  = (uint16)CDD_CRC_H_VENDOR_ID;
        pVersionInfoPtr->sw_major_version = (uint8)CDD_CRC_H_SW_MAJOR_VERSION;
        pVersionInfoPtr->sw_minor_version = (uint8)CDD_CRC_H_SW_MINOR_VERSION;
        pVersionInfoPtr->sw_patch_version = (uint8)CDD_CRC_H_SW_PATCH_VERSION;
    }
}
#endif

/**@} end of group CRC_Fuctions */

#define CRCU_STOP_SEC_CODE
#include "Crc_MemMap.h"

#ifdef __cplusplus
}
#endif

/**@} end of group CRC_Driver */
/**@} end of group G32A10xx_StdPeriphDriver */

