/**
*   @file    Can_Irq.c
*   @implements Can_Irq.c_Artifact
*   @version 1.0.0
*
*   @brief   AUTOSAR Can - module interface
*   @details Interrupt routines for Can driver.
*
*   @addtogroup CAN_DRIVER
*   @{
*/
/*==================================================================================================
*   Project              : AUTOSAR 4.3 MCAL
*   Platform             : PA
*   Peripheral           : MCAN
*   Dependencies         : 
*
*   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:2012 violations
*
* @section [global]
*          Violates MISRA 2012 Required Rule 5.1, External identifiers shall be distinct.
*          The used compilers use more than 31 chars for identifiers.
*
* @section [global]
*          Violates MISRA 2012 Required Rule 5.2, Identifiers declared in the same scope and name space shall be distinct.
*          The used compilers use more than 31 chars for identifiers.
*
* @section [global]
*          Violates MISRA 2012 Required Rule 5.4, Macro identifiers shall be distinct.
*          The used compilers use more than 31 chars for identifiers.
*
* @section [global]
*          Violates MISRA 2012 Required Rule 5.5, Identifiers shall be distinct from macro names.
*          The used compilers use more than 31 chars for identifiers.
*
* @section [global]
*           Violates MISRA 2012 Advisory Rule 8.7,  Functions and objects should not be defined with external 
*           linkage if they are referenced in only one translation unit.
*           These functions represent the API of the driver. External linkage is needed to export the API.
*
* @section Can_Irq_c_REF_1
* Violates MISRA 2012 Advisory Rule 2.5, A project should not contain unused macro declarations.
* Declaration is reserved for future feature.
*
* @section Can_Irq_c_REF_2
* Violates MISRA 2012 Required Directive 4.10, Precautions shall be taken in order to prevent the contents
* of a header file being included more than once
* This violation is not fixed since the inclusion of <MA>_MemMap.h is as per AUTOSAR requirement [SWS_MemMap_00003].
*
* @section Can_Irq_c_REF_3
* Violates MISRA 2012 Advisory Rule 20.1, #include directives should only be preceded by preprocessor directives or comments.
* <MA>_MemMap.h is included after each section define in order to set the current memory section as defined by AUTOSAR.
*
* @section Can_Irq_c_REF_4
* Violates MISRA 2012 Required Rule 14.4, The controlling expression of an if statement and the controlling expression of an iteration-statement shall have 
* essentially Boolean type
* SMCAL coding guideline, Rule 3.3: Multi-statement macros shall be wrapped in a do–while loop, so the macro can appear safely inside if
* clauses or other places that expect a single statement or a statement block
*
*/

/*
(CAN035) The module Can_Irq.c contains the implementation of interrupt frames.The implementation of the interrupt service routine shall be in Can.c
*/

/*==================================================================================================
*                                        INCLUDE FILES
* 1) system and project includes
* 2) needed interfaces from external units
* 3) internal and external interfaces from this unit
==================================================================================================*/
/*
* @file           Can_Irq.c
*/
#include "Can_Cfg.h"
#include "Can_IPW.h"
#include "Mcal.h"
/*==================================================================================================
*                              SOURCE FILE VERSION INFORMATION
==================================================================================================*/
/* The integration of incompatible files shall be avoided. */
#define CAN_VENDOR_ID_IRQ_C                      43
/* @violates @ref Can_Irq_c_REF_1 MISRA 2012 Advisory Rule 2.5 */
#define CAN_MODULE_ID_IRQ_C                      80
#define CAN_AR_RELEASE_MAJOR_VERSION_IRQ_C       4
#define CAN_AR_RELEASE_MINOR_VERSION_IRQ_C       3
#define CAN_AR_RELEASE_REVISION_VERSION_IRQ_C    1
#define CAN_SW_MAJOR_VERSION_IRQ_C               1
#define CAN_SW_MINOR_VERSION_IRQ_C               0
#define CAN_SW_PATCH_VERSION_IRQ_C               0


/*==================================================================================================
*                                     FILE VERSION CHECKS
==================================================================================================*/

/* Check if current file and Can_IPW header file are of the same vendor */
#if (CAN_VENDOR_ID_IRQ_C != CAN_IPW_VENDOR_ID_H)
    #error "Can_Irq.c and Can_IPW.h have different vendor ids"
#endif
/* Check if current file and Can_IPW header file are of the same Autosar version */
#if ((CAN_AR_RELEASE_MAJOR_VERSION_IRQ_C    != CAN_IPW_AR_RELEASE_MAJOR_VERSION_H) || \
     (CAN_AR_RELEASE_MINOR_VERSION_IRQ_C    != CAN_IPW_AR_RELEASE_MINOR_VERSION_H) || \
     (CAN_AR_RELEASE_REVISION_VERSION_IRQ_C != CAN_IPW_AR_RELEASE_REVISION_VERSION_H))
    #error "AutoSar Version Numbers of Can_Irq.c and Can_IPW.h are different"
#endif
/* Check if current file and Can_IPW header file are of the same Software version */
#if ((CAN_SW_MAJOR_VERSION_IRQ_C != CAN_IPW_SW_MAJOR_VERSION_H) || \
     (CAN_SW_MINOR_VERSION_IRQ_C != CAN_IPW_SW_MINOR_VERSION_H) || \
     (CAN_SW_PATCH_VERSION_IRQ_C != CAN_IPW_SW_PATCH_VERSION_H))
    #error "Software Version Numbers of Can_Irq.c and Can_IPW.h are different"
#endif

/* Check if current file and Can_Cfg header file are of the same vendor */
#if (CAN_VENDOR_ID_IRQ_C != CAN_VENDOR_ID_CFG_H)
    #error "Can_Irq.c and Can_Cfg.h have different vendor ids"
#endif
/* Check if current file and Can_Cfg header file are of the same Autosar version */
#if ((CAN_AR_RELEASE_MAJOR_VERSION_IRQ_C    != CAN_AR_RELEASE_MAJOR_VERSION_CFG_H) || \
     (CAN_AR_RELEASE_MINOR_VERSION_IRQ_C    != CAN_AR_RELEASE_MINOR_VERSION_CFG_H) || \
     (CAN_AR_RELEASE_REVISION_VERSION_IRQ_C != CAN_AR_RELEASE_REVISION_VERSION_CFG_H))
    #error "AutoSar Version Numbers of Can_Irq.c and Can_Cfg.h are different"
#endif
/* Check if current file and Can_Cfg header file are of the same Software version */
#if ((CAN_SW_MAJOR_VERSION_IRQ_C != CAN_SW_MAJOR_VERSION_CFG_H) || \
     (CAN_SW_MINOR_VERSION_IRQ_C != CAN_SW_MINOR_VERSION_CFG_H) || \
     (CAN_SW_PATCH_VERSION_IRQ_C != CAN_SW_PATCH_VERSION_CFG_H))
    #error "Software Version Numbers of Can_Irq.c and Can_Cfg.h are different"
#endif

#ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
    /* Check if current file and Mcal header file are of the same version */
    #if ((CAN_AR_RELEASE_MAJOR_VERSION_IRQ_C != MCAL_AR_RELEASE_MAJOR_VERSION) || \
       (CAN_AR_RELEASE_MINOR_VERSION_IRQ_C != MCAL_AR_RELEASE_MINOR_VERSION))
        #error "Software Version Numbers of Can_Irq.c and Mcal.h are different"
    #endif
#endif

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


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


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


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


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


/*==================================================================================================
*                                      GLOBAL VARIABLES
==================================================================================================*/

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

/*==================================================================================================
*                                       LOCAL FUNCTIONS
==================================================================================================*/

#define CAN_START_SEC_CODE
/* @violates @ref Can_Irq_c_REF_2 MISRA 2012 Required Directive 4.10 */
#include "Can_MemMap.h"


/*==================================================================================================
*                                       GLOBAL FUNCTIONS PROTOTYPES
==================================================================================================*/
#if (STD_ON == CAN_INTERRUPT_SUPPORTED)
    #if (STD_ON == CAN_COMBINED_INTERRUPT)
        ISR(Can_IsrCombined);
    
/*==================================================================================================
*                                       GLOBAL FUNCTIONS
==================================================================================================*/
        ISR(Can_IsrCombined)
        {
        #ifdef CAN_FCA_INDEX
            Can_IPW_Isr_common_process_interrupt(CAN_FCA_INDEX);
        #endif
        #ifdef CAN_FCB_INDEX
            Can_IPW_Isr_common_process_interrupt(CAN_FCB_INDEX);
        #endif
            /* @violates @ref Can_Irq_c_REF_4 MISRA 2012 Required Rule 14.4 */
            EXIT_INTERRUPT();
        }
    #endif
#endif

#define CAN_STOP_SEC_CODE
/* @violates @ref Can_Irq_c_REF_2 MISRA 2012 Required Directive 4.10 */
/* @violates @ref Can_Irq_c_REF_3 MISRA 2012 Advisory Rule 20.1 */
#include "Can_MemMap.h"

#ifdef __cplusplus
}
#endif
/** @} */
