/**
*   @file    Mcem_Fccu.h
*   @implements     Mcem_Fccu.h_Artifact
*
*   @version 1.0.0
*
*   @brief   AUTOSAR Mcem - FCCUv2 IP layer API
*   @details FCCUv2 internal IP API of the MCEM module
*
*   @addtogroup MCEM_MODULE
*   @{
*/
/*==================================================================================================
*   Project              : AUTOSAR 4.3 MCAL
*   Platform             : PA
*   Peripheral           : Fccu
*   Dependencies         : none
*
*   Autosar Version      : 4.3.1
*   Autosar Revision     : ASR_REL_4_3_REV_0001
*   Autosar Conf.Variant :
*   SW Version           : 1.0.0
*   Build Version        : MPC5777C_MCAL_1_0_0_RTM_ASR_REL_4_3_REV_0001_20190315
*
*   (c) Copyright 2006-2016 Freescale Semiconductor, Inc. 
*       Copyright 2017-2019 NXP
*   All Rights Reserved.
==================================================================================================*/
/*==================================================================================================
==================================================================================================*/

#ifndef MCEM_FCCU_H
#define MCEM_FCCU_H

#ifdef __cplusplus
extern "C"{
#endif

/**
 *
 * @page misra_violations MISRA-C:2004 violations
 *
 * @section Mcem_Fccu_h_REF_1
 * Violates MISRA 2004 Required Rule 19.15, Precautions shall be taken in order to prevent the
 * contents of a header file being included twice.
 * This is not a violation since all header files are protected against multiple inclusions.
 *
 * @section [global]
 * Violates MISRA 2004 Required Rule 5.1, Exceeds 31 characters due to AUTOSAR compatibility
 */

/*==================================================================================================
*                                        INCLUDE FILES
* 1) system and project includes
* 2) needed interfaces from external units
* 3) internal and external interfaces from this unit
==================================================================================================*/
#include "Mcem_Fccu_Types.h"
#include "Reg_eSys_Fccu.h"
#if(STD_ON == MCEM_DEM_EXTENDED_DATA)
    #include "Mcem_DemErrors.h"
#endif
/*==================================================================================================
*                              SOURCE FILE VERSION INFORMATION
==================================================================================================*/

#define FCCU_VENDOR_ID                    43
#define FCCU_MODULE_ID                    0
#define FCCU_AR_RELEASE_MAJOR_VERSION     4
#define FCCU_AR_RELEASE_MINOR_VERSION     3
#define FCCU_AR_RELEASE_REVISION_VERSION  1
#define FCCU_SW_MAJOR_VERSION             1
#define FCCU_SW_MINOR_VERSION             0
#define FCCU_SW_PATCH_VERSION             0

/*==================================================================================================
*                                     FILE VERSION CHECKS
==================================================================================================*/
/* Check if current file and Mcem_Fccu_Types.h header file are of the same vendor */
#if (FCCU_VENDOR_ID != FCCU_TYPES_VENDOR_ID)
    #error "Mcem_Fccu.h and Mcem_Fccu_Types.h have different Vendor ids"
#endif
/* Check if current file and Mcem_Fccu_Types.h header file are of the same Autosar version */
#if ((FCCU_AR_RELEASE_MAJOR_VERSION != FCCU_TYPES_AR_RELEASE_MAJOR_VERSION) || \
     (FCCU_AR_RELEASE_MINOR_VERSION != FCCU_TYPES_AR_RELEASE_MINOR_VERSION) || \
     (FCCU_AR_RELEASE_REVISION_VERSION != FCCU_TYPES_AR_RELEASE_REVISION_VERSION))
    #error "AutoSar Version Numbers of Mcem_Fccu.h and Mcem_Fccu_Types.h are different"
#endif
/* Check if current file and Mcem_Fccu_Types.h header file are of the same Software version */
#if ((FCCU_SW_MAJOR_VERSION != FCCU_TYPES_SW_MAJOR_VERSION) || \
     (FCCU_SW_MINOR_VERSION != FCCU_TYPES_SW_MINOR_VERSION) || \
     (FCCU_SW_PATCH_VERSION != FCCU_TYPES_SW_PATCH_VERSION))
    #error "Software Version Numbers of Mcem_Fccu.h and Mcem_Fccu_Types.h are different"
#endif

/* Check if current file and Reg_eSys_Fccu.h header file are of the same vendor */
#if (FCCU_VENDOR_ID != FCCU_REG_VENDOR_ID)
    #error "Mcem_Fccu.h and Reg_eSys_Fccu.h have different Vendor ids"
#endif
/* Check if current file and Reg_eSys_Fccu.h header file are the same Autosar version */
#if ((FCCU_AR_RELEASE_MAJOR_VERSION != FCCU_REG_AR_RELEASE_MAJOR_VERSION) || \
     (FCCU_AR_RELEASE_MINOR_VERSION != FCCU_REG_AR_RELEASE_MINOR_VERSION) || \
     (FCCU_AR_RELEASE_REVISION_VERSION != FCCU_REG_AR_RELEASE_REVISION_VERSION))
    #error "AutoSar Version Numbers of Mcem_Fccu.h and Reg_eSys_Fccu.h are different"
#endif
/* Check if current file and Reg_eSys_Fccu.h header file are of the same Software version */
#if ((FCCU_SW_MAJOR_VERSION != FCCU_REG_SW_MAJOR_VERSION) || \
     (FCCU_SW_MINOR_VERSION != FCCU_REG_SW_MINOR_VERSION) || \
     (FCCU_SW_PATCH_VERSION != FCCU_REG_SW_PATCH_VERSION))
    #error "Software Version Numbers of Mcem_Fccu.h and Reg_eSys_Fccu.h are different"
#endif

/*==================================================================================================
*                                          CONSTANTS
==================================================================================================*/


/*==================================================================================================
*                                      DEFINES AND MACROS
==================================================================================================*/

/* 1 bit in 32-bit wide register */
#define FCCU_SHIFT_BIT_U32              (0x00000001UL)

/* value of register with no pending errors */
#define FCCU_NO_ERRORS_U32              (0x00000000UL)

/* maximal loop repetition while waiting for FCCU operation to finish */
#define FCCU_MAX_LOOP_COUNT_U8          (20U)

/* This value specifies that CTRL reg bitfields will not be configured */
#define FCCU_NO_CTRL_REG_CONFIGURATION  (0x00000000UL)

/* 1 bit in 32-bit wide register */
#define FCCU_CFG_TO_IRQ_U32              (0x00000001UL)
/*==================================================================================================
*                                             ENUMS
==================================================================================================*/


/*==================================================================================================
*                                STRUCTURES AND OTHER TYPEDEFS
==================================================================================================*/


/*==================================================================================================
*                                GLOBAL VARIABLE DECLARATIONS
==================================================================================================*/

#define MCEM_START_SEC_VAR_INIT_BOOLEAN
/* @violates @ref Mcem_Fccu_h_REF_1 precautions to prevent the contents of a header file being included twice */
#include "Mcem_MemMap.h"

extern volatile VAR(boolean,MCEM_VAR) Fccu_bCfgTimeoutExpired;

#define MCEM_STOP_SEC_VAR_INIT_BOOLEAN
/* @violates @ref Mcem_Fccu_h_REF_1 precautions to prevent the contents of a header file being included twice */
#include "Mcem_MemMap.h"

/*==================================================================================================
*                                    FUNCTION PROTOTYPES
==================================================================================================*/

#define MCEM_START_SEC_CODE
/* @violates @ref Mcem_Fccu_h_REF_1 precautions to prevent the contents of a header file being included twice */
#include "Mcem_MemMap.h"

FUNC(Std_ReturnType, MCEM_CODE) Mcem_Fccu_Init(P2CONST(Fccu_ConfigType, AUTOMATIC, MCEM_APPL_CONST) pConfigPtr);

FUNC(Std_ReturnType, MCEM_CODE) Mcem_Fccu_GetErrors(VAR(uint32,AUTOMATIC) pFaultContainer[], P2VAR(uint32,AUTOMATIC,MCEM_APPL_DATA) pFaultAccumulator, VAR(boolean, AUTOMATIC) bNmiCall);

FUNC(Std_ReturnType, MCEM_CODE) Mcem_Fccu_ClearFault(VAR(Mcem_FaultType, AUTOMATIC) nFaultId, VAR(boolean, AUTOMATIC) bNmiCall);

FUNC(void, MCEM_CODE) Mcem_Fccu_InjectFault(VAR(Mcem_FaultType, AUTOMATIC) nFaultId);

FUNC(boolean, MCEM_CODE) Mcem_Fccu_CheckValidFault(VAR(Mcem_FaultType, AUTOMATIC) nFaultId);

FUNC(void, MCEM_CODE) Mcem_Fccu_LockConfiguration( void );

FUNC(Std_ReturnType, MCEM_CODE) Mcem_Fccu_ExecuteOperationAndConfigureCtrlReg
(
    VAR(FccuOpType,AUTOMATIC) nOpType,
    VAR(uint32,    AUTOMATIC) u32CtrlConfig,
    VAR(boolean, AUTOMATIC) bNmiCall
);

FUNC(Std_ReturnType, MCEM_CODE) Mcem_Fccu_CheckNMI( void );

#if (STD_ON == MCEM_ENABLE_USER_MODE_SUPPORT)
    #ifdef MCEM_FCCU_REG_PROT_AVAILABLE
FUNC(void, MCEM_CODE) Mcem_Fccu_SetUserAccess( void );
    #endif
#endif

FUNC(void, MCEM_CODE) Mcem_Fccu_UnlockTrans( void );

#define MCEM_STOP_SEC_CODE
/* @violates @ref Mcem_Fccu_h_REF_1 precautions to prevent the contents of a header file being included twice */
#include "Mcem_MemMap.h"

#ifdef __cplusplus
}
#endif

#endif /*MCEM_FCCU_H*/

/** @} */
