/*!
* @file     CDD_Crc.h
*
* @version  1.0.0
*
* @brief    Header file of crc unit 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.
*/

#ifndef CRC_H
#define CRC_H

#ifdef __cplusplus
extern "C"{
#endif

#include "CDD_Crc_Cfg.h"

/** @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_H_VENDOR_ID                        0x00C1U
/** Module ID of this module, as defined in the BSW Module List. */
#define CDD_CRC_H_MODULE_ID                        0x00FFU
/** Major version number of AUTOSAR release on which the appropriate implementation is based on. */
#define CDD_CRC_H_AR_RELEASE_MAJOR_VERSION         0x04U
/** Minor version number of AUTOSAR release on which the appropriate implementation is based on. */
#define CDD_CRC_H_AR_RELEASE_MINOR_VERSION         0x04U
/** Revision version number of AUTOSAR release on which the appropriate implementation is based on. */
#define CDD_CRC_H_AR_RELEASE_REVISION_VERSION      0x00U
/** Major version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define CDD_CRC_H_SW_MAJOR_VERSION                 0x01U
/** Minor version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define CDD_CRC_H_SW_MINOR_VERSION                 0x00U
/** Patch level version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define CDD_CRC_H_SW_PATCH_VERSION                 0x00U

/**@} end of group CRC_Macros */

/**************************************************************************
                    VERSION INFOMATION VERIFICATION
**************************************************************************/
/* Make sure the vendor id is the same between CDD_Crc.h and CDD_Crc_Cfg.h */
#if (CDD_CRC_H_VENDOR_ID != CDD_CRC_CFG_H_VENDOR_ID)
    #error "Vendor id mismatch between CDD_Crc.h and CDD_Crc_Cfg.h"
#endif
/* Make sure the AUTOSAR major version number is the same between CDD_Crc.h and CDD_Crc_Cfg.h */
#if (CDD_CRC_H_AR_RELEASE_MAJOR_VERSION != CDD_CRC_CFG_H_AR_RELEASE_MAJOR_VERSION)
    #error "AUTOSAR Major Version Number mismatch between CDD_Crc.h and CDD_Crc_Cfg.h"
#endif
/* Make sure the AUTOSAR minor version number is the same between CDD_Crc.h and CDD_Crc_Cfg.h */
#if (CDD_CRC_H_AR_RELEASE_MINOR_VERSION != CDD_CRC_CFG_H_AR_RELEASE_MINOR_VERSION)
    #error "AUTOSAR Minor Version Number mismatch between CDD_Crc.h and CDD_Crc_Cfg.h"
#endif
/* Make sure the AUTOSAR revision version number is the same between CDD_Crc.h and CDD_Crc_Cfg.h */
#if (CDD_CRC_H_AR_RELEASE_REVISION_VERSION != CDD_CRC_CFG_H_AR_RELEASE_REVISION_VERSION)
    #error "AUTOSAR Revision Version Number mismatch between CDD_Crc.h and CDD_Crc_Cfg.h"
#endif
/* Make sure the software major version number is the same between CDD_Crc.h and CDD_Crc_Cfg.h */
#if (CDD_CRC_H_SW_MAJOR_VERSION != CDD_CRC_CFG_H_SW_MAJOR_VERSION)
    #error "Software Major Version Number mismatch between CDD_Crc.h and CDD_Crc_Cfg.h"
#endif
/* Make sure the software minor version number is the same between CDD_Crc.h and CDD_Crc_Cfg.h */
#if (CDD_CRC_H_SW_MINOR_VERSION != CDD_CRC_CFG_H_SW_MINOR_VERSION)
    #error "Software Minor Version Number mismatch between CDD_Crc.h and CDD_Crc_Cfg.h"
#endif
/* Make sure the software patch version number is the same between CDD_Crc.h and CDD_Crc_Cfg.h */
#if (CDD_CRC_H_SW_PATCH_VERSION != CDD_CRC_CFG_H_SW_PATCH_VERSION)
    #error "Software Patch Version Number mismatch between CDD_Crc.h and CDD_Crc_Cfg.h"
#endif

/**************************************************************************
                    MACRO DEFINITION
**************************************************************************/
/** @defgroup CRC_Macros
  @{
*/

/** ID index of Crc Module starting at 0 */
#define CRC_INSTANCE_ID                    (0U)

/** Crc_Init: Service ID */
#define CRC_INIT_ID                        ((uint8)0x00U)
/** Crc_DeInit: Service ID */
#define CRC_DEINIT_ID                      ((uint8)0x01U)
/** Crc_ResetDataReg: Service ID */
#define CRC_RESETDATAREG_ID                ((uint8)0x02U)
/** Crc_SetInputReverseMode: Service ID */
#define CRC_SETINPUTREVERSEMODE_ID         ((uint8)0x03U)
/** Crc_SetOutputReverseMode: Service ID */
#define CRC_SETOUTPUTREVERSEMODE_ID        ((uint8)0x04U)
/** Crc_SetInitReg: Service ID */
#define CRC_SETINITREG_ID                  ((uint8)0x05U)
/** CRC_CalculateCRC: Service ID */
#define CRC_CALCULATECRC_ID                ((uint8)0x06U)
/** CRC_CalculateBlockCRC: Service ID */
#define CRC_CALCULATEBLOCKCRC_ID           ((uint8)0x07U)
/** CRC_GetCRCValue: Service ID */
#define CRC_GETCRCVALUE_ID                 ((uint8)0x08U)
/** CRC_SetIndataRegValue: Service ID */
#define CRC_SETINDATAREGVALUE_ID           ((uint8)0x09U)
/** CRC_GetIndataRegValue: Service ID */
#define CRC_GETINDATAREGVALUE_ID           ((uint8)0x0AU)
/** Crc_GetVersionInfo: Service ID */
#define CRC_GETVERSIONINFO_ID              ((uint8)0x0BU)

/** API error service ID without initialized */
#define CRC_E_UNINIT                       ((uint8)0x00U)
/** API error service ID with invalid parameter */
#define CRC_E_PARA                         ((uint8)0x01U)
/** API error service ID with invalid pointer parameter, eg: NULL_PTR. */
#define CRC_E_POINTER                      ((uint8)0x02U)
/** API error service ID without CRC driver and hardware already initialized */
#define CRC_E_ALREADY_INITIALIZED          ((uint8)0x03U)
/** API error service ID with invalid length parameter, eg: 0. */
#define CRC_E_LENGTH                       ((uint8)0x04U)

/**@} end of group CRC_Macros */

/**************************************************************************
                    STRUCT DEFINITION
**************************************************************************/
/** @defgroup CRC_Structure
  @{
*/

/**
 * @brief    This structure used to return calculate result
 */
typedef struct
{
#if( STD_ON == CRC_DEV_ERR_DETECT_ENABLE )
    Std_ReturnType   check;   //!< Indicates whether the result is valid
#endif
    uint32   crcValue;        //!< CRC calculation value
} Crc_CalculateResultType;

/**
 * @brief    This structure used to return register value
 */
typedef struct
{
#if( STD_ON == CRC_DEV_ERR_DETECT_ENABLE )
    Std_ReturnType   check;   //!< Indicates whether the result is valid
#endif
    uint32   regValue;        //!< CRC register value
} Crc_RegValueType;

/**@} end of group CRC_Structure */

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

/** @defgroup CRC_Fuctions
  @{
*/

FUNC(Std_ReturnType, CRCU_CODE) Crc_Init(void);

FUNC(Std_ReturnType, CRCU_CODE) Crc_DeInit(void);

FUNC(Std_ReturnType, CRCU_CODE) Crc_ResetDataReg(void);

FUNC(Std_ReturnType, CRCU_CODE) Crc_SetInputReverseMode(VAR(Crc_ReverseInputDataType, AUTOMATIC) Mode);

FUNC(Std_ReturnType, CRCU_CODE) Crc_SetOutputReverseMode(VAR(boolean, AUTOMATIC) Flag);

FUNC(Std_ReturnType, CRCU_CODE) Crc_SetInitReg(VAR(uint32, AUTOMATIC) InitValue);

FUNC(Std_ReturnType, CRCU_CODE) Crc_CalculateCRC(VAR(uint32, AUTOMATIC) Data,
                                               P2VAR(Crc_CalculateResultType, AUTOMATIC, CRC_APPL_DATA) pCalculateValues);

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);

FUNC(Std_ReturnType, CRCU_CODE) Crc_GetCRCValue(P2VAR(Crc_RegValueType, AUTOMATIC, CRC_APPL_DATA) pRegValue);

FUNC(Std_ReturnType, CRCU_CODE) Crc_SetIndataRegValue(VAR(uint8, AUTOMATIC) InitValue);

FUNC(Std_ReturnType, CRCU_CODE) Crc_GetIndataRegValue(P2VAR(Crc_RegValueType, AUTOMATIC, CRC_APPL_DATA) pRegValue);

#if (STD_ON == CRC_VERSION_INFO_API_ENABLE)
FUNC(void, CRCU_CODE) Crc_GetVersionInfo(P2VAR(Std_VersionInfoType, AUTOMATIC, CRCU_APPL_CONST) pVersionInfoPtr);
#endif

/**@} end of group CRC_Fuctions */

#define CRCU_STOP_SEC_CODE
#include "Crc_MemMap.h"

#ifdef __cplusplus
}
#endif

#endif

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