/*!
* @file     Det.h
*
* @version  1.0.0
*
* @brief    The header of the det 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 DET_H
#define DET_H

#ifdef __cplusplus
extern "C"{
#endif

/** @addtogroup G32A10xx_StdPeriphDriver
  @{
*/

/** @defgroup DET_Driver
  * @brief DET driver modules
  @{
*/

/** @defgroup DET_Macros
  @{
*/
/***********************************************************************************************************************
                                    VENDOR ID & AUTOSAR VERSION INFO
***********************************************************************************************************************/
/** Vendor ID (vendorId) of the dedicated implementation of this module according to the AUTOSAR vendor list. */
#define DET_H_VENDOR_ID                        0x00C1U
/** Module ID of this module, as defined in the BSW Module List. */
#define DET_H_MODULE_ID                        0x000FU
/** Major version number of AUTOSAR release on which the appropriate implementation is based on. */
#define DET_H_AR_RELEASE_MAJOR_VERSION         0x04U
/** Minor version number of AUTOSAR release on which the appropriate implementation is based on. */
#define DET_H_AR_RELEASE_MINOR_VERSION         0x04U
/** Revision version number of AUTOSAR release on which the appropriate implementation is based on. */
#define DET_H_AR_RELEASE_REVISION_VERSION      0x00U
/** Major version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define DET_H_SW_MAJOR_VERSION                 0x01U
/** Minor version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define DET_H_SW_MINOR_VERSION                 0x00U
/** Patch level version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define DET_H_SW_PATCH_VERSION                 0x00U

/**********************************************************************************************************************
                                            MACRO DEFINITION
***********************************************************************************************************************/
#define DET_MAX_EVENTS_NUM    ((uint32)8U)

/**@} end of group DET_Macros */

/**********************************************************************************************************************
                                             GLOBAL VARIABLE
***********************************************************************************************************************/
/** @defgroup DET_Variable
  @{
*/

/** global variables about overflow error */
extern VAR(uint8, DET_VAR)       g_detOverflowEvent;
extern VAR(uint8, DET_VAR)       g_detRuntimeOverflowEvent;
extern VAR(uint8, DET_VAR)       g_detTransOverflowEvent;

/** global variables to count error */
extern VAR(uint32, DET_VAR)      g_detEventErrNum;
extern VAR(uint32, DET_VAR)      g_detRuntimeEventErrNum;
extern VAR(uint32, DET_VAR)      g_detTransEventErrNum;

/** Variables to store last DET transient error */
extern VAR(uint8 , DET_VAR)      g_detTransInstanceId[DET_MAX_EVENTS_NUM];
extern VAR(uint8 , DET_VAR)      g_detTransApiId[DET_MAX_EVENTS_NUM];
extern VAR(uint8 , DET_VAR)      g_detTransFaultId[DET_MAX_EVENTS_NUM];
extern VAR(uint16, DET_VAR)      g_detTransModuleId[DET_MAX_EVENTS_NUM];

/** Variables to store last DET runtime error */
extern VAR(uint8 , DET_VAR)      g_detRuntimeInstanceId[DET_MAX_EVENTS_NUM];
extern VAR(uint8 , DET_VAR)      g_detRuntimeApiId[DET_MAX_EVENTS_NUM];
extern VAR(uint8 , DET_VAR)      g_detRuntimeErrId[DET_MAX_EVENTS_NUM];
extern VAR(uint16, DET_VAR)      g_detRuntimeModuleId[DET_MAX_EVENTS_NUM];

/** The variables to store last DET error */
extern VAR(uint8 , DET_VAR)      g_detInstanceId[DET_MAX_EVENTS_NUM];
extern VAR(uint8 , DET_VAR)      g_detApiId[DET_MAX_EVENTS_NUM];
extern VAR(uint8 , DET_VAR)      g_detErrId[DET_MAX_EVENTS_NUM];
extern VAR(uint16, DET_VAR)      g_detModuleId[DET_MAX_EVENTS_NUM];

/**@} end of group DET_Variable */

/**********************************************************************************************************************
                                              FUNCTION DECLARATION
***********************************************************************************************************************/
/** @defgroup DET_Fuctions
  @{
*/

#ifndef ASR_REL_4_0_REV_0003
FUNC(Std_ReturnType, DET_CODE) Det_ReportRuntimeError(VAR(uint16, AUTOMATIC) ModuleId, VAR(uint8, AUTOMATIC) InstanceId,
                                                      VAR(uint8, AUTOMATIC) ApiId, VAR(uint8, AUTOMATIC) ErrorId);

FUNC(Std_ReturnType, DET_CODE) Det_ReportTransientFault(VAR(uint16, AUTOMATIC) ModuleId, VAR(uint8, AUTOMATIC) InstanceId,
                                                        VAR(uint8, AUTOMATIC) ApiId, VAR(uint8, AUTOMATIC) FaultId);
#endif

FUNC(Std_ReturnType, DET_CODE) Det_ReportError(VAR(uint16, AUTOMATIC) ModuleId, VAR(uint8, AUTOMATIC) InstanceId,
                                               VAR(uint8, AUTOMATIC) ApiId, VAR(uint8, AUTOMATIC) ErrorId);

FUNC(void, DET_CODE) Det_Init(void);

FUNC(void, DET_CODE) Det_Start(void);

/**@} end of group DET_Fuctions */

#ifdef __cplusplus
}
#endif

#endif

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