/**
*   @file    Can_IPW.h
*   @implements Can_IPW.h_Artifact
*   @version 1.0.0
*
*   @brief   AUTOSAR Can - module interface
*   @details Main header file - can include different IPV models.
*
*   @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.
==================================================================================================*/
/*==================================================================================================
==================================================================================================*/

#ifndef CAN_IPW_H
#define CAN_IPW_H

#ifdef __cplusplus
extern "C"{
#endif

/**
* @page misra_violations MISRA-C:2012 violations
*
* @section Can_IPW_h_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_IPW_h_REF_2
* Violates MISRA 2012 Advisory Rule 4.9, A function should be used in preference to a function-like macro where they are interchangeable.
* Function like macro are used to reduce code complexity
*/

/*==================================================================================================
*                                        INCLUDE FILES
* 1) system and project includes
* 2) needed interfaces from external units
* 3) internal and external interfaces from this unit
==================================================================================================*/
#include "Can_MCan.h"
#include "Can_Cfg.h"
#include "Soc_Ips.h"
#include "Reg_eSys_MCan.h"
/*==================================================================================================
*                              SOURCE FILE VERSION INFORMATION
==================================================================================================*/
/**
* @{
* @file           Can_IPW.h
*/
#define CAN_IPW_VENDOR_ID_H                    43
/* @violates @ref Can_IPW_h_REF_1 MISRA 2012 Advisory Rule 2.5 */
#define CAN_IPW_MODULE_ID_H                    80
#define CAN_IPW_AR_RELEASE_MAJOR_VERSION_H     4
#define CAN_IPW_AR_RELEASE_MINOR_VERSION_H     3
#define CAN_IPW_AR_RELEASE_REVISION_VERSION_H  1
#define CAN_IPW_SW_MAJOR_VERSION_H             1
#define CAN_IPW_SW_MINOR_VERSION_H             0
#define CAN_IPW_SW_PATCH_VERSION_H             0
/**@}*/

/*==================================================================================================
*                                     FILE VERSION CHECKS
==================================================================================================*/
/* Check if current file and Can_Cfg header file are of the same vendor */
#if (CAN_IPW_VENDOR_ID_H != CAN_VENDOR_ID_CFG_H)
    #error "Can_IPW.h 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_IPW_AR_RELEASE_MAJOR_VERSION_H    != CAN_AR_RELEASE_MAJOR_VERSION_CFG_H) || \
     (CAN_IPW_AR_RELEASE_MINOR_VERSION_H    != CAN_AR_RELEASE_MINOR_VERSION_CFG_H) || \
     (CAN_IPW_AR_RELEASE_REVISION_VERSION_H != CAN_AR_RELEASE_REVISION_VERSION_CFG_H))
    #error "AutoSar Version Numbers of Can_IPW.h and Can_Cfg.h are different"
#endif
/* Check if current file and Can_Cfg header file are of the same software version */
#if ((CAN_IPW_SW_MAJOR_VERSION_H != CAN_SW_MAJOR_VERSION_CFG_H) || \
     (CAN_IPW_SW_MINOR_VERSION_H != CAN_SW_MINOR_VERSION_CFG_H) || \
     (CAN_IPW_SW_PATCH_VERSION_H != CAN_SW_PATCH_VERSION_CFG_H))
    #error "Software Version Numbers of Can_IPW.h and Can_Cfg.h are different"
#endif

/* Check if current file and Can_MCan header file are of the same vendor */
#if (CAN_IPW_VENDOR_ID_H != CAN_VENDOR_ID_MCAN_H)
    #error "Can_IPW.h and Can_MCan.h have different vendor ids"
#endif
/* Check if current file and Can_MCan header file are of the same Autosar version */
#if ((CAN_IPW_AR_RELEASE_MAJOR_VERSION_H    != CAN_AR_RELEASE_MAJOR_VERSION_MCAN_H) || \
     (CAN_IPW_AR_RELEASE_MINOR_VERSION_H    != CAN_AR_RELEASE_MINOR_VERSION_MCAN_H) || \
     (CAN_IPW_AR_RELEASE_REVISION_VERSION_H != CAN_AR_RELEASE_REVISION_VERSION_MCAN_H))
    #error "AutoSar Version Numbers of Can_IPW.h and Can_MCan.h are different"
#endif
/* Check if current file and Can_MCan header file are of the same software version */
#if ((CAN_IPW_SW_MAJOR_VERSION_H != CAN_SW_MAJOR_VERSION_MCAN_H) || \
     (CAN_IPW_SW_MINOR_VERSION_H != CAN_SW_MINOR_VERSION_MCAN_H) || \
     (CAN_IPW_SW_PATCH_VERSION_H != CAN_SW_PATCH_VERSION_MCAN_H))
    #error "Software Version Numbers of Can_IPW.h and Can_MCan.h are different"
#endif

/* Check if current file and Reg_eSys_MCan header file are of the same vendor */
#if (CAN_IPW_VENDOR_ID_H  != CAN_VENDOR_ID_REGM)
    #error "Can_IPW.h and Reg_eSys_MCan.h have different vendor ids"
#endif
/* Check if current file and Reg_eSys_MCan header file are of the same Autosar version */
#if ((CAN_IPW_AR_RELEASE_MAJOR_VERSION_H  != CAN_AR_RELEASE_MAJOR_VERSION_REGM) || \
     (CAN_IPW_AR_RELEASE_MINOR_VERSION_H  != CAN_AR_RELEASE_MINOR_VERSION_REGM) || \
     (CAN_IPW_AR_RELEASE_REVISION_VERSION_H  != CAN_AR_RELEASE_REVISION_VERSION_REGM))
    #error "AutoSar Version Numbers of Can_IPW.h and Reg_eSys_MCan.h are different"
#endif
/* Check if current file and Reg_eSys_MCan header file are of the same Software version */
#if ((CAN_IPW_SW_MAJOR_VERSION_H  != CAN_SW_MAJOR_VERSION_REGM) || \
     (CAN_IPW_SW_MINOR_VERSION_H  != CAN_SW_MINOR_VERSION_REGM) || \
     (CAN_IPW_SW_PATCH_VERSION_H  != CAN_SW_PATCH_VERSION_REGM))
    #error "Software Version Numbers of Can_IPW.h and Reg_eSys_MCan.h are different"
#endif

#ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
    #if (STD_ON == CAN_ENABLE_USER_MODE_SUPPORT)
        /* Check if current file and Reg_eSys.h file are of the same Software version */
        #if ((CAN_IPW_AR_RELEASE_MAJOR_VERSION_H != SOC_IPS_AR_RELEASE_MAJOR_VERSION) || \
            (CAN_IPW_AR_RELEASE_MINOR_VERSION_H != SOC_IPS_AR_RELEASE_MINOR_VERSION))
            #error "AutoSar Version Numbers of Can_IPW.h and Soc_Ips.h are different"
        #endif
    #endif
#endif
/*==================================================================================================
*                                          CONSTANTS
==================================================================================================*/

/*==================================================================================================
*                                      DEFINES AND MACROS
==================================================================================================*/
    #define     CAN_NULL_OFFSET      (MCAN_NULL_OFFSET_U8)

#ifdef ERR_IPV_MCAN_0004
    #if (STD_ON == ERR_IPV_MCAN_0004)
        /* @violates @ref Can_IPW_h_REF_2 MISRA 2012 Advisory Rule 4.9 */
        #define Can_IPW_GetControllerCommunicationState(Controller) \
                (Can_MCan_GetControllerCommunicationState((Controller)))
    #endif
#endif

#if (STD_ON == CAN_TRIGGER_TRANSMIT_EN)
    /* @violates @ref Can_IPW_h_REF_2 MISRA 2012 Advisory Rule 4.9 */
    #define Can_IPW_CheckBufferFree(Hth)     Can_MCan_CheckBufferFree((Hth))
#endif

#if (CAN_SET_BAUDRATE_API == STD_ON)
    /* @violates @ref Can_IPW_h_REF_2 MISRA 2012 Advisory Rule 4.9 */
    #define Can_IPW_SetBaudrate(Controller, BaudRateConfigID)       (Can_MCan_SetBaudrate((Controller), (BaudRateConfigID)))
#endif
    /* @violates @ref Can_IPW_h_REF_2 MISRA 2012 Advisory Rule 4.9 */
    #define Can_IPW_GetControllerErrorState(ControllerId)       (Can_MCan_GetControllerErrorState(ControllerId))
    /* @violates @ref Can_IPW_h_REF_2 MISRA 2012 Advisory Rule 4.9 */
    #define Can_IPW_GetControllerMode(ControllerId)             (Can_MCan_GetControllerMode(ControllerId))
    /* @violates @ref Can_IPW_h_REF_2 MISRA 2012 Advisory Rule 4.9 */
    #define Can_IPW_DeInitController(ControllerId)              (Can_MCan_DeInitController(ControllerId))
    /* @violates @ref Can_IPW_h_REF_1 MISRA 2012 Advisory Rule 2.5 */
    /* @violates @ref Can_IPW_h_REF_2 MISRA 2012 Advisory Rule 4.9 */
    #define Can_IPW_ProcessBusOff(controller)                                                 (Can_MCan_ProcessBusOff( controller))
    /* @violates @ref Can_IPW_h_REF_2 MISRA 2012 Advisory Rule 4.9 */
    #define         Can_IPW_InitVariables()                                            (Can_MCan_InitVariables())

#if (STD_ON == CAN_ENABLE_USER_MODE_SUPPORT)
    /* @violates @ref Can_IPW_h_REF_2 MISRA 2012 Advisory Rule 4.9 */
    #define         Can_IPW_SetUserAccessAllowed()          Mcal_Trusted_Call(Can_Mcan_SetUserAccessAllowed,(MCAN_BASEADDR))
#endif
    /* @violates @ref Can_IPW_h_REF_2 MISRA 2012 Advisory Rule 4.9 */
    #define Can_IPW_InitController(ControllerId)                (Can_MCan_InitController(ControllerId))
    /* @violates @ref Can_IPW_h_REF_2 MISRA 2012 Advisory Rule 4.9 */
    #define         Can_IPW_SetControllerMode(Controller, pCanControlerDescriptor, Transition, canif_notification_required) \
                        (Can_MCan_SetControllerMode((Controller), (pCanControlerDescriptor),(Transition), (canif_notification_required)))
    /* @violates @ref Can_IPW_h_REF_2 MISRA 2012 Advisory Rule 4.9 */
    #define         Can_IPW_DisableControllerInterrupts(Controller) \
                    (Can_MCan_DisableControllerInterrupts(Controller))
    /* @violates @ref Can_IPW_h_REF_2 MISRA 2012 Advisory Rule 4.9 */
    #define         Can_IPW_EnableControllerInterrupts(Controller, pCanControlerDescriptor) \
                    (Can_MCan_EnableControllerInterrupts((Controller), (pCanControlerDescriptor)))

#if ((CAN_API_ENABLE_ABORT_MB == STD_ON))
    /* @violates @ref Can_IPW_h_REF_1 MISRA 2012 Advisory Rule 2.5 */
    /* @violates @ref Can_IPW_h_REF_2 MISRA 2012 Advisory Rule 4.9 */
    #define         Can_IPW_Cancel(controller, mbindex)                                (Can_MCan_Cancel((controller), (mbindex)))
    /* @violates @ref Can_IPW_h_REF_2 MISRA 2012 Advisory Rule 4.9 */
    #define         Can_IPW_AbortMb(Hth)                                              (Can_MCan_AbortMb(Hth))
#endif /* (CAN_API_ENABLE_ABORT_MB == STD_ON) */

    /* @violates @ref Can_IPW_h_REF_2 MISRA 2012 Advisory Rule 4.9 */
    #define         Can_IPW_Write(Hth, PduInfo)                                       (Can_MCan_Write((Hth), (PduInfo)))

#if ((CAN_TXPOLL_SUPPORTED == STD_ON))
    /* @violates @ref Can_IPW_h_REF_2 MISRA 2012 Advisory Rule 4.9 */
    #define         Can_IPW_MainFunctionWrite()                                       (Can_MCan_MainFunctionWrite())
    /* @violates @ref Can_IPW_h_REF_1 MISRA 2012 Advisory Rule 2.5 */
    /* @violates @ref Can_IPW_h_REF_2 MISRA 2012 Advisory Rule 4.9 */
    #define         Can_IPW_MainFunctionMultipleWritePoll(writepoll)            (Can_MCan_MainFunctionMultipleWritePoll(writepoll))
#endif
    
#if (CAN_RXPOLL_SUPPORTED == STD_ON)
    /* @violates @ref Can_IPW_h_REF_2 MISRA 2012 Advisory Rule 4.9 */
    #define         Can_IPW_MainFunctionRead()                                        (Can_MCan_MainFunctionRead())
    /* @violates @ref Can_IPW_h_REF_1 MISRA 2012 Advisory Rule 2.5 */
    /* @violates @ref Can_IPW_h_REF_2 MISRA 2012 Advisory Rule 4.9 */
    #define         Can_IPW_MainFunctionMultipleReadPoll(readpoll)                    (Can_MCan_MainFunctionMultipleReadPoll(readpoll))
#endif
    /* @violates @ref Can_IPW_h_REF_2 MISRA 2012 Advisory Rule 4.9 */
    #define         Can_IPW_MainFunctionMode()  (Can_MCan_MainFunctionMode())
    /* @violates @ref Can_IPW_h_REF_1 MISRA 2012 Advisory Rule 2.5 */
    /* @violates @ref Can_IPW_h_REF_2 MISRA 2012 Advisory Rule 4.9 */
    #define         Can_IPW_CheckBusOff(controller)                                   (Can_MCan_CheckBusOff(controller)) 
    
#if (CAN_DUAL_CLOCK_MODE == STD_ON)
    /* @violates @ref Can_IPW_h_REF_2 MISRA 2012 Advisory Rule 4.9 */
    #define         Can_IPW_SetClockMode(u8Controller, can_clk_mode)                (Can_MCan_SetClockMode((u8Controller), (can_clk_mode)))
#endif

#ifdef ERR_IPV_MCAN_0002 
  #if (ERR_IPV_MCAN_0002 == STD_ON)
    /* @violates @ref Can_IPW_h_REF_2 MISRA 2012 Advisory Rule 4.9 */
    #define Can_IPW_DummyRead(u8Controller) (Can_MCan_DummyRead(u8Controller))
  #endif
#endif
    
#if (STD_ON == CAN_INTERRUPT_SUPPORTED)
    /* @violates @ref Can_IPW_h_REF_2 MISRA 2012 Advisory Rule 4.9 */
  #define Can_IPW_Isr_common_process_interrupt(u8Controller)    (Can_MCan_Isr_common_process_interrupt(u8Controller))
#endif

#ifdef CAN_SUPPORT_MRAF_EVENT
    #if (CAN_SUPPORT_MRAF_EVENT == STD_ON)
        #if (CAN_MRAFPOLL_SUPPORTED == STD_ON)
            /* @violates @ref Can_IPW_h_REF_2 MISRA 2012 Advisory Rule 4.9 */
            #define  Can_IPW_MainFunction_CheckMRAF()        Can_MCan_MainFunction_CheckMRAF()
        #endif
    #endif
#endif
/*==================================================================================================
*                                             ENUMS
==================================================================================================*/

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

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

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

#ifdef __cplusplus
}
#endif

#endif /*CAN_IPW_H*/

/** @} */
