/**
*  @file    Mcu_Cfg.h
*  @implements Mcu_Cfg.h_Artifact
*  @version 1.0.0
*
*   @brief   AUTOSAR Mcu - Configuration file for the driver.
*   @details Precompile parameters and extern configuration.
*
*  @addtogroup MCU
*  @{
*/
/*==================================================================================================
*   Project              : AUTOSAR 4.3 MCAL
*   Platform             : PA
*   Peripheral           : MC
*   Dependencies         : none
*
*   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.
==================================================================================================*/
/*==================================================================================================
==================================================================================================*/


#ifndef MCU_CFG_H
#define MCU_CFG_H

#ifdef __cplusplus
extern "C"{
#endif


/**
* @page misra_violations MISRA-C:2012 violations
*
* @section Mcu_CFG_H_REF_1
* Violates MISRA 2012 Advisory Directive 4.9, A function should be used in preference to a function-like macro
* where they are interchangeable. This violation is done to reduce code complexity by avoiding pointers to
* external functions (callbacks) defined by the user.
*
* @section Mcu_CFG_H_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 Mcu_CFG_H_REF_3
* 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 Mcu_MemMap.h is as
* per AUTOSAR requirement [SWS_MemMap_00003].
*
* @section Mcu_CFG_H_REF_4
* Violates MISRA 2012 Advisory Rule 2.5, A project should not contain unused macro declarations.
*
* @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.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.
* This rule does not apply if either identifier is a macro identifier, because this case is covered
* by Rule 5.4 and Rule 5.5. 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 identifier clash is between macro identifiers. Therefore, this rule is incorrectly reported by the tool.
* The used compilers use more than 31 chars for identifiers.
*
*/

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

/*==================================================================================================
                               SOURCE FILE VERSION INFORMATION
==================================================================================================*/
#define MCU_CFG_VENDOR_ID                        43
#define MCU_CFG_AR_RELEASE_MAJOR_VERSION         4
#define MCU_CFG_AR_RELEASE_MINOR_VERSION         3
#define MCU_CFG_AR_RELEASE_REVISION_VERSION      1
#define MCU_CFG_SW_MAJOR_VERSION                 1
#define MCU_CFG_SW_MINOR_VERSION                 0
#define MCU_CFG_SW_PATCH_VERSION                 0
#define MCU_MODULE_ID                            101

/*==================================================================================================
                                      FILE VERSION CHECKS
==================================================================================================*/
/* Check if current file and Mcal header file are of the same Autosar version */
#ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
    #if ((MCU_CFG_AR_RELEASE_MAJOR_VERSION != MCAL_AR_RELEASE_MAJOR_VERSION) || \
         (MCU_CFG_AR_RELEASE_MINOR_VERSION != MCAL_AR_RELEASE_MINOR_VERSION) \
        )
        #error "AutoSar Version Numbers of Mcu_Cfg.h and Mcal.h are different"
    #endif
#endif
[!INCLUDE "Mcu_VersionCheck_Inc.m"!][!//
/*==================================================================================================
                                           DEFINES AND MACROS
==================================================================================================*/
#define MCU_INSTANCE_ID                 ((uint8)0x0U)

/**
@{
* @brief            Service Ids for MCU APIs.
*/
#define MCU_INIT_ID                     ((uint8)0x00U)
#define MCU_INITRAMSECTION_ID           ((uint8)0x01U)
#define MCU_INITCLOCK_ID                ((uint8)0x02U)
#define MCU_DISTRIBUTEPLLCLOCK_ID       ((uint8)0x03U)
#define MCU_GETPLLSTATUS_ID             ((uint8)0x04U)
#define MCU_GETRESETREASON_ID           ((uint8)0x05U)
#define MCU_GETRESETRAWVALUE_ID         ((uint8)0x06U)
#define MCU_PERFORMRESET_ID             ((uint8)0x07U)
#define MCU_SETMODE_ID                  ((uint8)0x08U)
#define MCU_GETVERSIONINFO_ID           ((uint8)0x09U)
#define MCU_GETRAMSTATE_ID              ((uint8)0x0AU)

#define MCU_GETPOWERDOMAIN_ID           ((uint8)0x0BU)
#define MCU_GETPERIPHERALSTATE_ID       ((uint8)0x0CU)
#define MCU_GETSYSTEMSTATE_ID           ((uint8)0x0DU)
#define MCU_GETPOWERMODESTATE_ID        ((uint8)0x0EU)
#define MCU_GETMEMCONFIG_ID             ((uint8)0x13U)
#define MCU_GETMIDRSTRUCTURE_ID         ((uint8)0x14U)
#define MCU_SSCMGETSTATUS_ID            ((uint8)0x15U)
#define MCU_EMIOSCONFIGUREGPREN_ID      ((uint8)0x16U)
#define MCU_DISABLECMU_ID               ((uint8)0x17U)
/**@}*/

/**
@{
* @brief            Default error values are of type uint8.
*                   The following errors and exceptions shall be detectable by the MCU module depending on its
*                   build version (default/production mode).
*
*/
#define MCU_E_PARAM_CONFIG              ((uint8)0x0AU)
#define MCU_E_PARAM_CLOCK               ((uint8)0x0BU)
#define MCU_E_PARAM_MODE                ((uint8)0x0CU)
#define MCU_E_PARAM_RAMSECTION          ((uint8)0x0DU)
#define MCU_E_PLL_NOT_LOCKED            ((uint8)0x0EU)
#define MCU_E_UNINIT                    ((uint8)0x0FU)
#define MCU_E_PARAM_POINTER             ((uint8)0x10U)
#define MCU_E_INIT_FAILED               ((uint8)0x11U)
#define MCU_E_ALREADY_INITIALIZED      ((uint8)0x13U)
#define MCU_E_CMU_INDEX_OUT_OF_RANGE    ((uint8)0x22U)
/**@}*/

/**
@{
* @brief            Error ISR values are of type uint8.
*                   The following error codes are reported by the error ISR.
*/
#define MCU_E_ISR_CLOCK_FAILURE                 ((uint8)0x01U)
#define MCU_E_ISR_PLL_LOCK_FAILURE              ((uint8)0x02U)
#define MCU_E_ISR_VOLTAGE_ERROR                 ((uint8)0x06U)
#define MCU_E_ISR_TEMPERATURE_MONITOR_ERROR     ((uint8)0x07U)
/**@}*/


/**
* @brief            Pre-processor switch for enabling the development error detection and reporting to the DET.
*                   The detection of development errors is configurable (ON / OFF) at pre-compile time.
*/
#define MCU_DEV_ERROR_DETECT   [!IF "McuGeneralConfiguration/McuDevErrorDetect = 'true'"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]


/**
* @brief            Pre-processor switch to enable/disable the API to read out the modules version information.
*/
#define MCU_VERSION_INFO_API   [!IF "McuGeneralConfiguration/McuVersionInfoApi = 'true'"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]


/**
* @brief            Pre-processor switch to enable/disable the API Mcu_GetRamState.
*/
#define MCU_GET_RAM_STATE_API   [!IF "McuGeneralConfiguration/McuGetRamStateApi = 'true'"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]


/**
* @brief            If this parameter is set to FALSE, the clock initialization has to be disabled from the MCU driver.
*/
#define MCU_INIT_CLOCK   [!IF "McuGeneralConfiguration/McuInitClock = 'true'"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]


/**
* @brief            This parameter shall be set True, if the H/W does not have a PLL or the PLL circuitry is enabled after the power on without S/W intervention.
*/
#define MCU_NO_PLL   [!IF "McuGeneralConfiguration/McuNoPll = 'true'"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]

/**
* @brief            Support for Low Power mode.
*                   If this parameter has been configured to 'TRUE', the function 'Mcu_SetMode()' shall not be impacted and behave as specified.
* @requirements     PR-MCAL-3184
*/
#define MCU_ENTER_LOW_POWER_MODE   [!IF "McuGeneralConfiguration/McuEnterLowPowerMode = 'true'"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]

/**
* @brief            The function Mcu_PerformReset is only available if the runtime parameter McuPerformResetApi is set to TRUE.
*/
#define MCU_PERFORM_RESET_API   [!IF "McuGeneralConfiguration/McuPerformResetApi = 'true'"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]

/**
* @brief            If this parameter is set to TRUE, the SSCM initialization has to be disabled from the MCU driver.
*/
#define MCU_DISABLE_SSCM_INIT   [!IF "McuGeneralConfiguration/McuDisableSscmInit = 'true'"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]

/**
* @brief            If this parameter is set to TRUE, the Reset initialization has to be disabled from the MCU driver.
*/
#define MCU_DISABLE_RESET_INIT   [!IF "McuGeneralConfiguration/McuDisableResetInit = 'true'"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]

/**
* @brief            If this parameter is set to TRUE, the Power initialization has to be disabled from the MCU driver.
*/
#define MCU_DISABLE_PMC_INIT   [!IF "McuGeneralConfiguration/McuDisablePmcInit = 'true'"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]

/**
* @brief            Timeout representing the number of loops for preventing to lock inside am infinite while/for.
*/
#define MCU_TIMEOUT_LOOPS   ((uint32)[!"McuGeneralConfiguration/McuTimeout"!]U)

/**
* @brief            The user callout reset is/isn't available (STD_ON/STD_OFF) - called by MCU right before Mcu_PerformReset().
*/
#define MCU_RESET_CALLOUT_USED   [!IF "node:fallback(McuGeneralConfiguration/McuPerformResetApi, 'true') = 'true'"!][!IF "node:fallback(McuGeneralConfiguration/McuCalloutBeforePerformReset, 'true') = 'true'"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!][!ELSE!](STD_OFF)[!ENDIF!]


[!IF "node:fallback(McuGeneralConfiguration/McuPerformResetApi, 'true') = 'true'"!][!IF "node:fallback(McuGeneralConfiguration/McuCalloutBeforePerformReset, 'true') = 'true'"!]
#if (MCU_RESET_CALLOUT_USED == STD_ON)
/**
* @brief            The callout reset procedure configured by the user.
*/
#define MCU_RESET_CALLOUT   ([!"normalize-space(McuGeneralConfiguration/McuPerformResetCallout)"!])
#endif /* (MCU_RESET_CALLOUT_USED == STD_ON) */
[!ENDIF!][!ENDIF!]

[!IF "node:exists(McuGeneralConfiguration/McuCmuNotification)"!]
/**
* @brief            The callout configured by the user for CMU notifications.
*/
/** @violates @ref Mcu_CFG_H_REF_1 A function should be used in preference to a function-like macro where they are interchangeable. */
#define MCU_CMU_FCCU_NOTIFICATION(u8IndexCmu) ([!"normalize-space(McuGeneralConfiguration/McuCmuNotification)"!](u8IndexCmu))
[!ENDIF!]

[!IF "node:exists(McuGeneralConfiguration/McuErrorIsrNotification)"!]
/**
* @brief            The callout configured by the user for CMU notifications.
*/
/** @violates @ref Mcu_CFG_H_REF_1 A function should be used in preference to a function-like macro where they are interchangeable. */
#define MCU_ERROR_ISR_NOTIFICATION(u8ErrorCode) ([!"normalize-space(McuGeneralConfiguration/McuErrorIsrNotification)"!](u8ErrorCode))
[!ENDIF!]

/**
* @brief            If this parameter is set to STD_ON, the Mcu_PRAMC_SetRamWS function will not be called from Mcu_IPW.c.
*                   If this parameter is set to STD_OFF, the PRAMC will be configured according to the settings configured in the plugin.
*/
#define MCU_DISABLE_RAM_WS_CONFIG       [!IF "ecu:get('MCU.PRAMC.AVAILABLE')='true'"!][!IF "McuGeneralConfiguration/McuDisableRamWaitStatesConfig = 'true'"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!][!ELSE!](STD_ON)[!ENDIF!]

/**
* @brief            If this parameter is set to STD_ON, the Mcu_FLASH_Init and Mcu_FLASH_SetWS functions will not be called from Mcu_IPW.c.
*                   If this parameter is set to STD_OFF, the FLASH will be configured according to the settings configured in the plugin.
*/
#define MCU_DISABLE_FLASH_CONFIG        [!IF "ecu:get('MCU.PFLASH.AVAILABLE')='true'"!][!IF "McuGeneralConfiguration/McuDisableFlashConfigFromRam = 'true'"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!][!ELSE!](STD_ON)[!ENDIF!]

[!IF "node:exists(McuGeneralConfiguration/McuPrepareMemoryConfig)"!]
/**
* @brief            The callout configured by the user for preparing flash and ram controllers configuration.
*/
/** @violates @ref Mcu_CFG_H_REF_1 A function should be used in preference to a function-like macro where they are interchangeable. */
#define MCU_PREPARE_MEMORY_CONFIG(configStage) ([!"normalize-space(McuGeneralConfiguration/McuPrepareMemoryConfig)"!](configStage))
[!ENDIF!]

/**
* @brief            ISR Mcu_VoltageError_ISR is/isn't available (STD_ON/STD_OFF)
*/
#define MCU_VOLTAGE_ERROR_ISR_USED   [!IF "count(McuModuleConfiguration/McuInterruptEvents/McuVoltageErrorEvent[. = 'true']) >= 1"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]
/**
* @brief            ISR Mcu_VoltageError_ISR is/isn't available (STD_ON/STD_OFF)
*/
#define MCU_TEMPERATURE_ERROR_ISR_USED   [!IF "count(McuModuleConfiguration/McuInterruptEvents/McuTemperatureErrorEvent[. = 'true']) >= 1"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]

/**
* @brief            ISR Mcu_CmuClockFail_ISR is/isn't available
*/
#define MCU_CMU_ERROR_ISR_USED                  [!IF "McuGeneralConfiguration/McuCmuErrorIsrUsed = 'true'"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]

/**
* @brief            Enable the usage of Non-Autosar API Mcu_GetPeripheral_State() for getting infos about peripheral state from MC_ME module.
*/
#define MCU_GET_PERIPH_STATE_API   (STD_OFF)

/**
* @brief            Enable the usage of Non-Autosar API Mcu_GetSystem_State() for getting infos system platform configuration.
*/
#define MCU_GET_SYSTEM_STATE_API   (STD_OFF)

/**
* @brief            Enable the usage of Non-Autosar API Mcu_GetPowerMode_State() for getting infos system platform configuration.
*/
#define MCU_POWERMODE_STATE_API   (STD_OFF)

/**
* @brief            Enable the usage of Non-Autosar API Mcu_GetPowerDomain_Status. Get PMU state: operable or not.
*/
#define MCU_GET_POWER_DOMAIN_API   (STD_OFF)

/**
* @brief            ISR Mcu_PllDigPll0_LossOfLock_ISR is/isn't available (STD_ON/STD_OFF)
*/
#define MCU_PLLDIG_PLL0_LOL_ISR_USED [!IF "count(McuModuleConfiguration/McuClockSettingConfig/*/McuPll_0/McuPll0_Parameter/McuLossOfLockInt[. = 'true']) >= 1"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]

/**
* @brief            ISR Mcu_PllDigPll1_LossOfLock_ISR is/isn't available (STD_ON/STD_OFF)
*/
#define MCU_PLLDIG_PLL1_LOL_ISR_USED [!IF "count(McuModuleConfiguration/McuClockSettingConfig/*/McuPll_1/McuPll1_Parameter/McuLossOfLockInt[. = 'true']) >= 1"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]

/**
* @brief            Enable the usage of Non-Autosar API Mcu_SscmGetMemConfig(). Get SSCM_MEMCONFIG.
*/
#define MCU_GET_MEM_CONFIG_API   (STD_OFF)

/**
* @brief            Enable the usage of Non-Autosar API Mcu_SscmGetStatus(). Get SSCM_STATUS.
*/
#define MCU_SSCM_GET_STATUS_API   [!IF "McuDebugConfiguration/McuSscmGetStatusApi = 'true'"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]

/**
* @brief            Enable the usage of Non-Autosar API Mcu_SscmGetUops(). Get SSCM_UOPS.
*/
#define MCU_SSCM_GET_UOPS_API     (STD_OFF)

/**
* @brief            Enable the usage of Non-Autosar API  Mcu_GetMidrStructure(). Returns .
*/
#define MCU_GET_MIDR_API    [!IF "McuDebugConfiguration/McuGetMidrStructureApi = 'true'"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]

/**
* @brief            Enable the usage of Non-Autosar API  Mcu_EmiosConfigureGpren(). Returns.
*/
#define MCU_EMIOS_CONFIGURE_GPREN_API    [!IF "McuDebugConfiguration/McuEmiosConfigureGprenApi = 'true'"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]

/**
* @brief            Enable the usage of Non-Autosar API  Mcu_Disable_CMU().
*/
#define MCU_DISABLE_CMU_API    [!IF "McuDebugConfiguration/McuDisableCmuApi = 'true'"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]

/**
* @brief            Enable/Disable the API for reporting the Dem Error.
*/
#define MCU_DISABLE_DEM_REPORT_ERROR_STATUS     [!IF "(McuDebugConfiguration/McuDisableDemReportErrorStatus='true') or (num:i(count(McuModuleConfiguration/McuDemEventParameterRefs[node:exists(.)]))=0)"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]

/**
* @brief           This define controls the availability of the Mcu_MC_ME_FastModeConfig function
*/
#define MCU_FAST_MODE_CONFIG   (STD_OFF)

/**
* @brief           This define controls the availability of the Low Power Subsystem
*/
#define MCU_LPU_SUPPORT        (STD_OFF)

/**
* @brief           This define SSCM_ERROR to avoid compiler warning
*/
#define MCU_SSCM_ERROR_PRESENT (STD_ON)

/**
* @brief            Maximum number of MCU Clock configurations.
*/[!NOCODE!]
[!VAR "MaxNoOfClkCfgs" = "num:i(count(McuModuleConfiguration/McuClockSettingConfig/*))"!]
[!ENDNOCODE!]
#define MCU_MAX_CLKCONFIGS   ((uint32)[!"num:i($MaxNoOfClkCfgs)"!]U)


/**
* @brief            Maximum number of MCU Mode configurations.
*/[!NOCODE!]
[!VAR "MaxNoOfModeCfgs" = "num:i(count(McuModuleConfiguration/McuModeSettingConf/*))"!]
[!ENDNOCODE!]
#define MCU_MAX_MODECONFIGS   ((uint32)[!"num:i($MaxNoOfModeCfgs)"!]U)


/**
* @brief            Maximum number of MCU Ram configurations.
*/[!NOCODE!]
[!VAR "MaxNoOfRamCfgs" = "num:i(McuModuleConfiguration/McuRamSectors)"!]
[!ENDNOCODE!]
#define MCU_MAX_RAMCONFIGS   ((uint32)[!"num:i($MaxNoOfRamCfgs)"!]U)
[!NOCODE!]
    [!IF "$MaxNoOfRamCfgs = 0"!]
    [!CODE!]#define MCU_MAX_NORAMCONFIGS[!ENDCODE!]
    [!ENDIF!]
[!ENDNOCODE!]

[!NOCODE!]
[!CODE!]
/**
* @brief          Precompile Support On.
* @details        VARIANT-PRE-COMPILE: Only parameters with "Pre-compile time"
*                 configuration are allowed in this variant.
*
* @api
*/
#define MCU_PRECOMPILE_SUPPORT [!IF "(IMPLEMENTATION_CONFIG_VARIANT = 'VariantPreCompile') and (variant:size() <= 1)"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]
[!ENDCODE!]
[!ENDNOCODE!]


[!MACRO "McuExportDriverConfiguration"!]
[!NOCODE!][!//
[!VAR "configName" = "as:name(McuModuleConfiguration)"!][!//
[!CODE!][!//
/**
* @brief            Pre-Compile structure from Mcu_Cfg.c file.
*/
#define MCU_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(Mcu_ConfigType, MCU_CONST) [!"$configName"!]_[!"."!];[!IF "$variantIndex < $variantNumber"!]\[!ENDIF!][!CR!][!ENDCODE!]
    [!ENDLOOP!][!//
[!ELSE!][!//
    [!CODE!][!WS4!]extern CONST(Mcu_ConfigType, MCU_CONST) [!"$configName"!];[!CR!][!ENDCODE!]
[!ENDIF!][!//
[!ENDNOCODE!][!//
[!ENDMACRO!]

[!IF "((IMPLEMENTATION_CONFIG_VARIANT != 'VariantPostBuild') and (variant:size()>1)) or (IMPLEMENTATION_CONFIG_VARIANT = 'VariantPostBuild')"!]
    [!CALL "McuExportDriverConfiguration"!]
[!ENDIF!]

[!CODE!]
/**
* @brief            Number of available CMU units.
*/
#define MCU_CMU_UNITS                           ((uint8)[!"num:i(count(ecu:list('MCU.CMU.List')))"!]U)
[!ENDCODE!]

[!CODE!]
/**
* @brief            Number of total available CMU units.
*/
/* @violates @ref Mcu_CFG_H_REF_4 This macro is used to export number of total available CMU. */
#define MCU_CMU_TOTAL_UNITS                     ((uint8)[!"num:i(count(ecu:list('MCU.CMU.List')))"!]U)
[!ENDCODE!]

[!CODE!]
/**
* @brief            CMU_x_CSR[RCDIV] field needs to be updated independent of CMU_x_CSR[CME].
*/
#define MCU_CMU_RCDIV_INDEPEND   [!IF "ecu:get('MCU.CMU.RCDIV.Independent')='true'"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]
[!ENDCODE!]

[!CODE!]
/**
 * @brief           The eMIOS is configured or not.
 */
#define MCU_EMIOS_SUPPORT       [!IF "McuEMIOSConfiguration/McuEMIOSControl"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]
/**
* @brief            Number of available eMIOS units.
*/

#define MCU_EMIOS_NB_MODULES    [!IF "ecu:has('MCU.eMIOS.List')"!]((uint8)[!"num:i(count(ecu:list('MCU.eMIOS.List')))"!]U)[!ELSE!]((uint8)0U)[!ENDIF!]
[!ENDCODE!]


[!CODE!]
/**
* @brief            max number of prog. clock switch regs.
*/
#define MCU_NUMBER_OF_PCS_REGS              ((uint8)[!"ecu:get('MCU.NumberOfPcsRegs')"!]U)
[!ENDCODE!]

#define MCU_IRC_UNDER_MCU_CONTROL               (STD_OFF)
/* This define Enable/Disable the PLL0 clock under Mcu control */
#define MCU_PLL0_UNDER_MCU_CONTROL              [!IF "count(McuModuleConfiguration/McuClockSettingConfig/*/McuPll_0/McuPllUnderMcuControl[. = 'true']) >= 1"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]
/* This define Enable/Disable the PLL1 clock under Mcu control */
#define MCU_PLL1_UNDER_MCU_CONTROL              [!IF "count(McuModuleConfiguration/McuClockSettingConfig/*/McuPll_1/McuPllUnderMcuControl[. = 'true']) >= 1"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]

#define MCU_CMU_CLEAR_CLOCK_IRQ_FLAG            (STD_OFF)
#define MCU_RGM_CLEAR_CLOCK_IRQ_FLAG            (STD_OFF)

/**
* @brief        This is defined only on the platforms that have CMU_ISR[FLCI] bit present
*/
#define MCU_CMU_FLCI_BIT_PRESENT                (STD_ON)


/**
* @brief            Support for User mode.
*                   If this parameter has been configured to 'TRUE' the Mcu driver can be executed from both supervisor and user mode.
*/
#define MCU_ENABLE_USER_MODE_SUPPORT  [!IF "McuGeneralConfiguration/McuEnableUserModeSupport = 'true'"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]

/** Check the driver user mode is enabled only when the MCAL_ENABLE_USER_MODE_SUPPORT is enabled */
#ifndef MCAL_ENABLE_USER_MODE_SUPPORT
  #if (STD_ON == MCU_ENABLE_USER_MODE_SUPPORT)
    #error MCAL_ENABLE_USER_MODE_SUPPORT is not enabled. For running Mcu in user mode the MCAL_ENABLE_USER_MODE_SUPPORT needs to be defined.
  #endif /* (STD_ON == MCU_ENABLE_USER_MODE_SUPPORT) */
#endif /* ifndef MCAL_ENABLE_USER_MODE_SUPPORT */

/**
* @brief  The function Mcu_GetResetRawValue shall return an implementation specific value which does
*         not correspond to a valid value of the reset status register and is not equal to 0 if this
*         function is called prior to calling of the function Mcu_Init, and if supported by the
*         hardware.
*
*/
#define MCU_RAW_RESET_DEFAULT      ((uint32)0xFFFFFFFFUL)
/*==================================================================================================
                                 STRUCTURES AND OTHER TYPEDEFS
==================================================================================================*/

/**
* @brief            The Mcu_ModeType specifies the identification (ID) for a MCU mode, configured via configuration structure.
* @details          The type shall be uint8, uint16 or uint32.
*
* @implements     Mcu_ModeType_typedef
*
*/
typedef uint32 Mcu_ModeType;


/**
* @brief            The Mcu_RamSectionType specifies the identification (ID) for a RAM section, configured via the configuration structure.
*                   The type shall be uint8, uint16 or uint32, based on best performance.
* @implements Mcu_RamSectionType_typedef
*/
typedef uint32 Mcu_RamSectionType;

/**
* @brief            The Mcu_RamIndexType specifies the variable for indexing RAM sections.
*                   The type shall be uint8, uint16 or uint32, based on best performance.
*
*/
typedef uint32 Mcu_RamIndexType;

/**
* @brief            The Mcu_RamSizeType specifies the RAM section size.
*                   The type shall be uint8, uint16 or uint32, based on best performance.
*
*/
typedef uint32 Mcu_RamSizeType;

/**
* @brief            The Mcu_RamWriteSizeType specifies the RAM section write size.
*                   The type shall be uint8, uint16 or uint32, based on best performance.
*
*/
typedef uint32 Mcu_RamWriteSizeType;


#if (MCU_INIT_CLOCK == STD_ON)
/**
* @brief          Defines the identification (ID) for clock setting configured via the configuration structure.
* @details        The type shall be uint8, uint16 or uint32, depending on uC platform.
*
* @implements Mcu_ClockType_typedef
*/
typedef uint32 Mcu_ClockType;
#endif /* (MCU_INIT_CLOCK == STD_ON) */


/**
* @brief            Definition of a RAM section within the configuration structure.
*                   The definitions for each RAM section within the structure Mcu_ConfigType shall contain:
*                   - RAM section base address
*                   - Section size
*                   - Data pre-setting to be initialized
*                   - Ram write size
*
*/
typedef struct
{
    VAR( Mcu_RamSectionType, MCU_VAR) Mcu_RamSectorId;      /**< @brief The ID for Ram Sector configuration. */
    VAR( uint8, MCU_VAR) (*Mcu_pu8RamBaseAddr)[1U];         /**< @brief RAM section base address. */
    VAR( Mcu_RamSizeType, MCU_VAR) Mcu_RamSize;             /**< @brief RAM section size. */
    VAR( uint64, MCU_VAR) Mcu_u64RamDefaultValue;           /**< @brief RAM default value for initialization. */
    VAR(Mcu_RamWriteSizeType, MCU_VAR) Mcu_RamWriteSize;    /**< @brief RAM section write size. */


} Mcu_RamConfigType;



/**
* @brief            The type Mcu_RawResetType specifies the reset reason in raw register format, read from a reset status register.
* @details          The type shall be uint8, uint16 or uint32 based on best performance.
*
* @implements Mcu_RawResetType_typedef
*
*/
typedef uint32 Mcu_RawResetType;   /**< @brief Destructive and Functional Reset Events Log. */

/**
* @brief            DEM error reporting configuration.
* @details          This structure contains information DEM error reporting
*/
typedef struct
{
    VAR( Mcal_DemErrorType, MCU_VAR) Mcu_E_TimeoutFailureCfg;
    VAR( Mcal_DemErrorType, MCU_VAR) Mcu_E_SscmCerFailureCfg;

} Mcu_DemConfigType;

/*==================================================================================================
                                       CONSTANTS
==================================================================================================*/
#if (MCU_INIT_CLOCK == STD_ON)
/**
* @brief            Create defines with the IDs assigned to Mcu Clock configurations.
*                   These IDs will be transmitted as input parameters for Mcu_InitClock() API.
*/
[!LOOP "McuModuleConfiguration/McuClockSettingConfig/*"!]
#define [!"name(.)"!]   ((Mcu_ClockType)[!"num:i( num:i(McuClockSettingId) )"!]U)
#define McuConf_McuClockSettingConfig_[!"name(.)"!]   ((Mcu_ClockType)[!"num:i( num:i(McuClockSettingId) )"!]U)
[!ENDLOOP!]

#endif

/**
* @brief            Create defines with the IDs assigned to Mcu Mode configurations.
*                   These IDs will be transmitted as input parameters for Mcu_SetMode() API.
*/[!LOOP "McuModuleConfiguration/McuModeSettingConf/*"!]
#define [!"name(.)"!]   ((Mcu_ModeType)[!"num:i( num:i(McuMode) )"!]U)
#define McuConf_McuModeSettingConf_[!"name(.)"!]   ((Mcu_ModeType)[!"num:i( num:i(McuMode) )"!]U)
[!ENDLOOP!]

/**
* @brief            Create defines with the IDs assigned to Mcu RAM Section configurations.
*                   These IDs will be transmitted as input parameters for Mcu_InitRamSection() API.
*/
[!LOOP "McuModuleConfiguration/McuRamSectorSettingConf/*"!]
#define [!"name(.)"!]   ((Mcu_RamSectionType)[!"num:i(McuRamSectorId)"!]U)
#define McuConf_McuRamSectorSettingConf_[!"name(.)"!]   ((Mcu_RamSectionType)[!"num:i(McuRamSectorId)"!]U)
[!ENDLOOP!]

/**
* @brief            Create defines with the values assigned to Mcu Reset Reason configurations.
*                   These values can be  retrieved from Mcu_GetResetReason Api.
*/
[!LOOP "McuPublishedInformation/McuResetReasonConf/*"!]
/* @violates @ref Mcu_CFG_H_REF_4 This macro is used to export an alias for MCU Reset Reasons. */
#define McuConf_McuResetReasonConf_[!"name(.)"!]   ((uint8)[!"num:i(McuResetReason)"!]U)
[!ENDLOOP!]


/*==================================================================================================
                                             ENUMS
==================================================================================================*/
/**
* @brief            Type of the return value of the function Mcu_GetPllStatus.
* @details          The type of Mcu_PllStatusType is an enumeration with the following values:
*                       MCU_PLL_LOCKED, MCU_PLL_UNLOCKED, MCU_PLL_STATUS_UNDEFINED.
*
* @implements     Mcu_PllStatusType_enumeration
*
*/
typedef enum
{
    MCU_PLL_LOCKED = 0x33U,   /**< @brief PLL is locked. */
    MCU_PLL_UNLOCKED = 0xCCU,   /**< @brief PLL is unlocked. */
    MCU_PLL_STATUS_UNDEFINED = 0x5AU   /**< @brief PLL Status is unknown. */

} Mcu_PllStatusType;

/**
* @brief            Power Modes encoding.
* @details          Supported power modes for the MCU.
*/
typedef enum
{
#if (MCU_ENTER_LOW_POWER_MODE == STD_ON)
    MCU_WAIT_MODE = 0U,         /**< @brief WAIT Mode */
#endif /* (MCU_ENTER_LOW_POWER_MODE == STD_ON) */
    MCU_RUN_MODE = 1U          /**< @brief RUN Mode. */
} Mcu_PowerModeType;

/**
* @brief            The type Mcu_ResetType, represents the different reset that a specified MCU can have.
* @details          The MCU module shall provide at least the values MCU_POWER_ON_RESET and MCU_RESET_UNDEFINED for the enumeration Mcu_ResetType.
*
* @implements Mcu_ResetType_enumeration
*/
typedef enum
{
    MCU_SOFTWARE_EXTERNAL_RESET = McuConf_McuResetReasonConf_MCU_SOFTWARE_EXTERNAL_RESET,       /**< @brief Software external reset . SIU_RSR[SERF]. */
    MCU_SOFTWARE_SYSTEM_RESET = McuConf_McuResetReasonConf_MCU_SOFTWARE_SYSTEM_RESET,           /**< @brief Software system reset . SIU_RSR[SSSRS]. */
    MCU_STCU_RESET = McuConf_McuResetReasonConf_MCU_STCU_RESET,                                 /**< @brief Self Test Control Unit reset . SIU_RSR[STCURS]. */
    MCU_FCCU_RESET = McuConf_McuResetReasonConf_MCU_FCCU_RESET,                                 /**< @brief Failure Collection and Control Unit (FCCU) reset . SIU_RSR[FCUURS]. */
    MCU_FOSU_RESET = McuConf_McuResetReasonConf_MCU_FOSU_RESET,                                 /**< @brief FCCU Output Supervision Unit (FOSU) reset. SIU_RSR[FOSURS]. */
    MCU_CPU_RESET = McuConf_McuResetReasonConf_MCU_CPU_RESET,                                   /**< @brief Simultaneous Core 0 and Core 1 reset. SIU_RSR[CPURS]. */
    MCU_EXTERNAL_RESET = McuConf_McuResetReasonConf_MCU_EXTERNAL_RESET,                         /**< @brief External reset. SIU_RSR[ERS]. */
    MCU_POWER_ON_RESET = McuConf_McuResetReasonConf_MCU_POWER_ON_RESET,                         /**< @brief Power-on reset. SIU_RSR[PORS]. */
    MCU_NO_RESET_REASON = McuConf_McuResetReasonConf_MCU_NO_RESET_REASON,                       /**< @brief No reset reason found */
    MCU_MULTIPLE_RESET_REASON = McuConf_McuResetReasonConf_MCU_MULTIPLE_RESET_REASON,           /**< @brief More than one reset events are logged except "Power on event" */
    MCU_RESET_UNDEFINED = McuConf_McuResetReasonConf_MCU_RESET_UNDEFINED                        /**< @brief Undefined reset source. */

} Mcu_ResetType;

#if (MCU_GET_RAM_STATE_API == STD_ON)
/**
* @brief            Ram State of the microcontroller.
* @details          This is the Ram State data type returned by the function Mcu_GetRamState() of the Mcu module.
* @implements Mcu_RamStateType_enumeration
*/
typedef enum
{
    MCU_RAMSTATE_INVALID = 0U,   /**< @brief RAM content is not valid or unknown (default). */
    MCU_RAMSTATE_VALID   /**< @brief RAM content is valid. */

} Mcu_RamStateType;
#endif /* (MCU_GET_RAM_STATE_API == STD_ON) */

/**
* @brief            The stage of the flash and ram controllers configuration.
* @details          This is used to specify the entry and exit point of the flash and ram controllers configuration.
*/
typedef enum
{
    MCU_FLASH_MEMORY_CONFIG_ENTRY_POINT = 0x55U,
    MCU_FLASH_MEMORY_CONFIG_EXIT_POINT  = 0xAAU,
    MCU_RAM_MEMORY_CONFIG_ENTRY_POINT   = 0x77U,
    MCU_RAM_MEMORY_CONFIG_EXIT_POINT    = 0x88U
} Mcu_MemoryConfigStageType;

/*==================================================================================================
                                 GLOBAL VARIABLE DECLARATIONS
==================================================================================================*/
#if (MCU_DISABLE_DEM_REPORT_ERROR_STATUS == STD_OFF)
#define MCU_START_SEC_VAR_INIT_UNSPECIFIED
/**
* @violates @ref Mcu_CFG_H_REF_2 #include directives should only be preceded by preprocessor
* directives or comments.
*
* @violates @ref Mcu_CFG_H_REF_3 Precautions shall be taken in order to prevent the contents
* of a header file being included more than once.
*/
#include "Mcu_MemMap.h"
extern P2CONST(Mcu_DemConfigType, MCU_VAR, MCU_APPL_CONST) Mcu_pDemCfgPtr;

#define MCU_STOP_SEC_VAR_INIT_UNSPECIFIED
/**
* @violates @ref Mcu_CFG_H_REF_2 #include directives should only be preceded by preprocessor
* directives or comments.
*
* @violates @ref Mcu_CFG_H_REF_3 Precautions shall be taken in order to prevent the contents
* of a header file being included more than once.
*/
#include "Mcu_MemMap.h"
#endif

extern CONST( Mcu_DemConfigType, MCU_CONST) Mcu_Dem_Config;

[!IF "node:fallback(McuGeneralConfiguration/McuPerformResetApi, 'true') = 'true'"!][!IF "McuGeneralConfiguration/McuCalloutBeforePerformReset = 'true'"!]
/**
* @brief            Export the callout reset procedure configured by the user.
*/
extern FUNC(void, MCU_CODE) MCU_RESET_CALLOUT(void);
[!ENDIF!][!ENDIF!]

[!IF "node:exists(McuGeneralConfiguration/McuCmuNotification)"!]
/**
* @brief            The callout configured by the user for CMU notifications.
*/
extern FUNC(void, MCU_CODE) MCU_CMU_FCCU_NOTIFICATION(VAR (uint8, AUTOMATIC) u8IndexCmu);
[!ENDIF!]

[!IF "node:exists(McuGeneralConfiguration/McuErrorIsrNotification)"!]
/**
* @brief            The callout configured by the user for error ISR notifications.
*/
extern FUNC(void, MCU_CODE) MCU_ERROR_ISR_NOTIFICATION(VAR (uint8, AUTOMATIC) u8ErrorCode);
[!ENDIF!]


[!IF "node:exists(McuGeneralConfiguration/McuPrepareMemoryConfig)"!]
/**
* @brief            The callout configured by the user for preparing flash and ram controllers configuration.
*/
extern FUNC(void, MCU_CODE) MCU_PREPARE_MEMORY_CONFIG(VAR (Mcu_MemoryConfigStageType, AUTOMATIC) eConfigStage);
[!ENDIF!]

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

#ifdef __cplusplus
}
#endif

#endif /* #ifndef MCU_CFG_H */

/** @} */
