/**
*   @file       Eth_PBcfg.c
*   @implements Eth_PBcfg.c_Artifact
*   @version 1.0.0
*
*   @brief   AUTOSAR Eth driver Post-Build configuration 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.
==================================================================================================*/
/*==================================================================================================
==================================================================================================*/
#ifdef __cplusplus
extern "C"{
#endif

/**
* @page misra_violations MISRA-C:2012 violations
* 
* @section Eth_PBcfg_c_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_PBcfg_c_REF_2
* Violates MISRA 2012 Advisory Rule 20.1, #include directives should only be preceded by preprocessor 
* directives or comments. AUTOSAR imposes the specification of the sections in which certain parts
* of the driver must be placed.
*
* @section Eth_PBcfg_c_REF_3
* 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.
*
* @section Eth_PBcfg_c_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.
*
*/

/*==================================================================================================
*                                        INCLUDE FILES
* 1) system and project includes
* 2) needed interfaces from external units
* 3) internal and external interfaces from this unit
==================================================================================================*/
/* ETH001 */
#include "Eth.h"
#include "Eth_Fec_Reg_Sys.h"

/*==================================================================================================
*                              SOURCE FILE VERSION INFORMATION
==================================================================================================*/
#define ETH_VENDOR_ID_C                      43
#define ETH_MODULE_ID_C                      88
#define ETH_AR_RELEASE_MAJOR_VERSION_C       4
#define ETH_AR_RELEASE_MINOR_VERSION_C       3
#define ETH_AR_RELEASE_REVISION_VERSION_C    1
#define ETH_SW_MAJOR_VERSION_C               1
#define ETH_SW_MINOR_VERSION_C               0
#define ETH_SW_PATCH_VERSION_C               0

/*==================================================================================================
*                                     FILE VERSION CHECKS
==================================================================================================*/
/* Check if current file and ETH header file are of the same vendor */
#if (ETH_VENDOR_ID_C != ETH_VENDOR_ID)
    #error "Eth_PBcfg.c and Eth.h have different vendor ids"
#endif
/* Check if current file and ETH header file are of the same module */
#if (ETH_MODULE_ID_C != ETH_MODULE_ID)
    #error "Eth_PBcfg.c and Eth.h have different vendor ids"
#endif
/* Check if current file and ETH header file are of the same Autosar version */
#if ((ETH_AR_RELEASE_MAJOR_VERSION_C    != ETH_AR_RELEASE_MAJOR_VERSION) || \
     (ETH_AR_RELEASE_MINOR_VERSION_C    != ETH_AR_RELEASE_MINOR_VERSION) || \
     (ETH_AR_RELEASE_REVISION_VERSION_C != ETH_AR_RELEASE_REVISION_VERSION))
    #error "AutoSar Version Numbers of Eth_PBcfg.c and Eth.h are different"
#endif
/* Check if current file and ETH header file are of the same Software version */
#if ((ETH_SW_MAJOR_VERSION_C != ETH_SW_MAJOR_VERSION) || \
     (ETH_SW_MINOR_VERSION_C != ETH_SW_MINOR_VERSION) || \
     (ETH_SW_PATCH_VERSION_C != ETH_SW_PATCH_VERSION))
    #error "Software Version Numbers of Eth_PBcfg.c and Eth.h are different"
#endif
/* Check if current file and Eth_Fec_Reg_Sys header file are of the same vendor */
#if (ETH_VENDOR_ID_C != ETH_VENDOR_ID_REG_SYS_H)
    #error "Eth_PBcfg.c and Eth_Fec_Reg_Sys.h have different vendor ids"
#endif
/* Check if current file and Eth_Fec_Reg_Sys header file are of the same module */
#if (ETH_MODULE_ID_C != ETH_MODULE_ID_REG_SYS_H)
    #error "Eth_PBcfg.c and Eth_Fec_Reg_Sys.h have different vendor ids"
#endif
/* Check if current file and Eth_Fec_Reg_Sys header file are of the same Autosar version */
#if ((ETH_AR_RELEASE_MAJOR_VERSION_C    != ETH_AR_RELEASE_MAJOR_VERSION_REG_SYS_H) || \
     (ETH_AR_RELEASE_MINOR_VERSION_C    != ETH_AR_RELEASE_MINOR_VERSION_REG_SYS_H) || \
     (ETH_AR_RELEASE_REVISION_VERSION_C != ETH_AR_RELEASE_REVISION_VERSION_REG_SYS_H))
    #error "AutoSar Version Numbers of Eth_PBcfg.c and Eth_Fec_Reg_Sys.h are different"
#endif
/* Check if current file and Eth_Fec_Reg_Sys header file are of the same Software version */
#if ((ETH_SW_MAJOR_VERSION_C != ETH_SW_MAJOR_VERSION_REG_SYS_H) || \
     (ETH_SW_MINOR_VERSION_C != ETH_SW_MINOR_VERSION_REG_SYS_H) || \
     (ETH_SW_PATCH_VERSION_C != ETH_SW_PATCH_VERSION_REG_SYS_H))
    #error "Software Version Numbers of Eth_PBcfg.c and Eth_Fec_Reg_Sys.h are different"
#endif
[!AUTOSPACING!][!//
[!NOCODE!][!//
[!/* 
*************************************
* Error checks of the configuration *
*************************************
*/!]
  [!INCLUDE "Eth_VersionChecks.m"!]
  [!INCLUDE "Eth_Checks.m"!]
  [!INCLUDE "Eth_GetRegisterValues.m"!]
[!ENDNOCODE!][!//
/*==================================================================================================
*                          LOCAL TYPEDEFS (STRUCTURES, UNIONS, ENUMS)
==================================================================================================*/


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


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


/*==================================================================================================
*                                      LOCAL VARIABLES
==================================================================================================*/
#define ETH_START_SEC_CONFIG_DATA_UNSPECIFIED
/* @violates @ref Eth_PBcfg_c_REF_1 This violation is not fixed since the inclusion of Eth_MemMap.h is as per AUTOSAR requirement*/
#include "Eth_MemMap.h"
/*******************************************************************************
* Multiple configurations
*******************************************************************************/
[!AUTOSPACING!]
[!SELECT "EthConfigSet"!][!// Select configuration
[!LOOP "EthCtrlConfig/*"!] [!// Loop over the controller config
[!VAR "CtrlConfigName" = "name(.)"!]
        [!CALL "GetRegisterValues"!]
static CONST(Eth_EgressTxCfgType, ETH_APPL_CONST) Eth_Egress_PBConfig[!"$CtrlConfigName"!][ETH_MAX_TXFIFO_CONFIG] =
{
    [!INDENT "4"!]
    [!VAR "LOOP_COUNT1"="num:i(count(EthCtrlConfigEgress/EthCtrlConfigEgressFifo/*))"!]
    [!VAR "END_COMMA1"="0"!]
    [!LOOP "node:order(EthCtrlConfigEgress/EthCtrlConfigEgressFifo/*, 'node:value(EthCtrlConfigEgressFifoIdx)')"!]
    [!VAR "END_COMMA1"="$END_COMMA1 + 1"!]
    {
        [!INDENT "8"!]
        (uint16)[!"num:i(EthCtrlConfigEgressFifoBufLenByte)"!]U,
        (uint8)[!"num:i(EthCtrlConfigEgressFifoBufTotal)"!]U,
        [!ENDINDENT!]
    }[!IF "$END_COMMA1 < $LOOP_COUNT1"!],[!CR!][!ELSE!][!WS "1"!][!ENDIF!]
    [!ENDLOOP!][!CR!]
    [!ENDINDENT!]
};

static CONST(Eth_IngressCfgType, ETH_APPL_CONST) Eth_Ingress_PBConfig[!"$CtrlConfigName"!][ETH_MAX_RXFIFO_CONFIG] =
{
    [!INDENT "4"!]
    [!VAR "LOOP_COUNT1"="num:i(count(EthCtrlConfigIngress/EthCtrlConfigIngressFifo/*))"!]
    [!VAR "END_COMMA1"="0"!]
    [!LOOP "node:order(EthCtrlConfigIngress/EthCtrlConfigIngressFifo/*, 'node:value(EthCtrlConfigIngressFifoIdx)')"!]
        [!VAR "END_COMMA1"="$END_COMMA1 + 1"!]
        {
            [!INDENT "8"!]
            (uint8)[!"num:i(EthCtrlConfigIngressFifoIdx)"!]U,
            (uint16)[!"num:i(EthCtrlConfigIngressFifoBufLenByte)"!]U,
            (uint8)[!"num:i(EthCtrlConfigIngressFifoBufTotal)"!]U
            [!ENDINDENT!]
        }[!IF "$END_COMMA1 < $LOOP_COUNT1"!],[!CR!][!ELSE!][!WS "1"!][!ENDIF!]
    [!ENDLOOP!][!CR!]
    [!ENDINDENT!]
};

[!ENDLOOP!]
[!ENDSELECT!]
/**
* @var Specified for EthCtrlConfig: [!"@name"!]
* @par Memory usage:
[!IF "EthVendorSpecific/EthEnableLoopbackMode/EthInternalLoopbackMode = 'true'"!][!//
*
* @warning Internal loopback is enabled, no external signals will be used
[!ENDIF!][!//
*/
[!SELECT "EthConfigSet"!][!// Select configuration
        [!CALL "GetRegisterValues"!]
        [!VAR "ConfigSet" = "as:name(.)"!]
   [!LOOP "EthCtrlConfig/*"!]
   [!VAR "CtrlConfigName" = "name(.)"!]
[!IF "((../../../IMPLEMENTATION_CONFIG_VARIANT != 'VariantPostBuild') and (variant:size()>1)) or (../../../IMPLEMENTATION_CONFIG_VARIANT = 'VariantPostBuild')"!]
static CONST(Eth_CtrlCfgType, ETH_APPL_CONST) [!"$ConfigSet"!]_[!"$CtrlConfigName"!] =
[!ELSE!]
static CONST(Eth_CtrlCfgType, ETH_APPL_CONST) EthConfigSetPredefined =
[!ENDIF!]
{
    [!INDENT "4"!]
    [!"num:inttohex($MACAddrLow,8)"!]U, /**< First 32 bits of MAC address */
    [!"num:inttohex($MACAddrHigh,8)"!]U, /**< Last 16 bits of MAC address<<16 | 0x8808 */
    (((uint32)[!"EthVendorSpecific/EthMiiSpeed"!]U)<<1U),
    (uint32)[!"num:i($RCRValue)"!]U,
    (uint32)[!"num:i($TCRValue)"!]U,
    (uint8)[!"num:i(EthVendorSpecific/EthTxQueueNum)"!]U,
    (uint8)[!"num:i(EthVendorSpecific/EthRxQueueNum)"!]U,
    Eth_Egress_PBConfig[!"$CtrlConfigName"!],
    Eth_Ingress_PBConfig[!"$CtrlConfigName"!][!CR!]
#if STD_ON == ETH_DEM_EVENT_DETECT
    ,{ [!IF "$EthDemEAccessEnabled     = 'true'"!](uint32)STD_ON[!ELSE!](uint32)STD_OFF[!ENDIF!],[!"$EthDemEAccessEventId"!] },
    { [!IF "$EthDemFrameLostEnabled   = 'true'"!](uint32)STD_ON[!ELSE!](uint32)STD_OFF[!ENDIF!],[!"$EthDemFrameLostEventId"!] },
    { [!IF "$EthDemECRCEnabled        = 'true'"!](uint32)STD_ON[!ELSE!](uint32)STD_OFF[!ENDIF!],[!"$EthDemECRCEventId"!] },
    { [!IF "$EthDemEUnderSizeEnabled  = 'true'"!](uint32)STD_ON[!ELSE!](uint32)STD_OFF[!ENDIF!],[!"$EthDemEUnderSizeEventId"!] },
    { [!IF "$EthDemEOverSizeEnabled   = 'true'"!](uint32)STD_ON[!ELSE!](uint32)STD_OFF[!ENDIF!],[!"$EthDemEOverSizeEventId"!] },
    { [!IF "$EthDemEAlignmentEnabled  = 'true'"!](uint32)STD_ON[!ELSE!](uint32)STD_OFF[!ENDIF!],[!"$EthDemEAlignmentEventId"!] },
    { [!IF "$EthDemE1ColEnabled       = 'true'"!](uint32)STD_ON[!ELSE!](uint32)STD_OFF[!ENDIF!],[!"$EthDemE1ColEventId"!] },
    { [!IF "$EthDemEMColEnabled       = 'true'"!](uint32)STD_ON[!ELSE!](uint32)STD_OFF[!ENDIF!],[!"$EthDemEMColEventId"!] },
    { [!IF "$EthDemELColEnabled       = 'true'"!](uint32)STD_ON[!ELSE!](uint32)STD_OFF[!ENDIF!],[!"$EthDemELColEventId"!] }
#endif
    [!ENDINDENT!]
};
[!ENDLOOP!]
[!ENDSELECT!]

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


/*==================================================================================================
*                                      GLOBAL VARIABLES
==================================================================================================*/
/**
* @brief         Driver configuration to be passed to Eth_Init function
* @details       This array contains references to all multiple configurations
*                to be used for the Eth driver configuration.
*/
/* @violates @ref Eth_PBcfg_c_REF_4 */
/* @violates @ref Eth_PBcfg_c_REF_3 */
[!SELECT "EthConfigSet"!]
    [!VAR "ConfigSet" = "as:name(.)"!]
    [!INDENT "0"!]
[!IF "((../IMPLEMENTATION_CONFIG_VARIANT != 'VariantPostBuild') and (variant:size()>1)) or (../IMPLEMENTATION_CONFIG_VARIANT = 'VariantPostBuild')"!]
    CONST(Eth_ConfigType, ETH_CONST) [!"$ConfigSet"!][!IF "var:defined('postBuildVariant')"!]_[!"$postBuildVariant"!][!ENDIF!] = 
    {
        {
            [!VAR "CtrlNum" = "num:i(count(EthCtrlConfig/*))"!]
            [!VAR "CtrCount" = "0"!]
            [!LOOP "EthCtrlConfig/*"!]
                [!VAR "CtrlConfigName" = "name(.)"!]
                [!INDENT "4"!]
                &[!"$ConfigSet"!]_[!"$CtrlConfigName"!][!IF "$CtrCount < $CtrlNum - 1"!],[!CR!][!ELSE!][!CR!][!ENDIF!]
                [!VAR "CtrCount" = "$CtrCount + 1"!]
                [!ENDINDENT!]
            [!ENDLOOP!]
        }
    };
[!ELSE!]
    CONST(Eth_ConfigType, ETH_CONST) Eth_PBCfgVariantPredefined = 
    {
        {
            [!INDENT "4"!]
            &EthConfigSetPredefined[!CR!]
            [!ENDINDENT!]
        }
    };
[!ENDIF!]
[!ENDINDENT!]
 [!ENDSELECT!]
 
#define ETH_STOP_SEC_CONFIG_DATA_UNSPECIFIED
/* @violates @ref Eth_PBcfg_c_REF_1 This violation is not fixed since the inclusion of Eth_MemMap.h is as per AUTOSAR requirement*/
/* @violates @ref Eth_PBcfg_c_REF_2 Eth_MemMap.h is included after each section define in order to set the current memory section as defined by AUTOSAR */
#include "Eth_MemMap.h"

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


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


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

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