/**
*   @file       Eth_Cfg.h
*   @implements Eth_Cfg.h_Artifact
*   @version 1.0.0
*
*   @brief   AUTOSAR Eth driver configuration header file
*   @details File containing the configuration for the Ethernet driver
*   @note    This file was generated on [!"$date"!].
*
*   @addtogroup ETH_DRIVER_CONFIGURATION
*   @{
*/
/*==================================================================================================
*   Project              : AUTOSAR 4.3 MCAL
*   Platform             : PA
*   Peripheral           : FEC
*   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.
==================================================================================================*/
/*==================================================================================================
==================================================================================================*/
[!AUTOSPACING!]
[!NOCODE!][!//
[!/* 
*************************************
* Error checks of the configuration *
*************************************
*/!]
  [!INCLUDE "Eth_Checks.m"!][!// Configuration checks
  [!INCLUDE "Eth_GetRegisterValues.m"!][!// Calculates register values from configuration paremeters
[!ENDNOCODE!][!//
#ifndef ETH_CFG_H
#define ETH_CFG_H

#ifdef __cplusplus
extern "C"{
#endif
/**
* @page misra_violations MISRA-C:2012 violations
* 
* @section Eth_Cfg_h_REF_1
* 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 comes from the order of includes in the .c file
* and from include dependencies. As a safe approach, any file must include all its dependencies.
* Header files are already protected against double inclusions. The inclusion of Eth_Memmap.h is as
* per AUTOSAR requirement (SWS_MemMap_00003)
*
* @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 Eth_Cfg_h_REF_2
* Violates MISRA 2012 Advisory Rule 2.5, A project should not contain unused macro declarations.
*
* @section Eth_Cfg_h_REF_3
* Violates MISRA 2012 Advisory Rule 4.9, A function should be used in preference to a function-like macro where they are interchangeable.
*
* @section Eth_Cfg_h_REF_4
* Violates MISRA 2012 Advisory Rule 8.9, An object should be defined at block scope if its identifier only
* appears in a single function.
*
*/

[!IF "EthGeneral/EthDevErrorDetect = 'true'"!][!//
#include "Det.h"
[!ENDIF!][!//
[!IF "EthGeneral/EthVendorSpecific/EthDisableDemEventDetect = 'false'"!][!//
#include "Dem.h"
[!ENDIF!][!//
#include "Mcal.h"
#include "Reg_eSys.h"
#include "Soc_Ips.h"

/*==================================================================================================
*                              SOURCE FILE VERSION INFORMATION
==================================================================================================*/
#define ETH_VENDOR_ID_CFG                    43
/* @violates @ref Eth_Cfg_h_REF_2 */
#define ETH_MODULE_ID_CFG                    88
#define ETH_AR_RELEASE_MAJOR_VERSION_CFG     4
#define ETH_AR_RELEASE_MINOR_VERSION_CFG     3
#define ETH_AR_RELEASE_REVISION_VERSION_CFG  1
#define ETH_SW_MAJOR_VERSION_CFG             1
#define ETH_SW_MINOR_VERSION_CFG             0
#define ETH_SW_PATCH_VERSION_CFG             0

/*==================================================================================================
*                                     FILE VERSION CHECKS
==================================================================================================*/
#ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
    /* Check if current file and MCAL header file are of the same Autosar version */
    #if ((ETH_AR_RELEASE_MAJOR_VERSION_CFG != MCAL_AR_RELEASE_MAJOR_VERSION) || \
         (ETH_AR_RELEASE_MINOR_VERSION_CFG != MCAL_AR_RELEASE_MINOR_VERSION))
        #error "AutoSar Version Numbers of Eth_Cfg.h and Mcal.h are different"
    #endif
    /* Check if current file and Reg_eSys header file are of the same Autosar version */
    #if ((ETH_AR_RELEASE_MAJOR_VERSION_CFG != REG_ESYS_AR_RELEASE_MAJOR_VERSION) || \
         (ETH_AR_RELEASE_MINOR_VERSION_CFG != REG_ESYS_AR_RELEASE_MINOR_VERSION))
        #error "AutoSar Version Numbers of Eth_Cfg.h and Reg_eSys.h are different"
    #endif
    /* Check if current file and Soc_Ips header file are of the same Autosar version */
    #if ((ETH_AR_RELEASE_MAJOR_VERSION_CFG != SOC_IPS_AR_RELEASE_MAJOR_VERSION) || \
         (ETH_AR_RELEASE_MINOR_VERSION_CFG != SOC_IPS_AR_RELEASE_MINOR_VERSION))
        #error "AutoSar Version Numbers of Eth_Cfg.h and Soc_Ips.h are different"
    #endif
    /* Check if current file and DET header file are of the same Autosar version */
  [!IF "EthGeneral/EthDevErrorDetect = 'true'"!][!//
    #if ((ETH_AR_RELEASE_MAJOR_VERSION_CFG != DET_AR_RELEASE_MAJOR_VERSION) || \
         (ETH_AR_RELEASE_MINOR_VERSION_CFG != DET_AR_RELEASE_MINOR_VERSION))
        #error "AutoSar Version Numbers of Eth_Cfg.h and Det.h are different"
    #endif
  [!ENDIF!][!//
  [!IF "EthGeneral/EthVendorSpecific/EthDisableDemEventDetect = 'false'"!][!//
    /* Check if current file and Dem header file are of the same Autosar version */
    #if ((ETH_AR_RELEASE_MAJOR_VERSION_CFG != DEM_AR_RELEASE_MAJOR_VERSION) || \
         (ETH_AR_RELEASE_MINOR_VERSION_CFG != DEM_AR_RELEASE_MINOR_VERSION))
        #error "AutoSar Version Numbers of Eth_Cfg.h and Dem.h are different"
    #endif
  [!ENDIF!][!//
#endif /* DISABLE_MCAL_INTERMODULE_ASR_CHECK */

/*==================================================================================================
*                                          CONSTANTS
==================================================================================================*/
/* @violates @ref Eth_Cfg_h_REF_2 */
#define VARIANT_PRE_COMPILE 0
/* @violates @ref Eth_Cfg_h_REF_2 */
#define VARIANT_LINK_TIME 1
/* @violates @ref Eth_Cfg_h_REF_2 */
#define VARIANT_POST_BUILD 2
/* @violates @ref Eth_Cfg_h_REF_2 */
[!IF "(IMPLEMENTATION_CONFIG_VARIANT != 'VariantPostBuild' and (variant:size()<=1))"!][!//
#define ETH_PRECOMPILE_SUPPORT     (STD_ON)
[!ELSE!][!//
#define ETH_PRECOMPILE_SUPPORT     (STD_OFF)
[!ENDIF!][!//
 /******************************************************************************
 * Diagnostic Event Manager (DEM)
 ******************************************************************************/
[!IF "EthGeneral/EthVendorSpecific/EthDisableDemEventDetect = 'false'"!][!//
#define ETH_DEM_EVENT_DETECT  (STD_ON)   /*!< Enables Diagnostic Event Manager */
[!ELSE!][!//
#define ETH_DEM_EVENT_DETECT  (STD_OFF)  /*!< Enables Diagnostic Event Manager */
[!ENDIF!][!//
[!IF "EthGeneral/EthVendorSpecific/EthSwtManagementSupportApi = 'true'"!]
#define ETH_SWT_MANAGEMENT_SUPPORT_API  (STD_ON)
[!ELSE!]
#define ETH_SWT_MANAGEMENT_SUPPORT_API  (STD_OFF)
[!ENDIF!]
[!IF "(num:i(EthConfigSet/EthCtrlConfig/*/EthVendorSpecific/EthTxQueueNum) > 1)"!]
#define ETH_TXFIFO_SINGLE_MODE   (STD_OFF)
[!ELSE!]         
#define ETH_TXFIFO_SINGLE_MODE    (STD_ON)
[!ENDIF!]
[!IF "EthGeneral/EthVendorSpecific/EthBridgeSupport = 'true'"!][!//
#define ETH_BRIDGE_SUPPORT  (STD_ON)   /*!< Enable the Ethernet Bridge feature with the dual channels shall be supported*/
[!ELSE!][!//
#define ETH_BRIDGE_SUPPORT  (STD_OFF)  /*!< Disable the Ethernet Bridge feature with the dual channels shall be supported */
[!ENDIF!][!//
/*Select Mode of FEC in MII or RMII*/
[!IF "EthConfigSet/EthCtrlConfig/*/EthCtrlEnableMii = 'true'"!]
[!IF "(EthConfigSet/EthCtrlConfig/*/EthCtrlMacLayerType = 'ETH_MAC_LAYER_TYPE_XMII') and (EthConfigSet/EthCtrlConfig/*/EthCtrlMacLayerSubType = 'STANDARD')"!]
#define ETH_MII_MODE_SEL        (STD_ON)
[!ELSE!]
#define ETH_MII_MODE_SEL        (STD_OFF)
[!ENDIF!]
[!ENDIF!]
/*
* @brief          Support for User Mode feature.
* @details        This parameter is enabled only in order to support the write access to some registers are protected in user mode.
*/
[!IF "EthGeneral/EthVendorSpecific/EthEnableUserModeSupport = 'true'"!]
    #define ETH_ENABLE_USER_MODE_SUPPORT (STD_ON)
[!ELSE!]
    #define ETH_ENABLE_USER_MODE_SUPPORT (STD_OFF)
[!ENDIF!]

#ifndef MCAL_ENABLE_USER_MODE_SUPPORT
    #if (STD_ON == ETH_ENABLE_USER_MODE_SUPPORT)
        #error MCAL_ENABLE_USER_MODE_SUPPORT is not enabled. For running ETH in user mode the MCAL_ENABLE_USER_MODE_SUPPORT needs to be defined
    #endif /* (STD_ON == ETH_ENABLE_USER_MODE_SUPPORT */
#endif /* ifndef MCAL_ENABLE_USER_MODE_SUPPORT */
/*==================================================================================================
*                                      DEFINES AND MACROS
==================================================================================================*/
[!NOCODE!][!// Check minimum/maximum available CtrlIdx
  [!VAR "MaxCtrlIdx"="0"!]
  [!VAR "MinCtrlIdx"="EthGeneral/EthMaxCtrlsSupported"!]
  [!SELECT "EthConfigSet"!]
    [!LOOP "EthCtrlConfig/*"!]
      [!IF "EthCtrlIdx < $MinCtrlIdx "!]
        [!VAR "MinCtrlIdx"="EthCtrlIdx"!]
      [!ENDIF!]
      [!IF "EthCtrlIdx > $MaxCtrlIdx "!]
        [!VAR "MaxCtrlIdx"="EthCtrlIdx"!]
      [!ENDIF!]
    [!ENDLOOP!]
  [!ENDSELECT!]
[!ENDNOCODE!]
#define ETH_MAX_CTRLIDX  ((uint8)[!"num:i($MaxCtrlIdx)"!]U)
#define ETH_MIN_CTRLIDX  ((uint8)[!"num:i($MinCtrlIdx)"!]U)

[!SELECT "EthConfigSet"!][!// Select the configuration
    [!CALL "GetRegisterValues"!]
    /* Compiler_Warning: This is a cast from pointer type (can be 32bit or 64 bit) to uint32. Assuming the pointer value is always in range of uint32 type(MCAL limitation), the cast is safe.*/
    /* @violates @ref Eth_Cfg_h_REF_3 Function like macro are used to reduce code complexity */
    #define ETH_CFG_TXBDSTARTADDRESS(CtrlIdx)    ((uint32)((*(Eth_StaticConfigPtr.pController[CtrlIdx])).TxBufStartAddr))
    /* Compiler_Warning: This is a cast from pointer type (can be 32bit or 64 bit) to uint32. Assuming the pointer value is always in range of uint32 type(MCAL limitation), the cast is safe.*/
    /* @violates @ref Eth_Cfg_h_REF_3 Function like macro are used to reduce code complexity */
    #define ETH_CFG_RXBDSTARTADDRESS(CtrlIdx)    ((uint32)((*(Eth_StaticConfigPtr.pController[CtrlIdx])).RxBufStartAddr))
    /* @violates @ref Eth_Cfg_h_REF_3 Function like macro are used to reduce code complexity */
    #define ETH_CFG_MACCONFIG(CtrlIdx)            ((*(Eth_InternalCfgPtr->pController[CtrlIdx])).pDMACfg->u32MACfg)
    /* @violates @ref Eth_Cfg_h_REF_3 Function like macro are used to reduce code complexity */
    #define ETH_CFG_FILADDR(CtrlIdx)            ((*(Eth_InternalCfgPtr->pController[CtrlIdx])).pDMACfg->u32PkFiltAddr)
    /* @violates @ref Eth_Cfg_h_REF_2 */
    /* @violates @ref Eth_Cfg_h_REF_3 Function like macro are used to reduce code complexity */
    #define ETH_CFG_ENABLERXINTERRUPT(CtrlIdx)   ((*(Eth_StaticConfigPtr.pController[CtrlIdx])).EnableRxInterrupt)
    /* @violates @ref Eth_Cfg_h_REF_3 Function like macro are used to reduce code complexity */
    #define ETH_CFG_ENABLETXINTERRUPT(CtrlIdx)   ((*(Eth_StaticConfigPtr.pController[CtrlIdx])).EnableTxInterrupt)
    /* @violates @ref Eth_Cfg_h_REF_3 Function like macro are used to reduce code complexity */
    #define ETH_CFG_MACADDRESSLOW(CtrlIdx)       ((*(Eth_InternalCfgPtr->pController[CtrlIdx])).EthMACAddressLow)
    /* @violates @ref Eth_Cfg_h_REF_3 Function like macro are used to reduce code complexity */
    #define ETH_CFG_MACADDRESSHIGH(CtrlIdx)      ((*(Eth_InternalCfgPtr->pController[CtrlIdx])).EthMACAddressHigh)
    /* @violates @ref Eth_Cfg_h_REF_3 Function like macro are used to reduce code complexity */
    #define ETH_CFG_MSCR(CtrlIdx)                ((*(Eth_InternalCfgPtr->pController[CtrlIdx])).EthMSCR)
    /* @violates @ref Eth_Cfg_h_REF_3 Function like macro are used to reduce code complexity */
    #define ETH_CFG_RCR(CtrlIdx)                 ((*(Eth_InternalCfgPtr->pController[CtrlIdx])).EthRCR)
    /* @violates @ref Eth_Cfg_h_REF_3 Function like macro are used to reduce code complexity */
    #define ETH_CFG_TCR(CtrlIdx)                 ((*(Eth_InternalCfgPtr->pController[CtrlIdx])).EthTCR)    
    /* @violates @ref Eth_Cfg_h_REF_3 Function like macro are used to reduce code complexity */
    #define ETH_CFG_CTRLIDXINETHIF(CtrlIdx)      ((*(Eth_StaticConfigPtr.pController[CtrlIdx])).EthCtrlIdxInEthIf)
#if STD_ON == ETH_DEM_EVENT_DETECT
    /* @violates @ref Eth_Cfg_h_REF_3 Function like macro are used to reduce code complexity */
    #define ETH_CFG_DEM_E_ACCESS_ENABLED(CtrlIdx)    ((*(Eth_InternalCfgPtr->pController[CtrlIdx])).ETH_DEM_E_ACCESS_Cfg.state)
    /* @violates @ref Eth_Cfg_h_REF_3 Function like macro are used to reduce code complexity */
    #define ETH_CFG_DEM_E_ACCESS(CtrlIdx)    ((*(Eth_InternalCfgPtr->pController[CtrlIdx])).ETH_DEM_E_ACCESS_Cfg.id)
    /* @violates @ref Eth_Cfg_h_REF_3 Function like macro are used to reduce code complexity */
    #define ETH_CFG_DEM_E_FRAMELOST_ENABLED(CtrlIdx)    ((*(Eth_InternalCfgPtr[0].pController[CtrlIdx])).ETH_E_RX_FRAMES_LOST_Cfg.state)
    /* @violates @ref Eth_Cfg_h_REF_3 Function like macro are used to reduce code complexity */
    #define ETH_CFG_DEM_E_FRAMELOST(CtrlIdx)    ((*(Eth_InternalCfgPtr[0].pController[CtrlIdx])).ETH_E_RX_FRAMES_LOST_Cfg.id)
    /* @violates @ref Eth_Cfg_h_REF_3 Function like macro are used to reduce code complexity */
    #define ETH_CFG_DEM_E_CRC_ENABLED(CtrlIdx)    ((*(Eth_InternalCfgPtr[0].pController[CtrlIdx])).ETH_E_CRC_Cfg.state)
    /* @violates @ref Eth_Cfg_h_REF_3 Function like macro are used to reduce code complexity */
    #define ETH_CFG_DEM_E_CRC(CtrlIdx)    ((*(Eth_InternalCfgPtr[0].pController[CtrlIdx])).ETH_E_CRC_Cfg.id)
    /* @violates @ref Eth_Cfg_h_REF_3 Function like macro are used to reduce code complexity */
    #define ETH_CFG_DEM_E_UNDERSIZE_ENABLED(CtrlIdx)    ((*(Eth_InternalCfgPtr[0].pController[CtrlIdx])).ETH_E_UNDERSIZEFRAME_Cfg.state)
    /* @violates @ref Eth_Cfg_h_REF_3 Function like macro are used to reduce code complexity */
    #define ETH_CFG_DEM_E_UNDERSIZE(CtrlIdx)    ((*(Eth_InternalCfgPtr[0].pController[CtrlIdx])).ETH_E_UNDERSIZEFRAME_Cfg.id)
    /* @violates @ref Eth_Cfg_h_REF_3 Function like macro are used to reduce code complexity */
    #define ETH_CFG_DEM_E_OVERSIZE_ENABLED(CtrlIdx)    ((*(Eth_InternalCfgPtr[0].pController[CtrlIdx])).ETH_E_OVERSIZEFRAME_Cfg.state)
    /* @violates @ref Eth_Cfg_h_REF_3 Function like macro are used to reduce code complexity */
    #define ETH_CFG_DEM_E_OVERSIZE(CtrlIdx)    ((*(Eth_InternalCfgPtr[0].pController[CtrlIdx])).ETH_E_OVERSIZEFRAME_Cfg.id)
    /* @violates @ref Eth_Cfg_h_REF_3 Function like macro are used to reduce code complexity */
    #define ETH_CFG_DEM_E_ALIGN_ENABLED(CtrlIdx)    ((*(Eth_InternalCfgPtr[0].pController[CtrlIdx])).ETH_E_ALIGNMENT_Cfg.state)
    /* @violates @ref Eth_Cfg_h_REF_3 Function like macro are used to reduce code complexity */
    #define ETH_CFG_DEM_E_ALIGN(CtrlIdx)    ((*(Eth_InternalCfgPtr[0].pController[CtrlIdx])).ETH_E_ALIGNMENT_Cfg.id)
    /* @violates @ref Eth_Cfg_h_REF_3 Function like macro are used to reduce code complexity */
    #define ETH_CFG_DEM_E_1COL_ENABLED(CtrlIdx)    ((*(Eth_InternalCfgPtr[0].pController[CtrlIdx])).ETH_E_SINGLECOLLISION_Cfg.state)
    /* @violates @ref Eth_Cfg_h_REF_3 Function like macro are used to reduce code complexity */
    #define ETH_CFG_DEM_E_1COL(CtrlIdx)    ((*(Eth_InternalCfgPtr[0].pController[CtrlIdx])).ETH_E_SINGLECOLLISION_Cfg.id)
    /* @violates @ref Eth_Cfg_h_REF_3 Function like macro are used to reduce code complexity */
    #define ETH_CFG_DEM_E_MCOL_ENABLED(CtrlIdx)    ((*(Eth_InternalCfgPtr[0].pController[CtrlIdx])).ETH_E_MULTIPLECOLLISION_Cfg.state)
    /* @violates @ref Eth_Cfg_h_REF_3 Function like macro are used to reduce code complexity */
    #define ETH_CFG_DEM_E_MCOL(CtrlIdx)    ((*(Eth_InternalCfgPtr[0].pController[CtrlIdx])).ETH_E_MULTIPLECOLLISION_Cfg.id)
    /* @violates @ref Eth_Cfg_h_REF_3 Function like macro are used to reduce code complexity */
    #define ETH_CFG_DEM_E_LCOL_ENABLED(CtrlIdx)    ((*(Eth_InternalCfgPtr[0].pController[CtrlIdx])).ETH_E_LATECOLLISION_Cfg.state)
    /* @violates @ref Eth_Cfg_h_REF_3 Function like macro are used to reduce code complexity */
    #define ETH_CFG_DEM_E_LCOL(CtrlIdx)    ((*(Eth_InternalCfgPtr[0].pController[CtrlIdx])).ETH_E_LATECOLLISION_Cfg.id)
#endif /* ETH_DEM_EVENT_DETECT */
[!ENDSELECT!]
/******************************************************************************
* Features enable/disable switches 
******************************************************************************/
/* ETH004_Conf */
#define ETH_VERSION_INFO_API[!WS!][!IF "EthGeneral/EthVersionInfoApi = 'true'"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!][!WS!]/*!< Enables Version info function */
/* ETH005_Conf */
/* @violates @ref Eth_Cfg_h_REF_2 */
#define ETH_VERSION_INFO_API_MACRO[!WS!][!IF "EthGeneral/EthVersionInfoApiMacro = 'true'"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!][!WS!]/*!< Enables Version info function implementation as macro */
/* ETH019_Conf */
#define ETH_UPDATE_PHYS_ADDR_FILTER[!WS!][!IF "EthGeneral/EthUpdatePhysAddrFilter = 'true'"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!][!WS!]/*!< Enables optional API Eth_UpdatePhysAddrFilter */

/* Multi-Buffer frames support */
#define ETH_USE_MULTIBUFFER_RX_FRAMES[!WS!][!IF "EthGeneral/EthVendorSpecific/EthUseMultiBufferRxFrames = 'true'"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!][!WS!]/*!< Enables multi-buffer frames reception */
#define ETH_USE_RX_FRAMES_WRAP[!WS!][!IF "EthGeneral/EthVendorSpecific/EthEnableRxFrameWrap = 'true' and EthGeneral/EthVendorSpecific/EthUseMultiBufferRxFrames = 'true'"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!][!WS!]/*!< Enables multi-buffer frames wrap */

/* TX Multi-Buffer frames support */
#define ETH_USE_MULTIBUFFER_TX_FRAMES[!WS!][!IF "EthGeneral/EthVendorSpecific/EthUseMultiBufferTxFrames = 'true'"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!][!WS!]/*!< Enables multi-buffer frames transmission */

[!NOCODE!][!//
  [!/* This code check all multiple configurations whether all code switches
       (AllMiiDisabled) 
       have the value equal to false which means that the code can be omitted.
       The code cannot be omitted when a true value is set in at least 
       one multiple configuration */!]
  [!/* Set initial value to "can be omitted" */!]
  [!VAR "AllMiiDisabled" = "true()"!]
  [!/* Go through all multiple configurations and change initial value to
       "cannot be omitted" if a true value is found for a parameter */!]
  [!VAR "count" = "0"!]
  [!SELECT "EthConfigSet"!][!//
    [!LOOP "EthCtrlConfig/*"!][!//
      [!IF "EthCtrlEnableMii = 'true'"!]
        [!VAR "AllMiiDisabled" = "false()"!]
      [!ENDIF!]  
      [!IF "$count = 0"!]
        [!VAR "InternalooopBack" = "EthVendorSpecific/EthInternalLoopbackMode"!]
        [!VAR "FullDuplex" = "EthVendorSpecific/EthFullDuplexEnable"!]
        [!VAR "DisableBroad" = "EthVendorSpecific/EthDisBroadcast"!]
      [!ELSE!]
        [!VAR "InternalooopBack1" = "EthVendorSpecific/EthInternalLoopbackMode"!]
        [!VAR "FullDuplex1" = "EthVendorSpecific/EthFullDuplexEnable"!]
        [!VAR "DisableBroad1" = "EthVendorSpecific/EthDisBroadcast"!]
        [!IF "$InternalooopBack1 != $InternalooopBack"!]
            [!ERROR!]
                EthInternalLoopbackMode must configured same in all controller configurations.
            [!ENDERROR!]
        [!ENDIF!]
        [!IF "$FullDuplex != $FullDuplex1"!]
            [!ERROR!]
                EthFullDuplexEnable must configured same in all controller configurations.
            [!ENDERROR!]
        [!ENDIF!]
        [!IF "$DisableBroad != $DisableBroad1"!]
            [!ERROR!]
                EthDisBroadcast must configured same in all controller configurations.
            [!ENDERROR!]
        [!ENDIF!]
      [!ENDIF!]
      [!VAR "count" = "$count + 1"!]
    [!ENDLOOP!]
  [!ENDSELECT!][!//
[!ENDNOCODE!][!//
    /* This macro can have STD_OFF value only if the controller in all multiple configurations
       does not use the MII API. The value STD_ON means that code is compiled but the MII
       might not be used (API is present because it is needed in another multiple configuration
       but it is not called). */
    /* @requirements SWS_Eth_00012_Conf */
[!IF "$AllMiiDisabled = 'true'"!][!//
    #define ETH_CTRLENABLE_MII (STD_OFF)        /*!< MII handling functions compilation disabled */      
[!ELSE!][!//
    #define ETH_CTRLENABLE_MII (STD_ON)         /*!< MII handling functions compilation enabled */      
[!ENDIF!][!//

[!SELECT "EthGeneral"!][!//
    #define ETH_GETCOUNTVALAPI[!WS!][!IF "EthGetCounterValuesApi = 'true'"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!][!CR!][!//
    #define ETH_GET_RXSTATS_API[!WS!][!IF "EthGetRxStatsApi = 'true'"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!][!CR!][!//
    #define ETH_GET_TXSTATS_API[!WS!][!IF "EthGetTxStatsApi = 'true'"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!][!CR!][!//
    #define ETH_GET_GETTXCOUNT_API[!WS!][!IF "EthGetTxErrorCounterValuesApi = 'true'"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!][!CR!][!//
    #define ETH_GLOBALTIME_SUPPORT [!WS!][!IF "EthGlobalTimeSupport = 'true'"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!][!CR!][!//
  [!SELECT "EthCtrlOffloading"!][!//
    #define ETH_ENABLE_OFFLOAD_CRC_IPV4[!WS!][!IF "EthCtrlEnableOffloadChecksumIPv4 = 'true'"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!][!CR!][!//
    #define ETH_ENABLE_OFFLOAD_CRC_ICMP[!WS!][!IF "EthCtrlEnableOffloadChecksumICMP = 'true'"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!][!CR!][!//
    #define ETH_ENABLE_OFFLOAD_CRC_TCP[!WS!][!IF "EthCtrlEnableOffloadChecksumTCP = 'true'"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!][!CR!][!//
    #define ETH_ENABLE_OFFLOAD_CRC_UDP[!WS!][!IF "EthCtrlEnableOffloadChecksumUDP = 'true'"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!][!CR!][!//
  [!ENDSELECT!][!//
[!ENDSELECT!]


    /******************************************************************************
    * Development Error Detection 
    ******************************************************************************/
    /* ETH003_Conf */
[!IF "EthGeneral/EthDevErrorDetect = 'true'"!][!//
    #define ETH_DEV_ERROR_DETECT  (STD_ON)      /*!< Enables Development Error Detect feature */
[!ELSE!][!//
    #define ETH_DEV_ERROR_DETECT  (STD_OFF)     /*!< Enables Development Error Detect feature */
[!ENDIF!][!//
    
    /******************************************************************************
    * Configuration constants
    ******************************************************************************/
    /* ETH002_Conf */
    #define ETH_MAXCTRLS_SUPPORTED [!"EthGeneral/EthMaxCtrlsSupported"!]U  /* Number of supported controllers */
    /* @violates @ref Eth_Cfg_h_REF_2 */
    #define ETH_NUM_OF_CONFIGURATIONS 1U /* Number of configurations */
    /* @violates @ref Eth_Cfg_h_REF_2 */
    #define ETH_DRIVER_INSTANCE [!"EthGeneral/EthIndex"!]U   /* Instance number assigned to the driver */
    /* @violates @ref Eth_Cfg_h_REF_2 */
    #define ETH_RESET_WAIT_LOOP_COUNT 30U /* Reset waiting loop timeout */
    /* @violates @ref Eth_Cfg_h_REF_2 */
    #define ETH_INFINITE_LOOP_PROTECTION 4096U /* Number of runs in the loop before it is claimed to be never-ending and broken */   
    #define DEBUG_VARIABLES (STD_OFF) /* Debug variables inclusion into the code -
     debug variables are normally excluded from the code to save memory space */
    /* @violates @ref Eth_Cfg_h_REF_2 */
    #define ETH_MULTICAST_POOL_SIZE [!"num:i(EthGeneral/EthVendorSpecific/EthMulticastPoolSize)"!]U /* Maximal count of MAC address inside multicast pool */
[!NOCODE!]
    [!SELECT "EthConfigSet"!]
    [!LOOP "EthCtrlConfig/*"!]
        [!VAR "RxSpaceMax" = "0"!]
        [!VAR "TxSpaceMax" = "0"!]
        [!LOOP "EthCtrlConfigEgress/EthCtrlConfigEgressFifo/*"!]
            [!VAR "TxBuffMax" = "num:i(EthCtrlConfigEgressFifoBufTotal)"!]
            [!VAR "BufLength" = "num:i(EthCtrlConfigEgressFifoBufLenByte)"!]
            [!VAR "MaxTxSize" = " ($BufLength + 8) * $TxBuffMax"!]
            [!VAR "TxSpaceMax" = "$TxSpaceMax + $MaxTxSize"!]
        [!ENDLOOP!]
        [!LOOP "EthCtrlConfigIngress/EthCtrlConfigIngressFifo/*"!]
            [!VAR "RxBufLen" = "num:i(EthCtrlConfigIngressFifoBufLenByte)"!]
            [!IF "0 != num:i(num:mod($RxBufLen, 16))"!]
                [!VAR "RxBufLen" = "$RxBufLen + (16 - num:i(num:mod($RxBufLen, 16)))"!]
            [!ENDIF!]
            [!VAR "MaxRxSize" = "($RxBufLen + 8 + 16) * num:i(EthCtrlConfigIngressFifoBufTotal)"!]
            [!VAR "MaxRxMemory" = "$MaxRxSize"!]
            [!VAR "RxSpaceMax" = "$RxSpaceMax + $MaxRxMemory"!]
        [!ENDLOOP!]
        [!VAR "sodu" = "num:i(num:mod($TxSpaceMax, 16))"!]
        [!IF " $sodu != 0"!]
                [!VAR "TxSpaceMax" = "$TxSpaceMax + (num:i(16) - $sodu)"!]
        [!ELSE!]
                [!VAR "TxSpaceMax" = "$TxSpaceMax"!]
        [!ENDIF!]
        [!VAR "TxCFGMax" = "num:i(EthVendorSpecific/EthTxQueueNum)"!]
        [!VAR "RxCFGMax" = "num:i(EthVendorSpecific/EthRxQueueNum)"!]
    [!ENDLOOP!]
    [!IF "(../EthGeneral/EthVendorSpecific/EthUseMultiBufferRxFrames = 'true') and (../EthGeneral/EthVendorSpecific/EthEnableRxFrameWrap = 'true')"!]
        [!VAR "RxSpaceMax" = "$RxSpaceMax + 2047"!]
    [!ENDIF!]
    [!ENDSELECT!]
    [!VAR "MAX_CONTROLLER_CFG"="num:i(count(EthConfigSet/EthCtrlConfig/*))"!]
[!ENDNOCODE!]
/* Sizes of memory blocks allocated for TX/RX data buffers and related descriptors */
#define ETH_MAX_CONTROLLER_CFG          ([!"num:i($MAX_CONTROLLER_CFG)"!]U)
#define ETH_MAX_TXFIFO_CONFIG           ([!"num:i($TxCFGMax)"!]U)
#define ETH_MAX_RXFIFO_CONFIG           ([!"num:i($RxCFGMax)"!]U)
#define ETH_MAX_TX_PRIO_NUM             (8U)
#define ETH_TX_BUFF_MAX                 ([!"num:i($TxBuffMax)"!]U)
#define ETH_TX_BUF_MEM_SIZE             ([!"num:i($TxSpaceMax)"!]U)
#define ETH_RX_BUF_MEM_SIZE             ([!"num:i($RxSpaceMax)"!]U)
/*==================================================================================================
*                                             ENUMS
==================================================================================================*/

/*==================================================================================================
*                                STRUCTURES AND OTHER TYPEDEFS
==================================================================================================*/
typedef struct
{
    uint16 EthCtrlConfigEgressFifoBufLenByte;  /**< Length of one Tx buffer */
    uint8 EthCtrlConfigEgressFifoBufTotal;         /**< Number of Tx buffers */ 
    uint8 EthMaxTxQueue;
}Eth_EgressTxCfgType;

typedef struct
{
    uint8 EthCtrlConfigIngressFifoIdx;
    uint16 EthCtrlConfigIngressFifoBufLenByte;  /**< Length of one Rx buffer*/
    uint8 EthCtrlConfigIngressFifoBufTotal;         /**< Number of Rx buffers */
    uint8 EthDMAChanlIdx;
}Eth_IngressCfgType;

/**
* @brief         Type for Ethernet driver configuration values storage.
* @details       This type is used to collect and pass all configuration data
*                of one controller (except those which have only
*                precompile variant) to the Eth driver.
* @implements Eth_CtrlCfgType_structure
*/
typedef struct
{
    uint32 EthMACAddressLow;     /**< First 32 bits of MAC address */
    uint32 EthMACAddressHigh; /**< Last 16 bits of MAC address<<16|0x8808 */
    uint32 EthMSCR;        /**< Value stored to MSCR during initialization */
    uint32 EthRCR;         /**< Value stored to RCR during initialization */
    uint32 EthTCR;         /**< Value stored to TCR during initialization */
    uint8 EthTxFifoNum;     /**< Number of Tx Fifo which are supported */
    uint8 EthRxFifoNum;     /**< Number of Tx Fifo which are supported */
    P2CONST(Eth_EgressTxCfgType, ETH_CONST, ETH_APPL_CONST) pEgressCfg;
    P2CONST(Eth_IngressCfgType, ETH_CONST, ETH_APPL_CONST) pIngressCfg;
#if (STD_ON == ETH_DEM_EVENT_DETECT)
    Mcal_DemErrorType ETH_DEM_E_ACCESS_Cfg; /**< Contains enablement of specific
                                                error report and value assigned
                                                by Dem as ETH_E_ACCESS and   */
    Mcal_DemErrorType ETH_E_RX_FRAMES_LOST_Cfg; /**< Contains enablement of specific
                                                error report and value assigned
                                                by Dem as ETH_E_ACCESS and   */
    Mcal_DemErrorType ETH_E_CRC_Cfg; /**< Contains enablement of specific
                                                error report and value assigned
                                                by Dem as ETH_E_CRC and   */
    Mcal_DemErrorType ETH_E_UNDERSIZEFRAME_Cfg; /**< Contains enablement of specific
                                                error report and value assigned
                                                by Dem as ETH_E_UNDERSIZEFRAME and   */
    Mcal_DemErrorType ETH_E_OVERSIZEFRAME_Cfg; /**< Contains enablement of specific
                                                error report and value assigned
                                                by Dem as ETH_E_OVERSIZEFRAME and   */
    Mcal_DemErrorType ETH_E_ALIGNMENT_Cfg; /**< Contains enablement of specific
                                                error report and value assigned
                                                by Dem as ETH_E_ALIGNMENT and   */
    Mcal_DemErrorType ETH_E_SINGLECOLLISION_Cfg; /**< Contains enablement of specific
                                                error report and value assigned
                                                by Dem as ETH_E_SINGLECOLLISION and   */
    Mcal_DemErrorType ETH_E_MULTIPLECOLLISION_Cfg; /**< Contains enablement of specific
                                                error report and value assigned
                                                by Dem as ETH_E_MULTIPLECOLLISION and   */
    Mcal_DemErrorType ETH_E_LATECOLLISION_Cfg; /**< Contains enablement of specific
                                                error report and value assigned
                                                by Dem as ETH_E_LATECOLLISION and   */
#endif /* ETH_DEM_EVENT_DETECT */
#if (STD_ON == ETH_CTRLENABLE_MII)
    uint8 EthMDCClkFactor;
#endif
} Eth_CtrlCfgType;

/**
* @brief         Type for Ethernet driver Static configuration values storage.
* @details       This type is used to collect and pass all configuration data
*                of one controller (except those which have only
*                precompile variant) to the Eth driver.
*/
typedef struct
{
    boolean EnableRxInterrupt;  /**< Enable interrupt requests for frame
                                      reception event */
    boolean EnableTxInterrupt;  /**< Enable interrupt requests for
                                      frame transmission event */
    uint8 EthCtrlIdxInEthIf;    /**< Instance ID of the controller */
    uint8 *TxBufStartAddr;      /**< Start address for TX buffer of the controller */
    uint8 *RxBufStartAddr;      /**< Start address for TX buffer of the controller */
} Eth_StaticCtrlCfgType;

/* 
* @brief This type is used to group all multiple configurations.
*/   
typedef struct 
{
    P2CONST(Eth_CtrlCfgType, TYPEDEF, ETH_APPL_DATA) pController[ETH_MAXCTRLS_SUPPORTED];
} Eth_ConfigType;
/* 
* @brief This type is used to group Static configuration for all controllers.
*/   
typedef struct 
{
    P2CONST(Eth_StaticCtrlCfgType, TYPEDEF, ETH_APPL_DATA) pController[ETH_MAXCTRLS_SUPPORTED];
} Eth_StaticConfigType;

/*==================================================================================================
*                                GLOBAL VARIABLE DECLARATIONS
==================================================================================================*/
#define ETH_START_SEC_CONST_UNSPECIFIED
/* @violates @ref Eth_Cfg_h_REF_1 This violation is not fixed since the inclusion of Eth_MemMap.h is as per AUTOSAR requirement*/
#include "Eth_MemMap.h"

/* Configuration for parameters which are not variant */
extern CONST(Eth_StaticConfigType, ETH_APPL_CONST) Eth_StaticConfigPtr;

#define ETH_STOP_SEC_CONST_UNSPECIFIED
/* @violates @ref Eth_Cfg_h_REF_1 This violation is not fixed since the inclusion of Eth_MemMap.h is as per AUTOSAR requirement*/
#include "Eth_MemMap.h"

#define ETH_START_SEC_CONFIG_DATA_UNSPECIFIED
/* @violates @ref Eth_Cfg_h_REF_1 This violation is not fixed since the inclusion of Eth_MemMap.h is as per AUTOSAR requirement*/
#include "Eth_MemMap.h"

/* @violates @ref Eth_Cfg_h_REF_4 */
[!IF "((IMPLEMENTATION_CONFIG_VARIANT != 'VariantPostBuild') and (variant:size()>1)) or ((IMPLEMENTATION_CONFIG_VARIANT = 'VariantPostBuild') and (variant:size()>0))"!][!//
        [!VAR "configName" = "as:name(EthConfigSet)"!][!//
    [!LOOP "variant:all()"!][!//
      [!CODE!][!WS4!]extern CONST(Eth_ConfigType, ETH_CONST) [!"$configName"!]_[!"."!];[!CR!][!ENDCODE!][!//
    [!ENDLOOP!][!//
[!ELSEIF "(IMPLEMENTATION_CONFIG_VARIANT = 'VariantPostBuild') and (variant:size()<1)"!][!//
     [!SELECT "EthConfigSet"!][!// Select configuration
        [!VAR "ConfigSet" = "as:name(.)"!]
    [!CODE!][!WS4!]extern CONST(Eth_ConfigType, ETH_CONST) [!"$ConfigSet"!];[!CR!][!ENDCODE!]
    [!ENDSELECT!]
[!ELSE!]
          [!CODE!][!WS4!]extern CONST(Eth_ConfigType, ETH_CONST) Eth_PBCfgVariantPredefined;[!CR!][!ENDCODE!][!//
[!ENDIF!][!//
#define ETH_STOP_SEC_CONFIG_DATA_UNSPECIFIED
/* @violates @ref Eth_Cfg_h_REF_1 This violation is not fixed since the inclusion of Eth_MemMap.h is as per AUTOSAR requirement*/
#include "Eth_MemMap.h"

#define ETH_START_SEC_VAR_NO_INIT_UNSPECIFIED_NO_CACHEABLE
/* @violates @ref Eth_Cfg_h_REF_1 This violation is not fixed since the inclusion of Eth_MemMap.h is as per AUTOSAR requirement*/
#include "Eth_MemMap.h"

extern VAR(uint8, ETH_VAR) Eth_TxBuffers[ETH_MAX_CONTROLLER_CFG][ETH_TX_BUF_MEM_SIZE];
extern VAR(uint8, ETH_VAR) Eth_RxBuffers[ETH_MAX_CONTROLLER_CFG][ETH_RX_BUF_MEM_SIZE];

#define ETH_STOP_SEC_VAR_NO_INIT_UNSPECIFIED_NO_CACHEABLE
/* @violates @ref Eth_Cfg_h_REF_1 This violation is not fixed since the inclusion of Eth_MemMap.h is as per AUTOSAR requirement*/
#include "Eth_MemMap.h"

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


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