[!NOCODE!][!//
/**
  @file    Mcl_PluginMacros.m
  @version 1.0.0

  @brief   AUTOSAR Mcl - plugin check.
  @details Version checks.

  Project AUTOSAR 4.3 MCAL
  Patform PA
  Peripheral eDMA
  Dependencies none

  ARVersion 4.3.1
  ARRevision ASR_REL_4_3_REV_0001
  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.
*/
/*==================================================================================================
==================================================================================================*/
[!/* *************************** Dem config macro ******************************
******************************************************************************/!]
[!MACRO "DemConfig","MclConfigType"!]

/**
* @brief        DEM error reporting configuration
* @details      Set the state and id for Mcal_DemErrorType. */
/* @violates @ref Cdd_Mcl_Cfg_c_REF_3 MISRA 2012 Advisory 8.7*/
[!IF "$MclConfigType = ''"!][!//
CONST( Mcl_DemConfigType, MCL_CONST) Mcl_Dem_Config =
[!ELSEIF "$MclConfigType = 'PC'"!][!//
CONST( Mcl_DemConfigType, MCL_CONST) Mcl_Dem_Config_[!"$MclConfigType"!] =
[!ELSEIF "$MclConfigType = 'PB'"!][!//
CONST( Mcl_DemConfigType, MCL_CONST) Mcl_Dem_Config_[!"$MclConfigType"!] =
[!ENDIF!][!//
{
    /** MCL_DMA_E_BUS error code */
    {
[!IF "node:exists(MclDemEventParameterRefs/MCL_E_DMA_BUS)"!][!//
        (uint32)STD_ON,
[!ELSE!][!//
        (uint32)STD_OFF,
[!ENDIF!][!//
[!IF "node:exists(MclDemEventParameterRefs/MCL_E_DMA_BUS)"!][!//
        (uint16)DemConf_DemEventParameter_[!"node:ref(MclDemEventParameterRefs/MCL_E_DMA_BUS)/@name"!]
[!ELSE!][!//
        (uint16)0U
[!ENDIF!][!//
    [!/* */!]},
    /** MCL_DMA_E_DESCRIPTOR  error code */
    {
[!IF "node:exists(MclDemEventParameterRefs/MCL_E_DMA_DESCRIPTOR)"!][!//
        (uint32)STD_ON,
[!ELSE!][!//
        (uint32)STD_OFF,
[!ENDIF!][!//
[!IF "node:exists(MclDemEventParameterRefs/MCL_E_DMA_DESCRIPTOR)"!][!//
        (uint16)DemConf_DemEventParameter_[!"node:ref(MclDemEventParameterRefs/MCL_E_DMA_DESCRIPTOR)/@name"!]
[!ELSE!][!//
        (uint16)0U
[!ENDIF!][!//
    [!/* */!]},
    /** MCL_DMA_E_ECC error code */
    {
[!IF "node:exists(MclDemEventParameterRefs/MCL_E_DMA_ECC)"!][!//
        (uint32)STD_ON,
[!ELSE!][!//
        (uint32)STD_OFF,
[!ENDIF!][!//
[!IF "node:exists(MclDemEventParameterRefs/MCL_E_DMA_ECC)"!][!//
        (uint16)DemConf_DemEventParameter_[!"node:ref(MclDemEventParameterRefs/MCL_E_DMA_ECC)/@name"!]
[!ELSE!][!//
        (uint16)0U
[!ENDIF!][!//
    [!/* */!]},
    /** MCL_DMA_E_PRIORITY error code */
    {
[!IF "node:exists(MclDemEventParameterRefs/MCL_E_DMA_PRIORITY)"!][!//
        (uint32)STD_ON,
[!ELSE!][!//
        (uint32)STD_OFF,
[!ENDIF!][!//
[!IF "node:exists(MclDemEventParameterRefs/MCL_E_DMA_PRIORITY)"!][!//
        (uint16)DemConf_DemEventParameter_[!"node:ref(MclDemEventParameterRefs/MCL_E_DMA_PRIORITY)/@name"!]
[!ELSE!][!//
        (uint16)0U
[!ENDIF!][!//
    [!/* */!]},

    /** MCL_DMA_E_UNRECOGNIZED error code */
    {
[!IF "node:exists(MclDemEventParameterRefs/MCL_E_DMA_UNRECOGNIZED)"!][!//
        (uint32)STD_ON,
[!ELSE!][!//
        (uint32)STD_OFF,
[!ENDIF!][!//
[!IF "node:exists(MclDemEventParameterRefs/MCL_E_DMA_UNRECOGNIZED)"!][!//
        (uint16)DemConf_DemEventParameter_[!"node:ref(MclDemEventParameterRefs/MCL_E_DMA_UNRECOGNIZED)/@name"!]
[!ELSE!][!//
        (uint16)0U
[!ENDIF!][!//
    [!/* */!]},

    /** MCL_DMA_E_INCONSISTENCY error code */
    {
[!IF "node:exists(MclDemEventParameterRefs/MCL_E_DMA_INCONSISTENCY)"!][!//
        (uint32)STD_ON,
[!ELSE!][!//
        (uint32)STD_OFF,
[!ENDIF!][!//
[!IF "node:exists(MclDemEventParameterRefs/MCL_E_DMA_INCONSISTENCY)"!][!//
        (uint16)DemConf_DemEventParameter_[!"node:ref(MclDemEventParameterRefs/MCL_E_DMA_INCONSISTENCY)/@name"!]
[!ELSE!][!//
        (uint16)0U
[!ENDIF!][!//
    [!/* */!]}
};
[!ENDMACRO!][!// Dem config end

[!/* *************************** Notification config macro ******************************
******************************************************************************/!]
[!MACRO "NotificationHandler","Suffix"!]
/* DMA Channel Transfer Completion Notifications */
#if (MCL_DMA_NOTIFICATION_SUPPORTED == STD_ON)
[!NOCODE!]
        [!VAR "OuterLoopCounter" = "0"!]
        [!VAR "InnerLoopCounter" = "0"!]
        [!LOOP "MclConfigSet/*/DMAChannel/*"!]
            [!VAR "OuterLoopCounter" = "$OuterLoopCounter + 1"!]
            [!VAR "InnerLoopCounter" = "0"!]
            [!VAR "MatchCounter" = "0"!]
            [!VAR "Notification" = "MclDmaTransferCompletionNotif"!]

            [!LOOP "../../../*/DMAChannel/*"!]
              [!VAR "InnerLoopCounter" = "$InnerLoopCounter + 1"!]
              [!IF "(MclDmaTransferCompletionNotif != 'NULL_PTR') and (MclDmaTransferCompletionNotif != '"NULL"') and (MclDmaTransferCompletionNotif != 'NULL')"!]
                  [!IF "$OuterLoopCounter >= $InnerLoopCounter"!]
                      [!IF "($Notification = MclDmaTransferCompletionNotif)"!]
                          [!VAR "MatchCounter" = "$MatchCounter + 1"!]
                      [!ENDIF!]
                  [!ENDIF!]
              [!ENDIF!]
            [!ENDLOOP!]

            [!IF "$MatchCounter = 1"!]
                /* issue error if the ISR is disabled */
                [!VAR "hwCh" = "DmaHwChannel"!]
                [!LOOP "../../../../MclGeneral/MclIsrAvailable/*"!]
                    [!IF "(MclIsrName = $hwCh) and (MclIsrEnabled =  'false')"!]
                        [!ERROR!] [!//
                             "Interrupt configuration error ! Mcl hardware channel [!"$hwCh"!] has a transfer completion notification configured in one of the variants, but the ISR for the channel is disabled in the Mcl Interrupts Available TAB. "[!//
                        [!ENDERROR!][!//
                    [!ENDIF!]
                [!ENDLOOP!][!//
[!CODE!]
/** Completion Notification for [!"$hwCh"!] channel*/
/* @violates @ref Cdd_Mcl_PBcfg_c_REF_4 MISRA 2012 Required 8.5*/
extern FUNC(void, MCL_CODE)[!"MclDmaTransferCompletionNotif"!](void);
[!ENDCODE!]
            [!ENDIF!]
        [!ENDLOOP!]
[!ENDNOCODE!]
#endif

#if (MCL_DMA_ERROR_INTERRUPTS_USED == STD_ON)
[!NOCODE!]
[!IF "(MclGeneral/MclErrorNotification != 'NULL_PTR') and (MclGeneral/MclErrorNotification != '"NULL"') and (MclGeneral/MclErrorNotification != 'NULL')"!]

[!CODE!]
/** Error Dma Common Notification*/
/* @violates @ref Cdd_Mcl_PBcfg_c_REF_4 MISRA 2012 Required 8.5*/
extern FUNC(void, MCL_CODE) [!"normalize-space(MclGeneral/MclErrorNotification)"!](VAR(Mcl_DmaChannelErrorStatusType, AUTOMATIC) u8ErrorCode);
[!ENDCODE!]
[!ENDIF!]
[!ENDNOCODE!]
/* DMA Channel Transfer Error Notifications */
[!NOCODE!]
        [!VAR "OuterLoopCounter" = "0"!]
        [!VAR "InnerLoopCounter" = "0"!]
        [!LOOP "MclConfigSet/*/DMAChannel/*"!]
            [!VAR "OuterLoopCounter" = "$OuterLoopCounter + 1"!]
            [!VAR "InnerLoopCounter" = "0"!]
            [!VAR "MatchCounter" = "0"!]
            [!VAR "ErrNotification" = "MclDmaTransferErrorNotif"!]

            [!LOOP "../../../*/DMAChannel/*"!]
              [!VAR "InnerLoopCounter" = "$InnerLoopCounter + 1"!]
              [!IF "(MclDmaTransferErrorNotif != 'NULL_PTR') and (MclDmaTransferErrorNotif != '"NULL"') and (MclDmaTransferErrorNotif != 'NULL')"!]
                  [!IF "$OuterLoopCounter >= $InnerLoopCounter"!]
                      [!IF "($ErrNotification = MclDmaTransferErrorNotif)"!]
                          [!VAR "MatchCounter" = "$MatchCounter + 1"!]
                      [!ENDIF!]
                  [!ENDIF!]
              [!ENDIF!]
            [!ENDLOOP!]

            [!IF "$MatchCounter = 1"!]
                [!VAR "hwCh" = "DmaHwChannel"!]
[!CODE!]
/** Error Notification for [!"$hwCh"!] channel*/
/* @violates @ref Cdd_Mcl_PBcfg_c_REF_4 MISRA 2012 Required 8.5*/
extern FUNC(void, MCL_CODE)[!"MclDmaTransferErrorNotif"!](VAR(Mcl_DmaChannelErrorStatusType, AUTOMATIC) u8ErrorCode);
[!ENDCODE!]
            [!ENDIF!]
        [!ENDLOOP!]
[!ENDNOCODE!]
#endif
[!ENDMACRO!][!// Notification config end

[!/* *************************** DMA channel config ******************************
******************************************************************************/!]
[!MACRO "DmaChannelConfig","DmaConfigType"!]
[!IF "$DmaConfigType ='PC'"!][!//
static CONST(Mcl_DmaChannelConfigType, MCL_CONST) Mcl_Dma_ChannelConfig_[!"$DmaConfigType"!][MCL_DMA_CONF_CHANNELS_[!"$DmaConfigType"!]] =
[!ELSEIF "$DmaConfigType ='PB'"!][!//
static CONST(Mcl_DmaChannelConfigType, MCL_CONST) Mcl_Dma_ChannelConfig_[!"$DmaConfigType"!]_[!"@index"!][MCL_DMA_CONF_CHANNELS_[!"$DmaConfigType"!]_[!"@index"!]] =
[!ELSE!][!//
static CONST(Mcl_DmaChannelConfigType, MCL_CONST) Mcl_Dma_ChannelConfig[!IF "var:defined('postBuildVariant')"!]_[!"$postBuildVariant"!][!ENDIF!][MCL_DMA_CONF_CHANNELS_PB[!IF "var:defined('postBuildVariant')"!]_[!"$postBuildVariant"!][!ENDIF!]] =
[!ENDIF!][!//
{
[!FOR "varCounter" = "0" TO "num:i(count(DMAChannel/*))"!][!//
[!LOOP "DMAChannel/*"!][!//
[!IF "MclDMAChannelId = $varCounter"!][!//
    /** @brief [!"node:name(.)"!] - [!"DmaHwChannel"!] */
    {
[!/* */!][!VAR "DmaCh" = "substring-after(node:value(DmaHwChannel),'eDMA_')"!][!//
[!IF "(num:i($DmaCh))<(num:i($TotalNumberOfChannelsMainDie))"!][!//
        /** @brief Enable Channel Preemption */
        ([!IF "ECP='true'"!]DMAV3_ECP_EN_U32[!ELSE!]DMAV3_ECP_DIS_U32[!ENDIF!]) |
        /** @brief Disable Preempt Ability */
        ([!IF "DPA='true'"!]DMAV3_DPA_EN_U32[!ELSE!]DMAV3_DPA_DIS_U32[!ENDIF!]) |
        /** @brief Channel Priority */
        (DMA_PRIORITY_[!"DMAChannelPriority"!]_U8),
        /** @brief Channel Group Priority */
        (DMA_PRIORITY_[!"DMAChannelGroupPriority"!]_U8),
        /** @brief eDMA HW Channel used by the Mcl channel */
        (DMA_HW_CHANNEL_[!"$DmaCh"!]),
        /** @brief Master ID Replication */
        ([!IF "EMI='true'"!]DMAV3_EMI_EN_U32[!ELSE!]DMAV3_EMI_DIS_U32[!ENDIF!])
#ifdef MCL_DMA_SETUP_EARS
#if (MCL_DMA_SETUP_EARS == STD_ON)
        /** @brief Enable Asynchronous Request in Stop Register it only use for DMAV2 */
        ,0U
#endif
#endif
[!ELSE!][!//
        /** @brief Enable Channel Preemption */
        ([!IF "ECP='true'"!]DMAV2_ECP_EN_U32[!ELSE!]DMAV2_ECP_DIS_U32[!ENDIF!]) |
        /** @brief Disable Preempt Ability */
        ([!IF "DPA='true'"!]DMAV2_DPA_EN_U32[!ELSE!]DMAV2_DPA_DIS_U32[!ENDIF!]) |
        /** @brief Channel Priority */
        (DMA_PRIORITY_[!"DMAChannelPriority"!]_U8),
        /** @brief Channel Group Priority */
        (DMA_PRIORITY_[!"DMAChannelGroupPriority"!]_U8),
        /** @brief eDMA HW Channel used by the Mcl channel */
        (DMA_HW_CHANNEL_[!"$DmaCh"!]),
        /** @brief Master ID Replication */
        ([!IF "EMI='true'"!]DMAV2_EMI_EN_U8[!ELSE!]DMAV2_EMI_DIS_U8[!ENDIF!])[!CR!]
#ifdef MCL_DMA_SETUP_EARS
#if (MCL_DMA_SETUP_EARS == STD_ON)
        /** @brief Enable Asynchronous Request in Stop Register */
        [!IF "MclDMAChannelEnable='true'"!],1U[!ELSE!],0U[!ENDIF!]
#endif
#endif
[!ENDIF!][!//
    }[!IF "(num:i($comma))<(num:i($dmaChannelCount))"!],[!ENDIF!][!CR!][!VAR "comma"="$comma + 1"!][!//
[!ENDIF!][!//
[!ENDLOOP!][!//
[!ENDFOR!][!//
};
[!NOCODE!][!//
[!VAR "numDMAchannel" = "(num:i(count(DMAChannel/*))) -1"!][!//
[!FOR "varCounter" = "0" TO "$numDMAchannel -1"!][!//
    [!FOR "firstindex" = "$varCounter +1" TO "$numDMAchannel -1"!][!//
    [!VAR "DmaChannelConfigX" = "substring-after(node:value(concat(concat('DMAChannel/*[',$varCounter + 1),']/DmaHwChannel')),'eDMA_')"!][!//
    [!VAR "DmaChannelConfigY" = "substring-after(node:value(concat(concat('DMAChannel/*[',$firstindex + 1),']/DmaHwChannel')),'eDMA_')"!][!//
    [!VAR "DmachannelPriorityX" = "node:value(concat(concat('DMAChannel/*[',$varCounter + 1),']/DMAChannelPriority'))"!][!//
    [!VAR "DmachannelPriorityY" = "node:value(concat(concat('DMAChannel/*[',$firstindex +1),']/DMAChannelPriority'))"!][!//
    [!VAR "DmaGroupchannelX" = "floor($DmaChannelConfigX div num:i(ecu:get('Mcl.eDMA.ChannelNumberPerGroup')))"!][!//
    [!VAR "DmaGroupchannelY" = "floor($DmaChannelConfigY div num:i(ecu:get('Mcl.eDMA.ChannelNumberPerGroup')))"!][!//
    [!VAR "DmaChannelNumNain" = "num:i(ecu:get('Mcl.eDMA.ChannelNumberMain'))"!][!//
        [!IF "(num:i($DmachannelPriorityX) = num:i($DmachannelPriorityY)) and ($DmaGroupchannelX = $DmaGroupchannelY) and (num:i($DmaChannelConfigX) >= $DmaChannelNumNain) and (num:i($DmaChannelConfigY) >= $DmaChannelNumNain)"!][!//
            [!ERROR!] [!//
                                "Priority configuration error !Duplicate priority channel [!"$DmaChannelConfigX"!] and channel [!"$DmaChannelConfigY"!] "[!//
            [!ENDERROR!][!//
        [!ENDIF!][!//
    [!ENDFOR!][!//
[!ENDFOR!][!//
[!ENDNOCODE!][!//
[!ENDMACRO!][!// DMA channel config
[!/* *************************** DMA instance config ******************************
******************************************************************************/!]
[!MACRO "DmaInstanceConfig","DmaConfigType"!]
[!IF "$DmaConfigType = 'PC'"!][!//
static CONST(Mcl_DmaConfigInstanceType, MCL_CONST) Mcl_Dma_InstanceConfig_[!"$DmaConfigType"!][MCL_DMA_NB_CONTROLLERS] =
[!ELSEIF "$DmaConfigType = 'PB'"!][!//
static CONST(Mcl_DmaConfigInstanceType, MCL_CONST) Mcl_Dma_InstanceConfig_[!"$DmaConfigType"!]_[!"@index"!][MCL_DMA_NB_CONTROLLERS] =
[!ELSE!][!//
static CONST(Mcl_DmaConfigInstanceType, MCL_CONST) Mcl_Dma_InstanceConfig[!IF "var:defined('postBuildVariant')"!]_[!"$postBuildVariant"!][!ENDIF!][MCL_DMA_NB_CONTROLLERS] =
[!ENDIF!][!//
{
[!NOCODE!][!//
    [!VAR "comma" = "0"!][!//
    [!FOR "currentInstance" = "0" TO "$LastDmaInstanceId"!]
    [!CODE!][!//
    /** @brief Dma Hardware Instance [!"$currentInstance"!]*/
    {[!ENDCODE!][!//
        [!VAR "dmaCurrentInstanceExists" = "num:i(0)"!][!//
        [!LOOP "DmaInstance/*"!][!//
            [!VAR "dmaCurrentInstanceNumber" = "substring-after(node:value(DmaHwInstance),'eDMA_Instance')"!][!//
            [!IF "$dmaCurrentInstanceNumber = $currentInstance"!][!//
                [!VAR "dmaCurrentInstanceExists" = "num:i(1)"!][!//
                [!VAR "ChannelExistsForCrtDmaInstance" = "num:i(0)"!][!//
                [!LOOP "../../DMAChannel/*"!][!//
                    [!VAR "DmaCh" = "substring-after(node:value(DmaHwChannel),'eDMA_')"!][!//
                    [!VAR "Group" = "num:i($DmaCh div $ChannelsPerDmaGroup)"!][!//
                    [!VAR "CurrentDma" = "num:i($DmaCh div $ChannelsPerDmaInstance)"!][!//
                    [!IF "num:i($dmaCurrentInstanceNumber) = $CurrentDma"!][!//
                        [!VAR "ChannelExistsForCrtDmaInstance"="num:i(1)"!][!//
                    [!ENDIF!][!//
                [!ENDLOOP!][!//
                [!IF "$ChannelExistsForCrtDmaInstance=0"!][!//
                    [!WARNING!][!//
                    "Inconsistent Configuration! For Dma Instance [!"$currentInstance"!] there is no channel configured. It should be at least one channel configured."[!//
                    [!ENDWARNING!][!//
                [!ENDIF!][!CR!]
[!CODE!][!//
    /** @brief Dma CR Register */
[!IF "node:value(DmaHwInstanceVersion) = "eDMA_v3" "!][!//
        (uint32)(([!IF "MclEDMA_CX='true'"!]DMAV3_CANCEL_TRANSFER_EN_U32[!ELSE!]DMA_CANCEL_TRANSFER_DIS_U32[!ENDIF!]) |
        ([!IF "MclEDMA_ECX='true'"!]DMAV3_ERROR_CANCEL_TRANSFER_EN_U32[!ELSE!]DMA_ERROR_CANCEL_TRANSFER_DIS_U32[!ENDIF!]) |
        ([!IF "MclEDMA_EBW='true'"!]DMAV3_BUFFER_WRITES_EN_U32[!ELSE!]DMAV3_BUFFER_WRITES_DIS_U32[!ENDIF!]) |
        ([!IF "MclEDMA_GMRC='true'"!]DMAV3_GMRC_EN_U32[!ELSE!]DMAV3_GMRC_DIS_U32[!ENDIF!]) |
        ([!IF "MclEDMA_GCLC='true'"!]DMA_CH_LINK_EN_U32[!ELSE!]DMA_CH_LINK_DIS_U32[!ENDIF!]) |
[!ELSE!][!//
        (uint32)(([!IF "MclEDMA_CX='true'"!]DMAV2_CANCEL_TRANSFER_EN_U32[!ELSE!]DMA_CANCEL_TRANSFER_DIS_U32[!ENDIF!]) |
        ([!IF "MclEDMA_ECX='true'"!]DMAV2_ERROR_CANCEL_TRANSFER_EN_U32[!ELSE!]DMA_ERROR_CANCEL_TRANSFER_DIS_U32[!ENDIF!]) |
        ([!IF "MclEDMA_CLM='true'"!]DMA_CH_LINK_EN_U32[!ELSE!]DMA_CH_LINK_DIS_U32[!ENDIF!]) |
[!ENDIF!][!//
    [!IF "MclEDMA_ERGA='false'"!][!//
    [!IF "$DmaPriorityGroup0Exists = 'true'"!][!WS "4"!]((uint32)[!"num:i(MclEDMAChGroup0Priority)"!] << DMA_CHANNEL_GROUP_0_PRIORITY_SHIFT_U8) |[!CR!][!ENDIF!]
    [!IF "$DmaPriorityGroup1Exists = 'true'"!][!WS "4"!]((uint32)[!"num:i(MclEDMAChGroup1Priority)"!] << DMA_CHANNEL_GROUP_1_PRIORITY_SHIFT_U8) |[!CR!][!ENDIF!]
    [!IF "$DmaPriorityGroup2Exists = 'true'"!][!WS "4"!]((uint32)[!"num:i(MclEDMAChGroup2Priority)"!] << DMA_CHANNEL_GROUP_2_PRIORITY_SHIFT_U8) |[!CR!][!ENDIF!]
    [!IF "$DmaPriorityGroup3Exists = 'true'"!][!WS "4"!]((uint32)[!"num:i(MclEDMAChGroup3Priority)"!] << DMA_CHANNEL_GROUP_3_PRIORITY_SHIFT_U8) |[!CR!][!ENDIF!]
[!ENDIF!][!//
        ([!IF "MclEDMA_HALT='true'"!]DMA_HALT_OPERATIONS_EN_U32[!ELSE!]DMA_HALT_OPERATIONS_DIS_U32[!ENDIF!]) |
        ([!IF "MclEDMA_HOE='true'"!]DMA_HALT_ON_ERROR_EN_U32[!ELSE!]DMA_HALT_ON_ERROR_DIS_U32[!ENDIF!]) |
[!ENDCODE!][!//
[!CODE!]    [!IF "MclEDMA_ERGA='true'"!](DMA_ROUND_ROBIN_GROUP_ARB_EN_U32)[!ELSE!]
    (DMA_ROUND_ROBIN_GROUP_ARB_DIS_U32)[!ENDIF!] |[!ENDCODE!]
[!CODE!][!//
        ([!IF "MclEDMA_ERCA='true'"!]DMA_ROUND_ROBIN_ARB_EN_U32[!ELSE!]DMA_ROUND_ROBIN_ARB_DIS_U32[!ENDIF!]) |
        [!IF "MclEDMA_EDBG='true'"!](DMA_DEBUG_EN_U32)[!ELSE!](DMA_DEBUG_DIS_U32)[!ENDIF!]),
         /** @brief Hardware Dma Instance version - eDMA2 and eDMA3 supported */
        ([!IF "node:value(DmaHwInstanceVersion) = "eDMA_v3""!]MCL_EDMA_V3[!ELSE!]MCL_EDMA_V2[!ENDIF!]),
         /** @brief Dma Usage in Configuration */
        ([!IF "$ChannelExistsForCrtDmaInstance=1"!]DMA_INSTANCE_USED[!ELSE!]DMA_INSTANCE_NOT_USED[!ENDIF!])
[!ENDCODE!]

[!CODE!]    }[!IF "(num:i($comma))<(num:i($LastDmaInstanceId))"!],[!ENDIF!][!CR!][!VAR "comma"="$comma + 1"!][!ENDCODE!][!//
        [!ENDIF!][!//
    [!ENDLOOP!][!//
    [!IF "$dmaCurrentInstanceExists=0"!][!//
        [!LOOP "DMAChannel/*"!][!//
                [!VAR "DmaCh" = "substring-after(node:value(DmaHwChannel),'eDMA_')"!][!//
                [!VAR "Group" = "num:i($DmaCh div $ChannelsPerDmaGroup)"!][!//
                [!VAR "CurrentDma" = "num:i($Group div (num:i($ChannelsPerDmaInstance div $ChannelsPerDmaGroup)))"!][!//
                [!IF "num:i($currentInstance) = $CurrentDma"!][!//
                    [!ERROR!][!//
                           "Inconsistent Configuration! Dma hardware channel eDMA_[!"$DmaCh"!] uses Dma instance eDMA_Instance[!"$currentInstance"!] which is not configured."[!//
                    [!ENDERROR!][!//
                [!ENDIF!][!//
        [!ENDLOOP!]
[!CODE!]    /** @brief Dma Hardware Instance [!"$currentInstance"!] */
    /** @brief Dma CR Register */
    (Mcl_DmaControlType)0x00000400UL,
    /** @brief Hardware Dma Instance version - eDMA2 and eDMA3 supported */[!CR!]
    ([!IF "node:value(DmaHwInstanceVersion) = "eDMA_v3""!]MCL_EDMA_V3[!ELSE!]MCL_EDMA_V2[!ENDIF!]),
    /** @brief Dma Usage in Configuration */
    DMA_INSTANCE_NOT_USED
[!ENDCODE!]
[!CODE!]    }[!IF "(num:i($comma))<(num:i($LastDmaInstanceId))"!],[!ENDIF!][!CR!][!VAR "comma"="$comma + 1"!][!ENDCODE!][!//
    [!ENDIF!][!//
[!ENDFOR!][!//
[!ENDNOCODE!][!//
};
[!ENDMACRO!][!// DMA instances config

[!/* *************************** DMA MUX Channel config ******************************
******************************************************************************/!]




[!MACRO "DmaCrcChannelConfig","DmaConfigType"!]
[!IF "$DmaCrcInstancesNumber != 0"!][!//
[!IF "$DmaCrcChannelsNo > 0"!][!//
[!NOCODE!]/***************************** Configuration for DMACRC ********************/[!ENDNOCODE!][!//
/** @brief Configuration for DmaCrc channels */
[!IF "$DmaConfigType = 'PC'"!][!//
static CONST( Mcl_DmaCrcChannelConfigType, MCL_CONST) Mcl_DmaCrc_ChannelConfig_[!"$DmaConfigType"!][MCL_DMACRC_CONF_CHANNELS_[!"$DmaConfigType"!]] =
[!ELSEIF "$DmaConfigType = 'PB'"!][!//
static CONST( Mcl_DmaCrcChannelConfigType, MCL_CONST) Mcl_DmaCrc_ChannelConfig_[!"$DmaConfigType"!]_[!"@index"!][MCL_DMACRC_CONF_CHANNELS_[!"$DmaConfigType"!]_[!"@index"!]] =
[!ELSE!][!//
static CONST( Mcl_DmaCrcChannelConfigType, MCL_CONST) Mcl_DmaCrc_ChannelConfig[!IF "var:defined('postBuildVariant')"!]_[!"$postBuildVariant"!][!ENDIF!][MCL_DMACRC_CONF_CHANNELS[!IF "var:defined('postBuildVariant')"!]_[!"$postBuildVariant"!][!ENDIF!]] =
[!ENDIF!][!//
{
[!NOCODE!][!//
[!VAR "comma" = "1"!][!//
[!FOR "varCounter" = "0" TO "num:i(count(DMACrcChannel/*))"!][!//
    [!LOOP "DMACrcChannel/*"!][!//
        [!IF "MclDMACRCChannelId = $varCounter"!][!//
            [!VAR "DmaCh" = "num:i(substring-after(node:value(DmaCRCHwChannel),'DMACRC_'))"!][!//
            [!VAR "DmaCrcInstance"="$DmaCh div $ChannelNumberPerDmaCrc"!][!//
            [!VAR "DmaCrcInstance"="num:i($DmaCrcInstance)"!][!//
            [!VAR "DmaCrcInitialPolynome" = "node:value(MclCRCInitialPolynome)"!][!//
            [!IF "$DmaCrcInstance < $DmaCrcInstancesNumber"!][!//
                [!CODE!][!CR!][!WS,"4"!]{[!ENDCODE!]
                [!CODE!][!CR!][!WS,"8"!]/** @brief Hardware DMACRC channel used */[!ENDCODE!]
                [!CODE!][!CR!][!WS,"8"!]DMACRC_CH_[!"$DmaCh"!],[!ENDCODE!]
                [!CODE!][!CR!][!WS,"8"!]/** @brief DMACRC Initial Polynome */[!ENDCODE!]
                [!CODE!][!CR!][!WS,"8"!](uint32)([!"num:inttohex($DmaCrcInitialPolynome)"!]UL),[!ENDCODE!]
                [!CODE!][!CR!][!WS,"8"!]/** @brief DMACRC_CTRLn register configuration */[!ENDCODE!]
                [!CODE!][!CR!][!WS,"8"!](([!"concat(node:value(./MclCRCInitialValues),'_U32')"!]) |[!ENDCODE!]
                [!CODE!][!CR!][!WS,"8"!]([!"concat(node:value(./MclCRCPolynomialSelect),'_U32')"!]) |[!ENDCODE!]
                [!IF "$DmaCrcInstance != 0"!]
                    [!CODE!][!CR!][!WS,"8"!](uint32)[!"num:i(number(MclDMACRCChannel)-32)"!]U)[!ENDCODE!]
                [!ELSE!]
                    [!CODE!][!CR!][!WS,"8"!](uint32)[!"MclDMACRCChannel"!]U)[!ENDCODE!]
                [!ENDIF!]
[!/* */!][!CODE!][!CR!][!WS,"4"!]}[!IF "(num:i($comma))<(num:i($dmaCrcChannelCount))"!],[!ENDIF!][!CR!][!VAR "comma"="$comma + 1"!][!ENDCODE!][!//
            [!ENDIF!][!//
        [!ENDIF!][!//
    [!ENDLOOP!][!//
[!ENDFOR!][!//
[!ENDNOCODE!]
};
[!ELSE!][!//
/** @brief Configuration for DmaCrc channels */
[!IF "$DmaConfigType = 'PC'"!][!//
static CONST( Mcl_DmaCrcChannelConfigType, MCL_CONST) Mcl_DmaCrc_ChannelConfig_[!"$DmaConfigType"!][MCL_DMACRC_CONF_CHANNELS_[!"$DmaConfigType"!]+1U] =
[!ELSEIF "$DmaConfigType = 'PB'"!][!//
static CONST( Mcl_DmaCrcChannelConfigType, MCL_CONST) Mcl_DmaCrc_ChannelConfig_[!"$DmaConfigType"!]_[!"@index"!][MCL_DMACRC_CONF_CHANNELS_[!"$DmaConfigType"!]+1U] =
[!ELSE!][!//
static CONST( Mcl_DmaCrcChannelConfigType, MCL_CONST) Mcl_DmaCrc_ChannelConfig[!IF "var:defined('postBuildVariant')"!]_[!"$postBuildVariant"!][!ENDIF!][MCL_DMACRC_CONF_CHANNELS[!IF "var:defined('postBuildVariant')"!]_[!"$postBuildVariant"!]+1U[!ENDIF!]] =
[!ENDIF!][!//
{
    /** @brief Dummy config used for the case when no DMACRC channel is configured */
    {
        /** @brief Hardware DMACRC channel used */
        DMACRC_CH_0,
        /** @brief DMACRC instance used */
        DMACRC_0,
        /** @brief DMACRC_CTRLn register configuration */
        (0U)
    }
};
[!ENDIF!][!//
[!ENDIF!][!//
[!ENDMACRO!][!// DMA Crc Channel Config





[!/* *************************** AXBS Config Master ******************************
******************************************************************************/!]
[!MACRO "AxbsConfigMaster","AxbsConfigType"!]

/**
* @brief Number of configured Master port
*/
[!VAR "MastercrossbarPortCount" = "num:i(count(MclCrossbarLogicalMasterPorts/*))"!]

[!IF "$EnableInitAXBS_MGPCR = 1"!]
[!IF "$AxbsConfigType = 'PC'"!]
#define MCL_CROSSBAR_MASTER_PORTS_[!"$AxbsConfigType"!]  [!"$MastercrossbarPortCount"!]
static CONST( Mcl_CrossbarMasterHwIpsConfigType, MCL_CONST)Mcl_Crossbar_MasterPortConfig_[!"$AxbsConfigType"!][MCL_CROSSBAR_MASTER_PORTS_[!"$AxbsConfigType"!]] =
[!ELSEIF "$AxbsConfigType = 'PB'"!]
#define MCL_CROSSBAR_MASTER_PORTS_[!"@index"!]  [!"$MastercrossbarPortCount"!]
static CONST( Mcl_CrossbarMasterHwIpsConfigType, MCL_CONST)Mcl_Crossbar_MasterPortConfig_[!"@index"!][MCL_CROSSBAR_MASTER_PORTS_[!"@index"!]] =
[!ELSE!]
#define MCL_CROSSBAR_MASTER_PORTS[!IF "var:defined('postBuildVariant')"!]_[!"$postBuildVariant"!][!ENDIF!]  [!"$MastercrossbarPortCount"!]
static CONST( Mcl_CrossbarMasterHwIpsConfigType, MCL_CONST)Mcl_Crossbar_MasterPortConfig[!IF "var:defined('postBuildVariant')"!]_[!"$postBuildVariant"!][!ENDIF!][MCL_CROSSBAR_MASTER_PORTS[!IF "var:defined('postBuildVariant')"!]_[!"$postBuildVariant"!][!ENDIF!]] =
[!ENDIF!]
{
    [!VAR "comma" = "1"!][!//
    [!LOOP "MclCrossbarLogicalMasterPorts/*"!][!//
        [!VAR "MclMasterCrossbarHwPortNumber"="node:value(node:ref(MclCrossbarHwMasterPortRef)/MclMasterPortNumber)"!][!//
        [!VAR "MclCrossbarInstanceNumber" = "substring-after(node:value((node:ref(MclCrossbarHwMasterPortRef))/../../MclCrossbarHwInstance),"AXBS_")"!][!//
        [!VAR "MclCrossbarArbitrates" = "node:value((node:ref(MclCrossbarHwMasterPortRef))/MclCrossbarArbitrates)"!][!//
        {
            [!"$MclMasterCrossbarHwPortNumber"!]U,
            [!"$MclCrossbarInstanceNumber"!]U,
            ((uint32)([!"num:i($MclCrossbarArbitrates)"!]UL) >> AXBS_AULB_SHIFT_U32)
        }[!IF "(num:i($comma))<(num:i($MastercrossbarPortCount))"!],[!ENDIF!][!CR!][!VAR "comma"="$comma + 1"!][!//
    [!ENDLOOP!][!//
};
[!ENDIF!][!//
[!ENDMACRO!][!// AXBS Config Master

[!/* *************************** AXBS Config Slave ******************************
******************************************************************************/!]
[!MACRO "AxbsConfigSlave","AxbsConfigType"!]
[!NOCODE!]/*********************** Configuration for the crossbar switch ******************/[!ENDNOCODE!][!//
/**
* @brief Number of configured crossbar channels
*/
[!VAR "crossbarPortCount" = "num:i(count(MclCrossbarLogicalSlavePorts/*))"!]

[!IF "$AxbsConfigType = 'PC'"!]
#define MCL_CROSSBAR_CONF_PORTS_PC  [!"$crossbarPortCount"!]
/** @brief Configuration for the crossbar ports */
static CONST( Mcl_CrossbarSlaveHwIpsConfigType, MCL_CONST)Mcl_Crossbar_SlavePortConfig_PC[MCL_CROSSBAR_CONF_PORTS_PC] =
[!ELSEIF "$AxbsConfigType = 'PB'"!]
#define MCL_CROSSBAR_CONF_PORTS_[!"@index"!]  [!"$crossbarPortCount"!]
/** @brief Configuration for the crossbar ports */
static CONST( Mcl_CrossbarSlaveHwIpsConfigType, MCL_CONST)Mcl_Crossbar_SlavePortConfig_[!"@index"!][MCL_CROSSBAR_CONF_PORTS_[!"@index"!]] =
[!ELSE!]
static CONST( Mcl_CrossbarSlaveHwIpsConfigType, MCL_CONST)Mcl_Crossbar_SlavePortConfig[!IF "var:defined('postBuildVariant')"!]_[!"$postBuildVariant"!][!ENDIF!][MCL_CROSSBAR_CONF_PORTS[!IF "var:defined('postBuildVariant')"!]_[!"$postBuildVariant"!][!ENDIF!]] =
[!ENDIF!]
{
[!VAR "comma" = "1"!][!//
[!FOR "varCounter" = "0" TO "$crossbarPortCount"!][!//
[!LOOP "MclCrossbarLogicalSlavePorts/*"!][!//
    [!IF "MclCrossbarLogicalSlavePortId = $varCounter"!][!//
        [!VAR "MclMaxMastersAllPlatforms" = "7"!]
        [!VAR "MclCrossbarHwPortNumber" = "node:value(node:ref(MclCrossbarHwSlavePortRef)/MclSlavePortNumber)"!][!//
        [!VAR "MclCrossbarInstanceNumber" = "substring-after(node:value((node:ref(MclCrossbarHwSlavePortRef))/../../MclCrossbarHwInstance),"AXBS_")"!][!//
        [!VAR "MclParkingCtrl" = "'AXBS_PCTL_PARK_FIELD'"!][!//
        [!IF "$MclCrossbarInstanceNumber = 0"!][!VAR "NumberOfMaster" = "count(ecu:list('Mcl.Crossbar.AXBS0.Masters'))"!][!//
        [!ELSE!][!VAR "NumberOfMaster" = "count(ecu:list('Mcl.Crossbar.AXBS1.Masters'))"!][!ENDIF!][!//
        [!IF "node:ref(MclCrossbarHwSlavePortRef)/MclCrossbarParkingControl = 'LastMaster'"!][!VAR "MclParkingCtrl" = "'AXBS_PCTL_LAST_MASTER'"!][!ENDIF!][!//
        [!IF "node:ref(MclCrossbarHwSlavePortRef)/MclCrossbarParkingControl = 'LowPowerPark'"!][!VAR "MclParkingCtrl" = "'AXBS_PCTL_LOW_POWER_PARK'"!][!ENDIF!][!//

        /** Logical port [!"$varCounter"!] */
        {
                 /**  Hardware port slave number */
                [!"$MclCrossbarHwPortNumber"!]U,
                 /**  Hardware crossbar instance */
                [!"$MclCrossbarInstanceNumber"!]U,
[!IF "$PRSIsReadOnly = 0"!] 
                 /**  Priority register configuration */  
                (
[!IF "$MclCrossbarInstanceNumber = 0"!][!// /**For AXBS0**/
[!VAR "Slash" = "1"!][!//
[!FOR "Index" = "0" TO "$MclMaxMastersAllPlatforms"!][!//
[!IF "node:containsValue(ecu:list('Mcl.Crossbar.AXBS0.Masters'),concat('Master',$Index)) = 'true'"!][!//
[!CR!]                        (AXBS_MASTER[!"$Index"!]_MASK32 & ((uint32)AXBS_PRIORITY_[!"node:value(concat(node:path(node:ref(MclCrossbarHwSlavePortRef)),concat("/MclCrossbarPrioMaster",string(num:i($Index)))))"!]_U32 << AXBS_MASTER[!"$Index"!]_SHIFT_U32))[!/*
                        */!][!IF "num:i($Slash) < $NumberOfMaster"!]|[!ENDIF!][!VAR "Slash" = "num:i($Slash) +1"!][!//
[!NOCODE!][!//
[!VAR "CurrentNodeValue" = "node:value(concat(node:path(node:ref(MclCrossbarHwSlavePortRef)),concat("/MclCrossbarPrioMaster",string(num:i($Index)))))"!]
[!FOR "Index1" = "$Index" TO "$MclMaxMastersAllPlatforms"!]
    [!IF "(node:containsValue(ecu:list('Mcl.Crossbar.AXBS0.Masters'),concat('Master',$Index1)) = 'true') and ($Index1 != $Index)"!]
        [!IF "$CurrentNodeValue = node:value(concat(node:path(node:ref(MclCrossbarHwSlavePortRef)),concat("/MclCrossbarPrioMaster",string(num:i($Index1)))))"!]
            [!ERROR!]
            Two or more available masters have both priorities which are equal is not allowed, please check [!"node:path(node:ref(MclCrossbarHwSlavePortRef))"!]/MclCrossbarPrioMaster[!"$Index"!]
            [!ENDERROR!]
        [!ENDIF!]
    [!ENDIF!]
[!ENDFOR!]
[!ENDNOCODE!][!//
[!ENDIF!][!//
[!ENDFOR!][!//
[!ELSE!][!//   /**For AXBS1**/
[!VAR "Slash" = "1"!][!//
[!FOR "Index" = "0" TO "$MclMaxMastersAllPlatforms"!][!//
[!IF "node:containsValue(ecu:list('Mcl.Crossbar.AXBS1.Masters'),concat('Master',$Index)) = 'true'"!][!//
[!CR!]                       (AXBS_MASTER[!"$Index"!]_MASK32 & ((uint32)AXBS_PRIORITY_[!"node:value(concat(node:path(node:ref(MclCrossbarHwSlavePortRef)),concat("/MclCrossbarPrioMaster",string(num:i($Index)))))"!]_U32 << AXBS_MASTER[!"$Index"!]_SHIFT_U32))[!/*
                        */!][!IF "num:i($Slash) < $NumberOfMaster"!]|[!ENDIF!][!VAR "Slash" = "num:i($Slash) +1"!][!//
[!NOCODE!][!//
[!VAR "CurrentNodeValue" = "node:value(concat(node:path(node:ref(MclCrossbarHwSlavePortRef)),concat("/MclCrossbarPrioMaster",string(num:i($Index)))))"!]
[!FOR "Index1" = "$Index" TO "$MclMaxMastersAllPlatforms"!]
    [!IF "(node:containsValue(ecu:list('Mcl.Crossbar.AXBS1.Masters'),concat('Master',$Index1)) = 'true') and ($Index1 != $Index)"!]
        [!IF "$CurrentNodeValue = node:value(concat(node:path(node:ref(MclCrossbarHwSlavePortRef)),concat("/MclCrossbarPrioMaster",string(num:i($Index1)))))"!]
            [!ERROR!]
            Two or more available masters have both priorities which are equal is not allowed, please check [!"node:path(node:ref(MclCrossbarHwSlavePortRef))"!]/MclCrossbarPrioMaster[!"$Index"!]
            [!ENDERROR!]
        [!ENDIF!]
    [!ENDIF!]
[!ENDFOR!]
[!ENDNOCODE!][!//
[!ENDIF!][!//
[!ENDFOR!][!//
[!ENDIF!]
                ),
[!ENDIF!][!//
                /** Control register configuration */
                (
                (AXBS_LK_BIT_MASK32 & ((uint32)([!IF "node:ref(MclCrossbarHwSlavePortRef)/MclCrossbarEnableLock"!]AXBS_LOCK_EN_U32[!ELSE!]AXBS_LOCK_DIS_U32[!ENDIF!]) << AXBS_LOCK_SHIFT_U32))[!/*
            */!][!IF "ecu:get('Mcl.Crossbar.HaltLowPrioritySupport') = '1'"!][!//
[!CR!]                |(AXBS_HLP_BIT_MASK32 & ((uint32)([!IF "node:ref(MclCrossbarHwSlavePortRef)/MclCrossbarHaltLowPrio"!]AXBS_HLP_LOWEST_U32[!ELSE!]AXBS_HLP_HIGHEST_U32[!ENDIF!]) << AXBS_HLP_SHIFT_U32))[!/*
            */!][!ENDIF!]
[!IF "$MclCrossbarInstanceNumber = 0"!][!// /**For AXBS0**/
[!FOR "Index" = "0" TO "$MclMaxMastersAllPlatforms"!][!//
[!IF "node:containsValue(ecu:list('Mcl.Crossbar.AXBS0.Masters'),concat('Master',$Index)) = 'true'"!][!//
[!CR!]                |(AXBS_HPE[!"$Index"!]_BIT_MASK32 & ((uint32)([!IF "node:value(concat(node:path(node:ref(MclCrossbarHwSlavePortRef)),concat("/MclCrossbarEnablePrioElevM",string(num:i($Index))))) = 'true'"!]AXBS_HPE_EN_U32[!ELSE!]AXBS_HPE_DIS_U32[!ENDIF!]) << AXBS_HPE[!"$Index"!]_SHIFT_U32))[!/*
*/!][!ENDIF!][!//
[!ENDFOR!][!//
[!ELSE!][!// /**For AXBS1**/
[!FOR "Index" = "0" TO "$MclMaxMastersAllPlatforms"!][!//
[!IF "node:containsValue(ecu:list('Mcl.Crossbar.AXBS1.Masters'),concat('Master',$Index)) = 'true'"!][!//
[!CR!]                 |(AXBS_HPE[!"$Index"!]_BIT_MASK32 & ((uint32)([!IF "node:value(concat(node:path(node:ref(MclCrossbarHwSlavePortRef)),concat("/MclCrossbarEnablePrioElevM",string(num:i($Index))))) = 'true'"!]AXBS_HPE_EN_U32[!ELSE!]AXBS_HPE_DIS_U32[!ENDIF!]) << AXBS_HPE[!"$Index"!]_SHIFT_U32))[!/*
*/!][!ENDIF!][!//
[!ENDFOR!][!//
[!ENDIF!][!//
[!CR!]               |(AXBS_ARB_BITS_MASK32 & ((uint32)([!IF "node:ref(MclCrossbarHwSlavePortRef)/MclCrossbarEnableFixedPrio"!]AXBS_ARB_FIXED_U32[!ELSE!]AXBS_ARB_ROUND_ROBIN_U32[!ENDIF!]) << AXBS_ARB_SHIFT_U32))   
                |(AXBS_PCTL_BITS_MASK32 & ((uint32)([!"$MclParkingCtrl"!]_U32) << AXBS_PCTL_SHIFT_U32))
                |(AXBS_PARK_BITS_MASK32 & ((uint32)(AXBS_MASTER_[!"substring-after(node:ref(MclCrossbarHwSlavePortRef)/MclCrossbarParkField ,'Master')"!]_U32)))        
                )

        [!/* */!]}[!IF "(num:i($comma))<(num:i($crossbarPortCount))"!],[!ENDIF!][!CR!][!VAR "comma"="$comma + 1"!][!//
    [!ENDIF!][!//
[!ENDLOOP!][!//
[!ENDFOR!]
[!/* */!]};
[!ENDMACRO!][!// AXBS Config Slave

[!/* *************************** TRGMUX Config ******************************
******************************************************************************/!]

[!/* *************************** LOGICAL MEMORY SECTION Config ******************************
******************************************************************************************/!]
[!MACRO "Mcl_LogicalMemorySection_Config","Type"!][!//
[!NOCODE!]
        [!IF "num:i(count(MclLogicalMemorySectionConfig/*))>0"!]
            [!VAR "LogicalMemorySection"= "num:i(count(MclLogicalMemorySectionConfig/*))-1"!]
[!CODE!]
[!VAR "firstindex" = "0"!]
[!VAR "secondindex" = "0"!]
[!FOR "firstindex" = "0" TO "$LogicalMemorySection -1"!]
    [!FOR "secondindex" = "$firstindex + 1" TO "$LogicalMemorySection"!]
    
    [!VAR "LogicalEndx" = "node:value(concat(concat('MclLogicalMemorySectionConfig/MclLogicalMemorySectionConfig_',$firstindex),'/LogicalAddressEnd'))"!]
    [!VAR "LogicalStartx" = "node:value(concat(concat('MclLogicalMemorySectionConfig/MclLogicalMemorySectionConfig_',$firstindex),'/LogicalAddressStart'))"!]
    [!VAR "LogicalEndy" = "node:value(concat(concat('MclLogicalMemorySectionConfig/MclLogicalMemorySectionConfig_',$secondindex),'/LogicalAddressEnd'))"!]
    [!VAR "LogicalStarty" = "node:value(concat(concat('MclLogicalMemorySectionConfig/MclLogicalMemorySectionConfig_',$secondindex),'/LogicalAddressStart'))"!]
    [!VAR "PhysicalEndx" = "node:value(concat(concat('MclLogicalMemorySectionConfig/MclLogicalMemorySectionConfig_',$firstindex),'/PhysicalAddressEnd'))"!]
    [!VAR "PhysicalStartx" = "node:value(concat(concat('MclLogicalMemorySectionConfig/MclLogicalMemorySectionConfig_',$firstindex),'/PhysicalAddressStart'))"!]
    [!VAR "PhysicalEndy" = "node:value(concat(concat('MclLogicalMemorySectionConfig/MclLogicalMemorySectionConfig_',$secondindex),'/PhysicalAddressEnd'))"!]
    [!VAR "PhysicalStarty" = "node:value(concat(concat('MclLogicalMemorySectionConfig/MclLogicalMemorySectionConfig_',$secondindex),'/PhysicalAddressStart'))"!]
    
        [!IF "$LogicalEndx > $LogicalStarty and $LogicalEndx <= $LogicalEndy  "!]
    [!ERROR!] [!//
       " logical address overlap between MclLogicalMemorySectionConfig_[!"$firstindex"!] and MclLogicalMemorySectionConfig_[!"$secondindex"!]  "[!//
    [!ENDERROR!][!//
        [!ELSEIF "$LogicalEndy > $LogicalStartx and $LogicalEndy <= $LogicalEndx  "!]
    [!ERROR!] [!//
       " logical address overlap between MclLogicalMemorySectionConfig_[!"$firstindex"!] and MclLogicalMemorySectionConfig_[!"$secondindex"!]  "[!//
    [!ENDERROR!][!//
        [!ELSE!]
        [!ENDIF!]
        [!IF "$PhysicalEndx > $PhysicalStarty and $PhysicalEndx <= $PhysicalEndy  "!]
    [!ERROR!] [!//
       " Physical address overlap between MclLogicalMemorySectionConfig_[!"$firstindex"!] and MclLogicalMemorySectionConfig_[!"$secondindex"!]  "[!//
    [!ENDERROR!][!//
        [!ELSEIF "$PhysicalEndy > $PhysicalStartx and $PhysicalEndy <= $PhysicalEndx  "!]
    [!ERROR!] [!//
       " Physical address overlap between MclLogicalMemorySectionConfig_[!"$firstindex"!] and MclLogicalMemorySectionConfig_[!"$secondindex"!]  "[!//
    [!ENDERROR!][!//
    [!ELSE!]
    [!ENDIF!]
    
[!ENDFOR!]
[!ENDFOR!]
/**
* @brief        Definition of Logical Memory sections within the configuration structure.
*
*/
[!IF "$Type = 'PC'"!]
static CONST(Mcl_LogicalMemorySectionConfigType, MCL_CONST) Mcl_LogicalMemorySection_Config[!"$Type"!][[!"num:i(count(MclLogicalMemorySectionConfig/*))"!]] =
[!ELSE!]
static CONST(Mcl_LogicalMemorySectionConfigType, MCL_CONST) Mcl_LogicalMemorySection_Config[!"$Type"!]_[!"@index"!][[!"num:i(count(MclLogicalMemorySectionConfig/*))"!]] =
[!ENDIF!]
{
[!ENDCODE!]
        [!LOOP "MclLogicalMemorySectionConfig/*"!]
            [!VAR "PCindex" = "@index"!]
[!CODE!]
    {
        /* Start Logical address */
        (uint32)[!"num:inttohex(LogicalAddressStart,8)"!]U,
        /* End Logical address */
        (uint32)[!"num:inttohex(LogicalAddressEnd,8)"!]U,
        /* Start Physical address */
        (uint32)[!"num:inttohex(PhysicalAddressStart,8)"!]U,
        /* End Physical address */
        (uint32)[!"num:inttohex(PhysicalAddressEnd,8)"!]U
    }[!IF "$PCindex < $LogicalMemorySection"!],[!ENDIF!] /* End of [!"@name"!]. */
[!ENDCODE!]
        [!ENDLOOP!][!//MclLogicalMemorySectionConfig/*
        [!CODE!]
};
[!ENDCODE!]
        [!ENDIF!]
[!ENDNOCODE!]
[!ENDMACRO!][!//

[!/* *************************** Flexio SECTION Config ******************************
******************************************************************************************/!]
[!MACRO "FlexioConfig","FlexioConfigType"!]
[!VAR "NumofChannelConfig" = "num:i(count(./FlexioConfig/FlexioReferenceConfiguration/*))"!][!//
[!IF "$FlexioConfigType = 'PC'"!][!//
static CONST( Mcl_FlexioConfigType, MCL_CONST) Flexio_Config_PC =
[!ELSEIF "$FlexioConfigType = 'PB'"!][!//
static CONST( Mcl_FlexioConfigType, MCL_CONST) Flexio_Config_[!"@index"!] =
[!ELSE!][!//
static CONST( Mcl_FlexioConfigType, MCL_CONST) Flexio_Config[!IF "var:defined('postBuildVariant')"!]_[!"$postBuildVariant"!][!ENDIF!] =
[!ENDIF!][!//
{
    ([!IF "./FlexioConfig/FlexioGeneral/DozenEnable = 'true'"!]FLEXIO_CTRL_DOZEN_EN_U32 |[!ELSE!]FLEXIO_CTRL_DOZEN_DIS_U32 |[!ENDIF!]
    [!IF "./FlexioConfig/FlexioGeneral/DBGE = 'true'"!]FLEXIO_CTRL_DBGE_EN_U32[!ELSE!]FLEXIO_CTRL_DBGE_DIS_U32[!ENDIF!]),
    [!"$NumofChannelConfig"!]U
};
[!ENDMACRO!]
[!/* *************************** Mcl export driver configuration ***************************
******************************************************************************/!]
[!MACRO "MclExportDriverConfiguration"!]
[!NOCODE!][!//
[!VAR "configName" = "as:name(./MclConfigSet/*)"!][!//
[!CODE!][!//
#define MCL_CONF_PB \
[!ENDCODE!][!//
[!IF "var:defined('postBuildVariant')"!][!//
    [!VAR "variantIndex"="0"!][!//
    [!VAR "variantNumber"="variant:size()"!][!//
    [!LOOP "variant:all()"!][!VAR "variantIndex"="$variantIndex + 1"!][!//
    [!//
        [!CODE!][!WS4!]extern CONST(Mcl_ConfigType, MCL_CONST) [!"$configName"!]_[!"."!];[!IF "$variantIndex < $variantNumber"!]\[!ENDIF!][!CR!][!ENDCODE!]
    [!ENDLOOP!][!//
[!ELSE!][!//
    [!CODE!][!WS4!]extern CONST(Mcl_ConfigType, MCL_CONST) [!"$configName"!];[!CR!][!ENDCODE!]
[!ENDIF!][!//
[!ENDNOCODE!][!//
[!ENDMACRO!]
[!ENDNOCODE!]
