/*!
* @file     Irme_SmsTypes.h
*
* @version  1.0.0
*
* @brief    The header of Type and domain declarations of IRME moudle
*
* @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.
*/

/*
* MISRA-C:2012 compliance checks
*
*      Irme_SmsTypes_c_MISRA_REF1
*          Breaks the required M3CM Rule-1.2 of MISRA 2012 guidelines,
*          Language extensions should not be used.
*/

#ifndef IRME_SMSTYPES_h
#define IRME_SMSTYPES_h

#ifdef __cplusplus
extern "C"{
#endif

#include "Std_Types.h"
#include "SchM_Irme.h"
#include "Irme_SmsReg.h"

/** @addtogroup G32A10xx_StdPeriphDriver
  @{
*/

/** @defgroup IRME_Driver
  * @brief IRME driver modules
  @{
*/

/** @defgroup IRME_Macros
  @{
*/
/***********************************************************************************************************************
                                    VENDOR ID & AUTOSAR VERSION INFO
***********************************************************************************************************************/
/** Vendor ID (vendorId) of the dedicated implementation of this module according to the AUTOSAR vendor list. */
#define IRME_SMS_TYPES_H_VENDOR_ID                         0x00C1U
/** Module ID of this module, as defined in the BSW Module List. */
#define IRME_SMS_TYPES_H_MODULE_ID                         0x0000U
/** Major version number of AUTOSAR release on which the appropriate implementation is based on. */
#define IRME_SMS_TYPES_H_AR_RELEASE_MAJOR_VERSION          0x04U
/** Minor version number of AUTOSAR release on which the appropriate implementation is based on. */
#define IRME_SMS_TYPES_H_AR_RELEASE_MINOR_VERSION          0x04U
/** Revision version number of AUTOSAR release on which the appropriate implementation is based on. */
#define IRME_SMS_TYPES_H_AR_RELEASE_REVISION_VERSION       0x00U
/** Major version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define IRME_SMS_TYPES_H_SW_MAJOR_VERSION                  0x01U
/** Minor version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define IRME_SMS_TYPES_H_SW_MINOR_VERSION                  0x00U
/** Patch level version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define IRME_SMS_TYPES_H_SW_PATCH_VERSION                  0x00U

/**@} end of group IRME_Macros */

/**********************************************************************************************************************
                                  VERSION INFOMATION VERIFICATION
***********************************************************************************************************************/



/***********************************************************************************************************
                                            MACRO DEFINITION
************************************************************************************************************/
/** @defgroup IRME_Macros
  @{
*/

/** This is the return value indicating pending fault detected when calling API Irme_Geterrors() */
#define E_PENDING_FAULT_DETECTED                 ((Std_ReturnType)2)

/** Mask bits value of the fault pool */
#define IRME_FAULT_POOL_MASK                     ((1UL << IRME_FAULT_POOL_SHIFT)-1UL)
/** Shift bits value of the fault pool */
#define IRME_FAULT_POOL_SHIFT                    (0x05U)

/** Total count of all errors */
#define IRME_FAULTS_TOTAL_COUNT                  (0x04U)

#define SMS_FAULT_REGISTERS_COUNT                (1U) 

/** Verigy if the fault id is in the specified range */
#define IRME_FAULT_ID_WITHIN_SCOPE(FaultIndex)   ((uint8)IRME_FAULTS_TOTAL_COUNT > (uint8)FaultIndex)

/** SRAM start address */
#define SMS_RAM_START_ADDRESS                    (0x20000000U)

/**@} end of group IRME_Macros */

/**********************************************************************************************************************
                                             OTHER TYPE DEFINITION
***********************************************************************************************************************/
/** @defgroup IRME_Structure
  @{
*/

/** Defines the fault id */
typedef uint8 Irme_FaultIdType;

/** An array containing faults reported by the IRME moudle */
typedef uint32 Irme_IPW_FaultPoolType[SMS_FAULT_REGISTERS_COUNT];

/**
 * @brief    The fault pool struct type.
 */
typedef struct
{
    Std_ReturnType            errStatus;        //!< The return value of calling API Irme_AcquireErrors().
    /*** @warning Irme_SmsTypes_c_MISRA_REF1 [E] Treating array of length one as potentially flexible member. */
    Irme_IPW_FaultPoolType    faultPool;        //!< The fault status pool.
} Irme_FaultPoolType;

/** The states of the functions of IRME moudle driver.These functions that is not re-entrant should 
    use this type to protect from preempting itself */
typedef uint8 Irme_ApiStateType;

/** The states of the IRME moudle driver. */
typedef uint8 Irme_StateType;

/**
 * @brief    Defines the error injecting type.
 */
typedef enum
{
    IRME_INJECT_NO_ERROR = 0U,
    IRME_INJECT_SINGLE_BIT_ERROR = 0x01U,
    IRME_INJECT_DOUBLE_BIT_ERROR = 0x02U,
    IRME_INJECT_TRIPLE_BIT_ERROR = 0x03U
} Irme_InjectBitErrType;

/** The notification functions definition */
typedef void (*Irme_ErrorNotifyFunctionType)(Irme_FaultIdType FaultID, uint32 FaultAddr);

/**
* @brief    The type definition of SMS configuration struct 
*/
typedef struct
{
  VAR(uint32, IRME_VAR)                 smsEccCfgVal;      //!< SMS  register configuration
  VAR(uint32, IRME_VAR)                 smsIntRMVal;       //!< SMS interrupt mask register configuration
  VAR(uint32, IRME_VAR)                 injectRamAddr;     //!< The address to be injectded faults
  CONST(Irme_ErrorNotifyFunctionType, AUTOMATIC)     errNotificationFunction; //!< The Notification function callback.
} Irme_SmsConfigType;

/**@} end of group IRME_Structure */

/***********************************************************************************************************
                                            MACRO DEFINITION
************************************************************************************************************/
/** @defgroup IRME_Macros
  @{
*/

#define RD_ERR_SIN_ID                    ((Irme_FaultIdType)0U)
#define RD_ERR_DBL_ID                    ((Irme_FaultIdType)1U)
#define RMW_ERR_SIN_ID                   ((Irme_FaultIdType)2U)
#define RMW_ERR_DBL_ID                   ((Irme_FaultIdType)3U)

/**@} end of group IRME_Macros */

#ifdef __cplusplus
}
#endif

#endif

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