/**
*   @file    Mcem_Fccu_Irq.c
*   @implements     Mcem_Fccu_Irq.c_Artifact
*
*   @version 1.0.0
*
*   @brief   AUTOSAR Mcem - FCCU ISRs implementation
*   @details Implementation of interrupt handlers for the FCCU IP 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.
==================================================================================================*/
/*==================================================================================================
==================================================================================================*/

#ifdef __cplusplus
extern "C"{
#endif

/**
 *
 * @page misra_violations MISRA-C:2004 violations
 *
 * @section Mcem_Fccu_Irq_c_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 Mcem_Fccu_Irq_c_REF_2
 * Violates MISRA 2004 Advisory Rule 19.1, #include statements in a file should only be preceded by other
 * preprocessor directives or comments.
 * Violated due to AUTOSAR requirement MEMMAP003.
 *
 * @section Mcem_Fccu_Irq_c_REF_3
 * Violates MISRA 2004 Required Rule 11.1, Conversions shall not be performed between a pointer...
 * Unvoidable when addressing memory mapped registers
 *
 * @section Mcem_Fccu_Irq_c_REF_4
 * Violates MISRA 2004 Required Rule 8.10, All declarations and definitions of objects 
 * or functions at file scope shall have internal linkage unless external linkage is required.
 * Possibly unused public API
 *
 * @section Mcem_Fccu_Irq_c_REF_5
 * Violates MISRA 2004 Advisory Rule 11.3, A cast should not be performed between a pointer type and an integral type
 * Unvoidable when addressing memory mapped registers
 *
 * @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
==================================================================================================*/
#define USER_MODE_REG_PROT_ENABLED (STD_OFF)
#include "SilRegMacros.h"
#include "Mcal.h"
#include "CDD_Mcem.h"
#include "CDD_Mcem_IrqHandler.h"
#include "CDD_Mcem_Cfg.h"
#include "Mcem_IPW.h"
#include "Mcem_Fccu.h"
#include "Reg_eSys_Fccu.h"


/*==================================================================================================
*                              SOURCE FILE VERSION INFORMATION
==================================================================================================*/

#define FCCU_IRQ_VENDOR_ID_C                      43
#define FCCU_IRQ_AR_RELEASE_MAJOR_VERSION_C       4
#define FCCU_IRQ_AR_RELEASE_MINOR_VERSION_C       3
#define FCCU_IRQ_AR_RELEASE_REVISION_VERSION_C    1
#define FCCU_IRQ_SW_MAJOR_VERSION_C               1
#define FCCU_IRQ_SW_MINOR_VERSION_C               0
#define FCCU_IRQ_SW_PATCH_VERSION_C               0

/*==================================================================================================
*                                     FILE VERSION CHECKS
==================================================================================================*/
/* Check if current file and CDD_Mcem.h header file are of the same vendor */
#if (FCCU_IRQ_VENDOR_ID_C != CDD_MCEM_VENDOR_ID)
    #error "Mcem_Fccu_Irq.c and CDD_Mcem.h have different Vendor ids"
#endif
/* Check if current file and CDD_Mcem.h header file are of the same Autosar version */
#if ((FCCU_IRQ_AR_RELEASE_MAJOR_VERSION_C    != CDD_MCEM_AR_RELEASE_MAJOR_VERSION) || \
     (FCCU_IRQ_AR_RELEASE_MINOR_VERSION_C    != CDD_MCEM_AR_RELEASE_MINOR_VERSION) || \
     (FCCU_IRQ_AR_RELEASE_REVISION_VERSION_C != CDD_MCEM_AR_RELEASE_REVISION_VERSION))
    #error "AutoSar Version Numbers of Mcem_Fccu_Irq.c and CDD_Mcem.h are different"
#endif
/* Check if current file and CDD_Mcem.h header file are of the same Software version */
#if ((FCCU_IRQ_SW_MAJOR_VERSION_C != CDD_MCEM_SW_MAJOR_VERSION) || \
     (FCCU_IRQ_SW_MINOR_VERSION_C != CDD_MCEM_SW_MINOR_VERSION) || \
     (FCCU_IRQ_SW_PATCH_VERSION_C != CDD_MCEM_SW_PATCH_VERSION))
    #error "Software Version Numbers of Mcem_Fccu_Irq.c and CDD_Mcem.h are different"
#endif


/* Check if current file and CDD_Mcem_IrqHandler.h header file are of the same vendor */
#if (FCCU_IRQ_VENDOR_ID_C != CDD_MCEM_IRQHANDLER_VENDOR_ID)
    #error "Mcem_Fccu_Irq.c and CDD_Mcem_IrqHandler.h have different Vendor ids"
#endif
/* Check if current file and CDD_Mcem_IrqHandler.h header file are of the same Autosar version */
#if ((FCCU_IRQ_AR_RELEASE_MAJOR_VERSION_C    != CDD_MCEM_IRQHANDLER_AR_RELEASE_MAJOR_VERSION) || \
     (FCCU_IRQ_AR_RELEASE_MINOR_VERSION_C    != CDD_MCEM_IRQHANDLER_AR_RELEASE_MINOR_VERSION) || \
     (FCCU_IRQ_AR_RELEASE_REVISION_VERSION_C != CDD_MCEM_IRQHANDLER_AR_RELEASE_REVISION_VERSION))
    #error "AutoSar Version Numbers of Mcem_Fccu_Irq.c and CDD_Mcem_IrqHandler.h are different"
#endif
/* Check if current file and CDD_Mcem_IrqHandler.h header file are of the same Software version */
#if ((FCCU_IRQ_SW_MAJOR_VERSION_C != CDD_MCEM_IRQHANDLER_SW_MAJOR_VERSION) || \
     (FCCU_IRQ_SW_MINOR_VERSION_C != CDD_MCEM_IRQHANDLER_SW_MINOR_VERSION) || \
     (FCCU_IRQ_SW_PATCH_VERSION_C != CDD_MCEM_IRQHANDLER_SW_PATCH_VERSION))
    #error "Software Version Numbers of Mcem_Fccu_Irq.c and CDD_Mcem_IrqHandler.h are different"
#endif

/* Check if current file and CDD_Mcem_Cfg.h header file are of the same vendor */
#if (FCCU_IRQ_VENDOR_ID_C != CDD_MCEM_VENDOR_ID_CFG)
    #error "Mcem_Fccu_Irq.c and CDD_Mcem_Cfg.h have different Vendor ids"
#endif
/* Check if current file and CDD_Mcem_Cfg.h header file are of the same Autosar version */
#if ((FCCU_IRQ_AR_RELEASE_MAJOR_VERSION_C    != CDD_MCEM_AR_RELEASE_MAJOR_VERSION_CFG) || \
     (FCCU_IRQ_AR_RELEASE_MINOR_VERSION_C    != CDD_MCEM_AR_RELEASE_MINOR_VERSION_CFG) || \
     (FCCU_IRQ_AR_RELEASE_REVISION_VERSION_C != CDD_MCEM_AR_RELEASE_REVISION_VERSION_CFG))
    #error "AutoSar Version Numbers of Mcem_Fccu_Irq.c and CDD_Mcem_Cfg.h are different"
#endif
/* Check if current file and CDD_Mcem_Cfg.h header file are of the same Software version */
#if ((FCCU_IRQ_SW_MAJOR_VERSION_C != CDD_MCEM_SW_MAJOR_VERSION_CFG) || \
     (FCCU_IRQ_SW_MINOR_VERSION_C != CDD_MCEM_SW_MINOR_VERSION_CFG) || \
     (FCCU_IRQ_SW_PATCH_VERSION_C != CDD_MCEM_SW_PATCH_VERSION_CFG))
    #error "Software Version Numbers of Mcem_Fccu_Irq.c and CDD_Mcem_Cfg.h are different"
#endif

/* Check if current file and Mcem_IPW.h header file are of the same vendor */
#if (FCCU_IRQ_VENDOR_ID_C != MCEM_IPW_VENDOR_ID)
    #error "Mcem_Fccu_Irq.c and Mcem_IPW.h have different Vendor ids"
#endif
/* Check if current file and Mcem_IPW.h header file are of the same Autosar version */
#if ((FCCU_IRQ_AR_RELEASE_MAJOR_VERSION_C    != MCEM_IPW_AR_RELEASE_MAJOR_VERSION) || \
     (FCCU_IRQ_AR_RELEASE_MINOR_VERSION_C    != MCEM_IPW_AR_RELEASE_MINOR_VERSION) || \
     (FCCU_IRQ_AR_RELEASE_REVISION_VERSION_C != MCEM_IPW_AR_RELEASE_REVISION_VERSION))
    #error "AutoSar Version Numbers of Mcem_Fccu_Irq.c and Mcem_IPW.h are different"
#endif
/* Check if current file and Mcem_IPW.h header file are of the same Software version */
#if ((FCCU_IRQ_SW_MAJOR_VERSION_C != MCEM_IPW_SW_MAJOR_VERSION) || \
     (FCCU_IRQ_SW_MINOR_VERSION_C != MCEM_IPW_SW_MINOR_VERSION) || \
     (FCCU_IRQ_SW_PATCH_VERSION_C != MCEM_IPW_SW_PATCH_VERSION))
    #error "Software Version Numbers of Mcem_Fccu_Irq.c and Mcem_IPW.h are different"
#endif


/* Check if current file and Mcem_Fccu.h header file are of the same vendor */
#if (FCCU_IRQ_VENDOR_ID_C != FCCU_VENDOR_ID)
    #error "Mcem_Fccu_Irq.c and Mcem_Fccu.h have different Vendor ids"
#endif
/* Check if current file and Mcem_Fccu.h header file are of the same Autosar version */
#if ((FCCU_IRQ_AR_RELEASE_MAJOR_VERSION_C    != FCCU_AR_RELEASE_MAJOR_VERSION) || \
     (FCCU_IRQ_AR_RELEASE_MINOR_VERSION_C    != FCCU_AR_RELEASE_MINOR_VERSION) || \
     (FCCU_IRQ_AR_RELEASE_REVISION_VERSION_C != FCCU_AR_RELEASE_REVISION_VERSION))
    #error "AutoSar Version Numbers of Mcem_Fccu_Irq.c and Mcem_Fccu.h are different"
#endif
/* Check if current file and Mcem_Fccu.h header file are of the same Software version */
#if ((FCCU_IRQ_SW_MAJOR_VERSION_C != FCCU_SW_MAJOR_VERSION) || \
     (FCCU_IRQ_SW_MINOR_VERSION_C != FCCU_SW_MINOR_VERSION) || \
     (FCCU_IRQ_SW_PATCH_VERSION_C != FCCU_SW_PATCH_VERSION))
    #error "Software Version Numbers of Mcem_Fccu_Irq.c and Mcem_Fccu.h are different"
#endif


/* Check if current file and Reg_eSys_Fccu.h header file are of the same vendor */
#if (FCCU_IRQ_VENDOR_ID_C != FCCU_REG_VENDOR_ID)
    #error "Mcem_Fccu_Irq.c and Reg_eSys_Fccu.h have different Vendor ids"
#endif
/* Check if current file and Reg_eSys_Fccu.hheader file are of the same Autosar version */
#if ((FCCU_IRQ_AR_RELEASE_MAJOR_VERSION_C    != FCCU_REG_AR_RELEASE_MAJOR_VERSION) || \
     (FCCU_IRQ_AR_RELEASE_MINOR_VERSION_C    != FCCU_REG_AR_RELEASE_MINOR_VERSION) || \
     (FCCU_IRQ_AR_RELEASE_REVISION_VERSION_C != FCCU_REG_AR_RELEASE_REVISION_VERSION))
    #error "AutoSar Version Numbers of Mcem_Fccu_Irq.c 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_IRQ_SW_MAJOR_VERSION_C != FCCU_REG_SW_MAJOR_VERSION) || \
     (FCCU_IRQ_SW_MINOR_VERSION_C != FCCU_REG_SW_MINOR_VERSION) || \
     (FCCU_IRQ_SW_PATCH_VERSION_C != FCCU_REG_SW_PATCH_VERSION))
    #error "Software Version Numbers of Mcem_Fccu_Irq.c and Reg_eSys_Fccu.h are different"
#endif


#ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
    /* Check if current file and Mcal.h header file are of the same Autosar version */
    #if ((FCCU_IRQ_AR_RELEASE_MAJOR_VERSION_C != MCAL_AR_RELEASE_MAJOR_VERSION) || \
         (FCCU_IRQ_AR_RELEASE_MINOR_VERSION_C != MCAL_AR_RELEASE_MINOR_VERSION))
        #error "AutoSar Version Numbers of Mcem_Fccu_Irq.c and Mcal.h are different"
    #endif
    
    /* Check if current file and SilRegMacros.h header file are of the same Autosar version */
    #if ((FCCU_IRQ_AR_RELEASE_MAJOR_VERSION_C != SILREGMACROS_AR_RELEASE_MAJOR_VERSION) || \
         (FCCU_IRQ_AR_RELEASE_MINOR_VERSION_C != SILREGMACROS_AR_RELEASE_MINOR_VERSION))
        #error "AutoSar Version Numbers of Mcem_Fccu_Irq.c and SilRegMacros.h are different"
    #endif
#endif

/*==================================================================================================
*                          LOCAL TYPEDEFS (STRUCTURES, UNIONS, ENUMS)
==================================================================================================*/


/*==================================================================================================
*                                       LOCAL MACROS
==================================================================================================*/


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


/*==================================================================================================
*                                      LOCAL VARIABLES
==================================================================================================*/


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


/*==================================================================================================
*                                      GLOBAL VARIABLES
==================================================================================================*/
#define MCEM_START_SEC_VAR_INIT_UNSPECIFIED
/* @violates @ref Mcem_Fccu_Irq_c_REF_1 precautions to prevent the contents of a header file being included twice */
#include "Mcem_MemMap.h"

#define MCEM_STOP_SEC_VAR_INIT_UNSPECIFIED
/* @violates @ref Mcem_Fccu_Irq_c_REF_1 precautions to prevent the contents of a header file being included twice */
/* @violates @ref Mcem_Fccu_Irq_c_REF_2 only preprocessor statements and comments before "#include". */
#include "Mcem_MemMap.h"


/*==================================================================================================
*                                   LOCAL FUNCTION PROTOTYPES
==================================================================================================*/
#define MCEM_START_SEC_CODE
/* @violates @ref Mcem_Fccu_Irq_c_REF_1 precautions to prevent the contents of a header file being included twice */
/* @violates @ref Mcem_Fccu_Irq_c_REF_2 only preprocessor statements and comments before "#include". */
#include "Mcem_MemMap.h"

#ifdef MCEM_MERGE_FCCU_ALARM_AND_CONFIG_TIMEOUT_IRQS
ISR(FCCU_ALARM_AND_TIMEOUT_ISR);
#else
ISR(FCCU_TIMEOUT_ISR);
ISR(FCCU_ALARM_ISR);
#endif /* MCEM_MERGE_FCCU_ALARM_AND_CONFIG_TIMEOUT_IRQS */

LOCAL_INLINE FUNC(boolean, MCEM_CODE) Mcem_ProcessFrozenStatus(VAR(FccuOpType, AUTOMATIC) nOperation, VAR(uint32, AUTOMATIC) nFrozenStatusRegister);

/*==================================================================================================
*                                       LOCAL FUNCTIONS
==================================================================================================*/
/**
* @brief Process each frozen status register
* @details Process given frozen status register and call high-layer ALARM interrupt handler.
* @param[in]    nOperation FCCU read frozen status operation to be triggered
* @param[in]    nFrozenStatusRegister FCCU frozen status register address to be read
* @return       logical
* @retval       FALSE in case of spurious call
* @retval       TRUE otherwise
* @implements   Mcem_ProcessFrozenStatus_Activity
*/
LOCAL_INLINE FUNC(boolean, MCEM_CODE) Mcem_ProcessFrozenStatus
(
    VAR(FccuOpType, AUTOMATIC) nOperation,
    VAR(uint32, AUTOMATIC) nFrozenStatusRegister 
)
{
    VAR(boolean, MCEM_VAR) bReturn = (boolean)TRUE;
    VAR(uint8, MCEM_VAR) uFaultID;
    VAR(uint32, MCEM_VAR) u32IEAddr;
    VAR(uint32, MCEM_VAR) u32IEMask;
    
    /* Read the frozen status register (Normal->Alarm) */
    if ( (Std_ReturnType)E_OK == Mcem_Fccu_ExecuteOperationAndConfigureCtrlReg( nOperation, FCCU_NO_CTRL_REG_CONFIGURATION, (boolean)FALSE ) )
    {
        /* @violates @ref Mcem_Fccu_Irq_c_REF_3 Pointer conversion */
        /* @violates @ref Mcem_Fccu_Irq_c_REF_5 Pointer conversion */
        uFaultID = (uint8)REG_READ32( nFrozenStatusRegister );
        if ( FCCU_FAULT_NONE_U8 != uFaultID )
        {
            if ( FCCU_FAULT_MULTIPLE_U8 == uFaultID )
            {
                /* Multiple faults recorded */
                Mcem_AlarmRoutine( MCEM_FCCU_MULTIPLE_FAULTS );
            }
            else    
            {
                /* Single fault: remove the linear shift introduced by the hardware and check the range */
                uFaultID -= FCCU_FAULT_INDEX_U8;
                if ( FCCU_NCF_TOTAL_NUMBER > uFaultID )
                {
                    /* Check ALARM Interrupt Enable for the given fault */
                    u32IEAddr = FCCU_IRQ_ALARM_EN0_ADDR32 + (((uint32)uFaultID/FCCU_REG_SIZE_U8)*(uint32)FCCU_REG_SIZE_BYTE_U8);
                    u32IEMask = (uint32)FCCU_SHIFT_BIT_U32 << (uint32)((uint32)uFaultID % FCCU_REG_SIZE_U8);
                    /* @violates @ref Mcem_Fccu_Irq_c_REF_3 Pointer conversion */
                    /* @violates @ref Mcem_Fccu_Irq_c_REF_5 Pointer conversion */
                    if ( (uint32)0UL != (uint32)(REG_READ32( u32IEAddr ) & u32IEMask) )
                    {
                        /* Valid fault with its specific ALARM Interrupt enabled */
                        Mcem_AlarmRoutine( uFaultID );
                    }
                    else
                    {   /* spurious interrupt, return FALSE */
                        bReturn = (boolean)FALSE;
                    }
                }
                else
                {
                    /* Invalid faultID received from HW. Call the AlarmRoutine with MultipleFaults parameter */
                    Mcem_AlarmRoutine( MCEM_FCCU_MULTIPLE_FAULTS );
                }
            }
        }
    }

    return bReturn;
}


/*==================================================================================================
*                                       GLOBAL FUNCTIONS
==================================================================================================*/

#ifdef MCEM_MERGE_FCCU_ALARM_AND_CONFIG_TIMEOUT_IRQS
/**
* @brief          Fccu Alarm and cconfiguration Timeout merged ISR.
* @details        This interrupt captures 2 possible events:
*                 1. When in Config mode, a timer is running. If a change from CONFIG to NORMAL mode
*                 is not done until the time expires, and automatic change to NORMAL mode is done,
*                 generating an interrupt (if not masked).
*                 2. An ALARM Interrupt is generated when a properly configured fault generates a transition 
*                 to the ALARM state. The status (fault triggering interrupt) can be obtained
*                 through frozen status registers.
*
* @isr            
*
* @implements     FCCU_ALARM_AND_TIMEOUT_ISR_Activity
*
* @violates @ref Mcem_Fccu_Irq_c_REF_4 Public API
*/
ISR(FCCU_ALARM_AND_TIMEOUT_ISR)
{
    VAR(uint32, MCEM_VAR) u32IrqStat = FCCU_NO_ERRORS_U32;

    /* Read Configuration Timeout Interrupt Status */
    /* @violates @ref Mcem_Fccu_Irq_c_REF_3 Pointer conversion */
    /* @violates @ref Mcem_Fccu_Irq_c_REF_5 Pointer conversion */
    u32IrqStat = REG_READ32( FCCU_IRQ_STAT_ADDR32 );

    /* Read and test ALARM Interrupt bit */
    if ( FCCU_NO_ERRORS_U32 != (u32IrqStat & FCCU_ALARM_IRQ_MASK_U32) )
    {   
        /* ALARM interrupt is pending (automatically cleared, no W1C available) */
        /* Process the frozen N2A (Normal -> Alarm) status register */
        if ( (boolean)TRUE != Mcem_ProcessFrozenStatus( FCCU_READ_N2AF_STATUS, FCCU_N2AF_STATUS_ADDR32 ) )
        {
            /* If not already processed, try the frozen F2A (Fault -> Alarm) status register */
            (void)Mcem_ProcessFrozenStatus( FCCU_READ_F2AF_STATUS, FCCU_F2A_STATUS_ADDR32 );
        }

        /* Clear frozen status registers */
        (void)Mcem_Fccu_ExecuteOperationAndConfigureCtrlReg( FCCU_CLEAR_FREEZE_STATUS_REGS, FCCU_NO_CTRL_REG_CONFIGURATION, (boolean)FALSE );
    }
    
    /* Read and test Configuration Timeout Interrupt bit */
    if ( FCCU_NO_ERRORS_U32 != (u32IrqStat & FCCU_TO_IRQ_MASK_U32) )
    { 
        /* Read and test Configuration Timeout Interrupt Enable bit */
        /* @violates @ref Mcem_Fccu_Irq_c_REF_3 Pointer conversion */
        /* @violates @ref Mcem_Fccu_Irq_c_REF_5 Pointer conversion */
        if ( 0UL != (REG_READ32( FCCU_IRQ_EN_ADDR32 ) & FCCU_TO_IRQ_ENABLE_MASK_U32) )
        {   /* TO interrupt enabled */
        
            /* Signal the timeout  */
            Mcem_CfgToRoutine();
            Fccu_bCfgTimeoutExpired = (boolean)TRUE;
        }   
        /* Clear Configuration Timeout Interrupt Flag */
        /* @violates @ref Mcem_Fccu_Irq_c_REF_3 Pointer conversion */
        /* @violates @ref Mcem_Fccu_Irq_c_REF_5 Pointer conversion */
        REG_WRITE32(FCCU_IRQ_STAT_ADDR32, u32IrqStat);
        /* confirm and wait to FCCU changed state  */
        (void)Mcem_Fccu_ExecuteOperationAndConfigureCtrlReg(FCCU_READ_FCCU_STATE, FCCU_NO_CTRL_REG_CONFIGURATION, (boolean)FALSE);
    }
    
    /* Exit the interrupt */
    /* @violates @ref Mcem_Fccu_Irq_c_REF_3 Pointer conversion */
    /* @violates @ref Mcem_Fccu_Irq_c_REF_5 Pointer conversion */
    EXIT_INTERRUPT();
}

#else /* MCEM_MERGE_FCCU_ALARM_AND_CONFIG_TIMEOUT_IRQS */

/*================================================================================================*/
/**
* @brief          Fccu configuration Timeout ISR.
* @details        When in Config mode, a timer is running. If a change from CONFIG to NORMAL mode
*                 is not done until the time expires, and automatic change to NORMAL mode is done,
*                 generating an interrupt (if not masked).
*
* @isr            
*
* @implements     FCCU_TIMEOUT_ISR_Activity
*
* @violates @ref Mcem_Fccu_Irq_c_REF_4 Public API
*/
ISR(FCCU_TIMEOUT_ISR)
{
    VAR(uint32, MCEM_VAR) u32IrqStat = FCCU_NO_ERRORS_U32;

    
    /* Read Configuration Timeout Interrupt Status */
    /* @violates @ref Mcem_Fccu_Irq_c_REF_3 Pointer conversion */
    /* @violates @ref Mcem_Fccu_Irq_c_REF_5 Pointer conversion */
    u32IrqStat = REG_READ32( FCCU_IRQ_STAT_ADDR32 );
    
    if ( (uint32)FCCU_NO_ERRORS_U32 != (u32IrqStat & FCCU_TO_IRQ_MASK_U32) )
    { 
        /* Read and test Configuration Timeout Interrupt Enable bit */
        /* @violates @ref Mcem_Fccu_Irq_c_REF_3 Pointer conversion */
        /* @violates @ref Mcem_Fccu_Irq_c_REF_5 Pointer conversion */
        if ( (uint32)0UL != ((uint32)REG_READ32( FCCU_IRQ_EN_ADDR32 ) & FCCU_TO_IRQ_ENABLE_MASK_U32) )
        {   /* TO interrupt enabled */
        
            /* Signal the timeout  */
            Mcem_CfgToRoutine();
            Fccu_bCfgTimeoutExpired = (boolean)TRUE;
        }   
        /* Clear Configuration Timeout Interrupt Flag */
        /* @violates @ref Mcem_Fccu_Irq_c_REF_3 Pointer conversion */
        /* @violates @ref Mcem_Fccu_Irq_c_REF_5 Pointer conversion */
        REG_WRITE32(FCCU_IRQ_STAT_ADDR32, u32IrqStat); 
    }
    
    /* Exit the interrupt */
    /* @violates @ref Mcem_Fccu_Irq_c_REF_3 Pointer conversion */
    /* @violates @ref Mcem_Fccu_Irq_c_REF_5 Pointer conversion */
    EXIT_INTERRUPT();
}


/**
* @brief          FCCU Alarm Interrupt routine.
* @details        An ALARM Interrupt is generated when a properly configured fault generates a transition 
*                 to the ALARM state. The status (fault triggering interrupt) can be obtained
*                 through frozen status registers.
*                 
* @isr          
*
* @implements     FCCU_ALARM_ISR_Activity
*
* @violates @ref Mcem_Fccu_Irq_c_REF_4 Public API
*/
ISR(FCCU_ALARM_ISR)
{

    /* Read and test ALARM Interrupt Enable bit */
    /* @violates @ref Mcem_Fccu_Irq_c_REF_3 Pointer conversion */
    /* @violates @ref Mcem_Fccu_Irq_c_REF_5 Pointer conversion */
    if ( (uint32)0UL != ((uint32)REG_READ32( FCCU_IRQ_STAT_ADDR32 ) & FCCU_ALARM_IRQ_MASK_U32) )
    {   /* ALARM interrupt is pending (automatically cleared, no W1C available) */

        /* Process the frozen N2A (Normal -> Alarm) status register */
        if ( (boolean)TRUE != Mcem_ProcessFrozenStatus( FCCU_READ_N2AF_STATUS, FCCU_N2AF_STATUS_ADDR32 ) )
        {
            
            /* If not already processed, try the frozen F2A (Fault -> Alarm) status register */
            (void)Mcem_ProcessFrozenStatus( FCCU_READ_F2AF_STATUS, FCCU_F2A_STATUS_ADDR32 );
   
        }

        /* Clear frozen status registers */
        (void)Mcem_Fccu_ExecuteOperationAndConfigureCtrlReg( FCCU_CLEAR_FREEZE_STATUS_REGS, FCCU_NO_CTRL_REG_CONFIGURATION, (boolean)FALSE );
    }

    /* @violates @ref Mcem_Fccu_Irq_c_REF_3 Pointer conversion */
    /* @violates @ref Mcem_Fccu_Irq_c_REF_5 Pointer conversion */
    EXIT_INTERRUPT();
}
#endif /* MCEM_MERGE_FCCU_ALARM_AND_CONFIG_TIMEOUT_IRQS */

#define MCEM_STOP_SEC_CODE
/* @violates @ref Mcem_Fccu_Irq_c_REF_1 precautions to prevent the contents of a header file being included twice */
/* @violates @ref Mcem_Fccu_Irq_c_REF_2 only preprocessor statements and comments before "#include". */
#include "Mcem_MemMap.h"

#ifdef __cplusplus
}
#endif

/** @} */
