[!AUTOSPACING!]
[!CODE!]
/**
*   @file    Fee_Cfg.c
*   @implements Fee_Cfg.c_Artifact   
*   @version 1.0.0
*
*   @brief   AUTOSAR Fee - AUTOSAR Module Flash EEPROM Emulation Driver.
*   @details Definitions of all Pre-compile configuration structures.
*
*   @addtogroup FEE
*   @{
*/
/*==================================================================================================
*   Project              : AUTOSAR 4.3 MCAL
*   Platform             : PA
*   Peripheral           : none
*   Dependencies         : Fls
*
*   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 [global]
* Violates MISRA 2012 Required Rule 5.1, External identifiers shall be distinct.
* Identifiers (internal and external) shall not rely on the significance of more than 31 characters. 
* 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 namespace shall be distinct.
* This violation is due to the requirement that requests to have a file version check.
*
* @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 Fee_Cfg_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 violation is not fixed 
* since the inclusion of Fee_MemMap.h is as per AUTOSAR requirement [SWS_MemMap_00003].
*
* @section Fee_Cfg_c_REF_2
* Violates MISRA 2012 Advisory Rule 20.1, #include directives should only be preceded by preprocessor directives or comments.
* Fee_MemMap.h is included after each section define in order to set the current memory section as defined by AUTOSAR.
*/

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

/*==================================================================================================
*                              SOURCE FILE VERSION INFORMATION
==================================================================================================*/
#define FEE_VENDOR_ID_CFG_C                      43
#define FEE_AR_RELEASE_MAJOR_VERSION_CFG_C       4
#define FEE_AR_RELEASE_MINOR_VERSION_CFG_C       3
#define FEE_AR_RELEASE_REVISION_VERSION_CFG_C    1
#define FEE_SW_MAJOR_VERSION_CFG_C               1
#define FEE_SW_MINOR_VERSION_CFG_C               0
#define FEE_SW_PATCH_VERSION_CFG_C               0

/*==================================================================================================
                                      FILE VERSION CHECKS
==================================================================================================*/
/* Check if source file and Fee header file are of the same vendor */
#if (FEE_VENDOR_ID_CFG_C != FEE_VENDOR_ID)
    #error "Fee_Cfg.c and Fee.h have different vendor ids"
#endif
/* Check if current file and Fee header file are of the same Autosar version */
#if ((FEE_AR_RELEASE_MAJOR_VERSION_CFG_C    != FEE_AR_RELEASE_MAJOR_VERSION) || \
     (FEE_AR_RELEASE_MINOR_VERSION_CFG_C    != FEE_AR_RELEASE_MINOR_VERSION) || \
     (FEE_AR_RELEASE_REVISION_VERSION_CFG_C != FEE_AR_RELEASE_REVISION_VERSION)\
    )
    #error "AutoSar Version Numbers of Fee_Cfg.c and Fee.h are different"
#endif
/* Check if current file and Fee header file are of the same Software version */
#if ((FEE_SW_MAJOR_VERSION_CFG_C != FEE_SW_MAJOR_VERSION) || \
     (FEE_SW_MINOR_VERSION_CFG_C != FEE_SW_MINOR_VERSION) || \
     (FEE_SW_PATCH_VERSION_CFG_C != FEE_SW_PATCH_VERSION)\
    )
    #error "Software Version Numbers of Fee_Cfg.c and Fee.h are different"
#endif

[!INCLUDE "Fee_VersionCheck.m"!][!//


#define FEE_START_SEC_CONST_UNSPECIFIED
/* @violates @ref Fee_Cfg_c_REF_1 MISRA 2012 Advisory 4.10 */
/* @violates @ref Fee_Cfg_c_REF_2 MISRA 2012 Advisory 20.1*/
#include "Fee_MemMap.h"


/*==================================================================================================
                                       GLOBAL VARIABLES
==================================================================================================*/
[!VAR "FeeVPS" = "num:i(FeeGeneral/FeeVirtualPageSize)"!]
[!VAR "FeeBlkOverhead" = "num:i(ceiling(12 div $FeeVPS + 2) * $FeeVPS)"!]
[!VAR "FeeClsOverhead" = "num:i(ceiling(16 div $FeeVPS + 2) * $FeeVPS)"!]

[!LOOP "FeeClusterGroup/*"!]
/* Configuration of cluster group [!"node:name(.)"!] */
static CONST(Fee_ClusterType, FEE_CONST) Fee_[!"node:name(.)"!][[!"num:i(count(FeeCluster/*))"!]] =
{
    [!VAR "FeeLoopIt" = "count(FeeCluster/*)"!]
    [!LOOP "FeeCluster/*"!]
        [!VAR "FeeLoopIt" = "$FeeLoopIt - 1"!]
        [!VAR "FeeClusterSize" = "0"!]
        [!LOOP "FeeSector/*"!]
            [!VAR "FeeClusterSize" = "$FeeClusterSize + num:i(node:ref(./FeeSectorRef)/FlsSectorSize) * num:i(node:ref(./FeeSectorRef)/FlsNumberOfSectors)"!]
        [!ENDLOOP!]
    /* [!"node:name(.)"!] */
    {
        [!"num:i(node:ref(FeeSector/*[FeeSectorIndex = 0]/FeeSectorRef)/FlsSectorStartaddress)"!]U, /* Start address */
        [!"num:i($FeeClusterSize)"!]U /* Size */
    }[!IF "$FeeLoopIt != 0"!],[!ENDIF!][!//
    [!ENDLOOP!]
};
[!ENDLOOP!]


/* Configuration of cluster group set */
CONST(Fee_ClusterGroupType, FEE_CONST) Fee_ClrGrps[FEE_NUMBER_OF_CLUSTER_GROUPS] =
{
[!VAR "FeeLoopIt" = "count(FeeClusterGroup/*)"!]
[!LOOP "FeeClusterGroup/*"!]
    [!VAR "FeeLoopIt" = "$FeeLoopIt - 1"!]
    [!// Compute the size of the reserved area (immediate block headers and aligned data)
    [!VAR "FeeReservedSize" = "0"!][!//
    [!LOOP "../../FeeBlockConfiguration/*[node:name(node:ref(FeeClusterGroupRef)) = node:current()/@name]"!]
        [!IF "./FeeImmediateData"!]
            [!VAR "FeeReservedSize" = "$FeeReservedSize + $FeeBlkOverhead + [!//
                             num:i( ceiling( ./FeeBlockSize div $FeeVPS ) * $FeeVPS )"!]
        [!ENDIF!]
    [!ENDLOOP!]     
    /* [!"node:name(.)"!] */
    {
        Fee_[!"node:name(.)"!], /* Cluster set */
        [!"num:i(count(./FeeCluster/*))"!]U, /* Number of clusters */
        [!"num:i( $FeeReservedSize )"!]U /* Size of the reserved area */        
    }[!IF "$FeeLoopIt != 0"!],[!ENDIF!][!//

[!ENDLOOP!]
};

/* Configuration of Fee blocks */
CONST(Fee_BlockConfigType, FEE_CONST) Fee_BlockConfig[FEE_CRT_CFG_NR_OF_BLOCKS] =
{
[!VAR "FeeLoopIt" = "count(FeeBlockConfiguration/*)"!]
[!LOOP "node:order(FeeBlockConfiguration/*,'node:value(./FeeBlockNumber)')"!]
    [!VAR "FeeLoopIt" = "$FeeLoopIt - 1"!]
    /* [!"node:name(.)"!] */
    {
        FeeConf_FeeBlockConfiguration_[!"node:name(.)"!], /* FeeBlockNumber symbol */
        [!"./FeeBlockSize"!]U, /* FeeBlockSize */
        [!"node:ref(./FeeClusterGroupRef)/@index"!]U, /* FeeClusterGroup */
        (boolean) [!IF "./FeeImmediateData"!]TRUE [!ELSE!]FALSE[!ENDIF!],[!//
   /* FeeImmediateData */
#if (FEE_SWAP_FOREIGN_BLOCKS_ENABLED == STD_ON) 
        FEE_PROJECT_[!"node:value(./FeeBlockAssignment)"!] /* Fee Block Assignment to a project */
#else
        FEE_PROJECT_RESERVED
#endif
    }[!IF "$FeeLoopIt != 0"!],[!ENDIF!][!//

[!ENDLOOP!]
};
[!ENDCODE!]

#define FEE_STOP_SEC_CONST_UNSPECIFIED
/* @violates @ref Fee_Cfg_c_REF_1 MISRA 2012 Advisory 4.10 */
/* @violates @ref Fee_Cfg_c_REF_2 MISRA 2012 Advisory 20.1*/
#include "Fee_MemMap.h"

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