/**
  \file    Eth_GetRegisterValues.m
  \version 1.0.0

  \brief   AUTOSAR Eth - Get register value macro.
  \details Get register values for driver.

  Project         : AUTOSAR 4.3 MCAL
  Platform        : PA
  Peripheral      : FEC
  Dependencies    : 
  
  ARVersion       : 4.3.1
  ARConfVariant
  SWVersion       : 1.0.0
  BuildVersion    : 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
*/
[!MACRO "GetRegisterValues"!][!//
    [!NOCODE!][!//
    [!/* Compute MAC address register values */!]
    [!SELECT "EthVendorSpecific"!]
      [!IF "node:exists(../EthCtrlPhyAddress)"!]
        [!VAR "MACAddrString"="../EthCtrlPhyAddress"!]
        [!VAR "PhysAddress"="concat('0x',text:replaceAll($MACAddrString, ':',''))"!]
        [!VAR "PhysAddress"="num:hextoint($PhysAddress)"!]
      [!ELSE!]
        [!VAR "MACAddrString"="'00:00:00:00:00:00'"!]
        [!VAR "PhysAddress"="0"!]
      [!ENDIF!]
      [!VAR "MACAddrLow" = "num:i(num:div($PhysAddress,65536))"!][!//Get first four numbers
      [!VAR "MACAddrHigh" = "num:i(num:mod($PhysAddress,65536))"!][!//Get last two numbers
      [!VAR "MACAddrHigh" = "num:i($MACAddrHigh * 65536 + num:hextoint('0x8808'))"!][!//Add other bits value
      [!ENDSELECT!]
      [!SELECT "EthVendorSpecific"!][!/* Container is seleccted for simpler access to children */!][!//
      [!// -----------------------------
      [!// RCR value and description set
      [!// -----------------------------
      [!VAR "RCRValue" = "num:i(4)"!][!// Initial register value - MII mode always selected
      [!VAR "EthMaxRxSize" = "../../../../EthGeneral/EthVendorSpecific/EthMaxFrameLength"!]
      [!VAR "MaxFrameSize" = "$EthMaxRxSize * 65536"!][!//get maximum frame size
      [!VAR "RCRValue" = "$RCRValue + $MaxFrameSize"!]
      [!IF "(../EthCtrlEnableMii = 'true') and (../EthCtrlMacLayerSubType = 'REDUCED')"!]
        [!VAR "RCRValue" = "$RCRValue + 256"!][!// RMII is selected.
        [!IF "../EthCtrlMacLayerSpeed = 'ETH_MAC_LAYER_SPEED_10M'"!]
            [!VAR "RCRValue" = "$RCRValue + 512"!]
        [!ENDIF!]
      [!ENDIF!]     
      [!IF "EthDisBroadcast = 'true'"!][!// Broadcast shall be rejected
        [!VAR "RCRValue" = "$RCRValue + 16"!][!// set BC_REJ bit   
      [!ENDIF!]
      [!IF "EthPromiscousEn = 'true'"!][!// Promiscuous mode is enabled
        [!VAR "RCRValue" = "$RCRValue + 8"!][!// set PROM bit  
      [!ENDIF!]
      [!IF "EthInternalLoopbackMode = 'true'"!]
        [!VAR "RCRValue" = "$RCRValue + 1"!][!// set LOOP bit   
      [!ENDIF!]
      [!IF "(EthFullDuplexEnable = 'false') and (EthInternalLoopbackMode = 'false')"!]
          [!/* No loopback and half duplex mode is selected so no reception during transmission is needed - set DRT bit*/!]
          [!VAR "RCRValue" = "$RCRValue + 2"!][!// set DRT bit   
      [!ENDIF!][!// 
      [!// -----------------------------
      [!// TCR value and description set
      [!// -----------------------------
        [!IF "EthFullDuplexEnable = 'false'"!][!//
            [!VAR "TCRValue" = "num:i(0)"!][!// 0x00000000U
        [!ELSE!]
            [!VAR "TCRValue" = "num:i(4)"!][!// 0x00000004U
        [!ENDIF!]
    [!ENDSELECT!]
      [!SELECT "EthDemEventParameterRefs"!]
      [!IF "(../../../../EthGeneral/EthVendorSpecific/EthDisableDemEventDetect = 'false') and (node:exists(../EthDemEventParameterRefs) = true())"!]
        [!IF "node:refvalid(ETH_E_ACCESS) and node:exists(ETH_E_ACCESS)"!]
          [!VAR "EthDemEAccessEnabled" = "'true'"!]
          [!VAR "EthDemEAccessEventId" ="concat('DemConf_DemEventParameter_',node:ref(ETH_E_ACCESS)/@name)"!]
        [!ELSE!][!//
          [!VAR "EthDemEAccessEnabled" = "'false'"!]
          [!VAR "EthDemEAccessEventId" ="num:i(0)"!]
        [!ENDIF!]
        [!IF "node:refvalid(ETH_E_RX_FRAMES_LOST) and node:exists(ETH_E_RX_FRAMES_LOST)"!]
          [!VAR "EthDemFrameLostEnabled" = "'true'"!]
          [!VAR "EthDemFrameLostEventId" ="concat('DemConf_DemEventParameter_',node:ref(ETH_E_RX_FRAMES_LOST)/@name)"!]
        [!ELSE!][!//
          [!VAR "EthDemFrameLostEnabled" = "'false'"!]
          [!VAR "EthDemFrameLostEventId" ="num:i(0)"!]
        [!ENDIF!]
        [!IF "node:refvalid(ETH_E_CRC) and node:exists(ETH_E_CRC)"!]
          [!VAR "EthDemECRCEnabled" = "'true'"!]
          [!VAR "EthDemECRCEventId" ="concat('DemConf_DemEventParameter_',node:ref(ETH_E_CRC)/@name)"!]
        [!ELSE!][!//
          [!VAR "EthDemECRCEnabled" = "'false'"!]
          [!VAR "EthDemECRCEventId" ="num:i(0)"!]
        [!ENDIF!]
        [!IF "node:refvalid(ETH_E_UNDERSIZEFRAME) and node:exists(ETH_E_UNDERSIZEFRAME)"!]
          [!VAR "EthDemEUnderSizeEnabled" = "'true'"!]
          [!VAR "EthDemEUnderSizeEventId" ="concat('DemConf_DemEventParameter_',node:ref(ETH_E_UNDERSIZEFRAME)/@name)"!]
        [!ELSE!][!//
          [!VAR "EthDemEUnderSizeEnabled" = "'false'"!]
          [!VAR "EthDemEUnderSizeEventId" ="num:i(0)"!]
        [!ENDIF!]
        [!IF "node:refvalid(ETH_E_OVERSIZEFRAME) and node:exists(ETH_E_OVERSIZEFRAME)"!]
          [!VAR "EthDemEOverSizeEnabled" = "'true'"!]
          [!VAR "EthDemEOverSizeEventId" ="concat('DemConf_DemEventParameter_',node:ref(ETH_E_OVERSIZEFRAME)/@name)"!]
        [!ELSE!][!//
          [!VAR "EthDemEOverSizeEnabled" = "'false'"!]
          [!VAR "EthDemEOverSizeEventId" ="num:i(0)"!]
        [!ENDIF!]
        [!IF "node:refvalid(ETH_E_ALIGNMENT) and node:exists(ETH_E_ALIGNMENT)"!]
          [!VAR "EthDemEAlignmentEnabled" = "'true'"!]
          [!VAR "EthDemEAlignmentEventId" ="concat('DemConf_DemEventParameter_',node:ref(ETH_E_ALIGNMENT)/@name)"!]
        [!ELSE!][!//
          [!VAR "EthDemEAlignmentEnabled" = "'false'"!]
          [!VAR "EthDemEAlignmentEventId" ="num:i(0)"!]
        [!ENDIF!]
        [!IF "node:refvalid(ETH_E_SINGLECOLLISION) and node:exists(ETH_E_SINGLECOLLISION)"!]
          [!VAR "EthDemE1ColEnabled" = "'true'"!]
          [!VAR "EthDemE1ColEventId" ="concat('DemConf_DemEventParameter_',node:ref(ETH_E_SINGLECOLLISION)/@name)"!]
        [!ELSE!][!//
          [!VAR "EthDemE1ColEnabled" = "'false'"!]
          [!VAR "EthDemE1ColEventId" ="num:i(0)"!]
        [!ENDIF!]
        [!IF "node:refvalid(ETH_E_MULTIPLECOLLISION) and node:exists(ETH_E_MULTIPLECOLLISION)"!]
          [!VAR "EthDemEMColEnabled" = "'true'"!]
          [!VAR "EthDemEMColEventId" ="concat('DemConf_DemEventParameter_',node:ref(ETH_E_MULTIPLECOLLISION)/@name)"!]
        [!ELSE!][!//
          [!VAR "EthDemEMColEnabled" = "'false'"!]
          [!VAR "EthDemEMColEventId" ="num:i(0)"!]
        [!ENDIF!]
        [!IF "node:refvalid(ETH_E_LATECOLLISION) and node:exists(ETH_E_LATECOLLISION)"!]
          [!VAR "EthDemELColEnabled" = "'true'"!]
          [!VAR "EthDemELColEventId" ="concat('DemConf_DemEventParameter_',node:ref(ETH_E_LATECOLLISION)/@name)"!]
        [!ELSE!][!//
          [!VAR "EthDemELColEnabled" = "'false'"!]
          [!VAR "EthDemELColEventId" ="num:i(0)"!]
        [!ENDIF!]
    [!ELSE!]
      [!VAR "EthDemEAccessEnabled" = "'false'"!]
      [!VAR "EthDemEAccessEventId" ="num:i(0)"!]
      [!VAR "EthDemFrameLostEnabled" = "'false'"!]
      [!VAR "EthDemFrameLostEventId" ="num:i(0)"!]
      [!VAR "EthDemECRCEnabled" = "'false'"!]
      [!VAR "EthDemECRCEventId" ="num:i(0)"!]
      [!VAR "EthDemEUnderSizeEnabled" = "'false'"!]
      [!VAR "EthDemEUnderSizeEventId" ="num:i(0)"!]
      [!VAR "EthDemEOverSizeEnabled" = "'false'"!]
      [!VAR "EthDemEOverSizeEventId" ="num:i(0)"!]
      [!VAR "EthDemEAlignmentEnabled" = "'false'"!]
      [!VAR "EthDemEAlignmentEventId" ="num:i(0)"!]
      [!VAR "EthDemE1ColEnabled" = "'false'"!]
      [!VAR "EthDemE1ColEventId" ="num:i(0)"!]
      [!VAR "EthDemEMColEnabled" = "'false'"!]
      [!VAR "EthDemEMColEventId" ="num:i(0)"!]
      [!VAR "EthDemELColEnabled" = "'false'"!]
      [!VAR "EthDemELColEventId" ="num:i(0)"!]
    [!ENDIF!]
    [!ENDSELECT!]
      [!ENDNOCODE!][!//
[!ENDMACRO!][!//