[!CODE!][!//
/**
* @file    Port_Cfg.h
* @implements Port_Cfg.h_Artifact
*
* @version 1.0.0
* @brief   AUTOSAR Port - PORT driver configuration.
* @details This file contains the PORT driver precompile configuration.
*
* @addtogroup Port
* @{
*/
/*=================================================================================================
*   Project              : AUTOSAR 4.3 MCAL
*   Platform             : PA
*   Peripheral           : SIU,IGF
*   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 PORT_CFG_H
#define PORT_CFG_H

#ifdef __cplusplus
extern "C" {
#endif

/**
* @page misra_violations MISRA-C:2012 violations
*
*
* @section Port_Cfg_h_REF_1
*          Violates MISRA 2012 Advisory Rule 8.9, An object should be defined at block scope if its identifier only 
*          appears in a single function. This violation is due to exporting the externally configured structures 
*          used by the "Port_SetPinMode" function.
*
* @section [global]
*          Violates MISRA 2012 Required Rule 5.1, External identifiers shall be distinct.
*          The used compilers use more than 31 chars for identifiers.
*
* @section [global]
*          Violates MISRA 2012 Required Rule 5.2, Identifiers declared in the same scope and name space shall be distinct.
*          The used compilers use more than 31 chars for identifiers.
*
* @section [global]
*          Violates MISRA 2012 Required Rule 5.4, Macro identifiers shall be distinct.
*          The used compilers use more than 31 chars for identifiers.
*
* @section [global]
*          Violates MISRA 2012 Required Rule 5.5, Identifiers shall be distinct from macro names.
*          The used compilers use more than 31 chars for identifiers.
*/

/*=================================================================================================
                                         INCLUDE FILES
 1) system and project includes
 2) needed interfaces from external units
 3) internal and external interfaces from this unit
=================================================================================================*/

#include "Port_Siu_Types.h"
#include "Port_Igf_Types.h"

[!INCLUDE "Port_VersionCheck_Inc.m"!][!//
[!NOCODE!][!//
[!INCLUDE "Cobra55_Resource.m"!]
[!ENDNOCODE!][!//
/*=================================================================================================
*                              SOURCE FILE VERSION INFORMATION
=================================================================================================*/

/**
* @brief Parameters that shall be published within the Port driver header file and also in the
*        module's description file
* @details The integration of incompatible files shall be avoided.
*/
#define PORT_VENDOR_ID_CFG_H                       43
#define PORT_AR_RELEASE_MAJOR_VERSION_CFG_H        4
#define PORT_AR_RELEASE_MINOR_VERSION_CFG_H        3
#define PORT_AR_RELEASE_REVISION_VERSION_CFG_H     1
#define PORT_SW_MAJOR_VERSION_CFG_H                1
#define PORT_SW_MINOR_VERSION_CFG_H                0
#define PORT_SW_PATCH_VERSION_CFG_H                0

/*=================================================================================================
*                               FILE VERSION CHECKS
=================================================================================================*/

/* Check if Port_Cfg.h and Port_SIU_Types.h file are of the same vendor */
#if (PORT_VENDOR_ID_CFG_H != PORT_SIU_VENDOR_ID_TYPES_H)
    #error "Port_Cfg.h and Port_Siu_Types.h have different vendor ids"
#endif
/* Check if Port_Cfg.h and Port_Siu_Types.h file are of the same Autosar version */
#if ((PORT_AR_RELEASE_MAJOR_VERSION_CFG_H != PORT_SIU_AR_RELEASE_MAJOR_VERSION_TYPES_H)   ||  \
     (PORT_AR_RELEASE_MINOR_VERSION_CFG_H != PORT_SIU_AR_RELEASE_MINOR_VERSION_TYPES_H)   ||  \
     (PORT_AR_RELEASE_REVISION_VERSION_CFG_H != PORT_SIU_AR_RELEASE_REVISION_VERSION_TYPES_H) \
    )
    #error "AutoSar Version Numbers of Port_Cfg.h and Port_Siu_Types.h are different"
#endif
/* Check if Port_Cfg.h and Port_Siu_Types.h file are of the same software version */
#if ((PORT_SW_MAJOR_VERSION_CFG_H != PORT_SIU_SW_MAJOR_VERSION_TYPES_H) || \
     (PORT_SW_MINOR_VERSION_CFG_H != PORT_SIU_SW_MINOR_VERSION_TYPES_H) || \
     (PORT_SW_PATCH_VERSION_CFG_H != PORT_SIU_SW_PATCH_VERSION_TYPES_H)    \
    )
    #error "Software Version Numbers of Port_Cfg.h and Port_Siu_Types.h are different"
#endif

/* Check if Port_Cfg.h and Port_Igf_Types.h file are of the same vendor */
#if (PORT_VENDOR_ID_CFG_H != PORT_IGF_VENDOR_ID_TYPES_H)
    #error "Port_Cfg.h and Port_Igf_Types.h have different vendor ids"
#endif
/* Check if Port_Cfg.h and Port_Igf_Types.h file are of the same Autosar version */
#if ((PORT_AR_RELEASE_MAJOR_VERSION_CFG_H != PORT_IGF_AR_RELEASE_MAJOR_VERSION_TYPES_H)   ||  \
     (PORT_AR_RELEASE_MINOR_VERSION_CFG_H != PORT_IGF_AR_RELEASE_MINOR_VERSION_TYPES_H)   ||  \
     (PORT_AR_RELEASE_REVISION_VERSION_CFG_H != PORT_IGF_AR_RELEASE_REVISION_VERSION_TYPES_H) \
    )
    #error "AutoSar Version Numbers of Port_Cfg.h and Port_Igf_Types.h are different"
#endif
/* Check if Port_Cfg.h and Port_Igf_Types.h file are of the same software version */
#if ((PORT_SW_MAJOR_VERSION_CFG_H != PORT_IGF_SW_MAJOR_VERSION_TYPES_H) || \
     (PORT_SW_MINOR_VERSION_CFG_H != PORT_IGF_SW_MINOR_VERSION_TYPES_H) || \
     (PORT_SW_PATCH_VERSION_CFG_H != PORT_IGF_SW_PATCH_VERSION_TYPES_H)    \
    )
    #error "Software Version Numbers of Port_Cfg.h and Port_Igf_Types.h are different"
#endif

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


/*=================================================================================================
*                                      DEFINES AND MACROS
=================================================================================================*/

/**
* @brief       Ensure better readability of the configuration
* @note 
*
*/
#define SHL_PAD_U32(x)                      ((uint32)(((uint32)1) << (x)))

/**
* @brief Inmux setting not available
* @note The current platform does not implement pad selection for multiplexed input for current pin.
*       Used for better readability of Inmux settings.
*
*/
#define NO_INPUTMUX_U16                     ((uint16)0xFFFFU)

/**
* @brief Muxsel in the Inmux register not available
* @note The current platform does not implement pad selection for multiplexed input for current pin.
*       Used for better readability of Inmux Muxsel settings.
*
*/
#define MUXSEL_RESERVED_U8                  ((uint8)0xFF)

/**
* @brief Show the Platform used.
* @note This define can be used by test phase.  
*
*/
#define PLATFORM_COBRA55
/**
* @brief Shows the IPV used.
* @note This define can be used by test phase.
*
*/
#define IPV_SIU_USED

/**
* @brief Shows the IPV used.
* @note This define can be used by test phase.
*
*/
#define IPV_IGF_USED


/** @brief Port GPIO Mode */
#define PORT_GPIO_MODE                  ((Port_PinModeType)0)
/** @brief Port Alternate 1 Mode */
#define PORT_ALT1_FUNC_MODE             ((Port_PinModeType)1)
/** @brief Port Alternate 2 Mode */
#define PORT_ALT2_FUNC_MODE             ((Port_PinModeType)2)
/** @brief Port Alternate 3 Mode */
#define PORT_ALT3_FUNC_MODE             ((Port_PinModeType)3)
/** @brief Port Alternate 4 Mode */
#define PORT_ALT4_FUNC_MODE             ((Port_PinModeType)4)
/** @brief Port Input 1 Mode */
#define PORT_INPUT1_MODE                ((Port_PinModeType)5)
/** @brief Port Input 2 Mode */
#define PORT_INPUT2_MODE                ((Port_PinModeType)6)
/** @brief Port Input 3 Mode */
#define PORT_INPUT3_MODE                ((Port_PinModeType)7)
/** @brief Port Input 4 Mode */
#define PORT_INPUT4_MODE                ((Port_PinModeType)8)
/** @brief Port ADC Mode */
#define PORT_ANALOG_INPUT_MODE          ((Port_PinModeType)9)

/** @brief Port Abstraction Modes */
[!IF "((ecu:get('PortPackage'))='Port_mapbga416')"!]
[!"$PinAbstractionModes_1"!]
[!ELSE!]
[!"$PinAbstractionModes_2"!]
[!ENDIF!][!//

/**
* @brief Enable/Disable Development Error Detection
*
* @implements   PORT_DEV_ERROR_DETECT_define
*/
#define PORT_DEV_ERROR_DETECT           [!IF "PortGeneral/PortDevErrorDetect"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]

/**
* @brief Use/remove Port_SetPinDirection function from the compiled driver
*
* @implements   PORT_SET_PIN_DIRECTION_API_define
*/
[!IF "node:exists(PortGeneral/PortSetPinDirectionApi)"!]
#define PORT_SET_PIN_DIRECTION_API      [!IF "PortGeneral/PortSetPinDirectionApi"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]
[!ELSE!]
#define PORT_SET_PIN_DIRECTION_API      (STD_OFF)
[!ENDIF!]

/**
* @brief Use/remove Port_SetPinMode function from the compiled driver
*
* @implements   PORT_SET_PIN_MODE_API_define
*/
[!IF "node:exists(PortGeneral/PortSetPinModeApi)"!]
#define PORT_SET_PIN_MODE_API           [!IF "PortGeneral/PortSetPinModeApi"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]
[!ELSE!]
#define PORT_SET_PIN_MODE_API           (STD_OFF)
[!ENDIF!]

/**
* @brief Enable/Disable Port_SetPinMode function updating the output level of the pins configured at runtime as GPIO
*/
#define PORT_SETPINMODE_DOES_NOT_TOUCH_GPIO_LEVEL           [!IF "PortGeneral/PortSetPinModeDoesNotTouchGpioLevel"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]

/**
* @brief Support for User mode.
*        If this parameter has been configured to 'STD_ON', the Port driver code can be executed from both supervisor and user mode.
*
*/
[!IF "node:exists(PortGeneral/PortEnableUserModeSupport)"!][!//
#define PORT_ENABLE_USER_MODE_SUPPORT   [!IF "PortGeneral/PortEnableUserModeSupport"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]
[!ELSE!]
#define PORT_ENABLE_USER_MODE_SUPPORT   (STD_OFF)
[!ENDIF!]

/**
* @brief Use/remove Port_GetVersionInfo function from the compiled driver
*
* @implements   PORT_VERSION_INFO_API_define
*/
#define PORT_VERSION_INFO_API           [!IF "PortGeneral/PortVersionInfoApi"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]

[!NOCODE!][!//
[!// Various checks performed to validate the configuration
[!SELECT "PortConfigSet"!]
    [!VAR "OuterLoopCounter" = "0"!][!//
    [!VAR "InnerLoopCounter" = "0"!][!//
    [!LOOP "PortContainer/*"!][!//
        [!LOOP "PortPin/*"!][!//
            [!VAR "OuterLoopCounter" = "$OuterLoopCounter + 1"!]
            [!VAR "InnerLoopCounter" = "0"!]
            [!VAR "MatchCounter" = "0"!]
            [!VAR "Id" = "PortPinPcr"!]
            [!VAR "Name" = "node:name(.)"!]
            [!LOOP "../../../../PortContainer/*"!][!//
                [!LOOP "PortPin/*"!][!//
                    [!VAR "InnerLoopCounter" = "$InnerLoopCounter + 1"!]
                    [!IF "$OuterLoopCounter >= $InnerLoopCounter"!]
                        [!IF "($Id = PortPinPcr)"!]
                            [!VAR "MatchCounter" = "$MatchCounter + 1"!]
                        [!ENDIF!][!//
                    [!ENDIF!][!//
                [!ENDLOOP!][!//
            [!ENDLOOP!][!//
            [!IF "$MatchCounter = 1"!]
            [!ELSE!]
                [!ERROR!][!//
                    Error in PortPin list: [!"PortPinPcr is repeated for two or more ports."!][!//
                [!ENDERROR!][!//
            [!ENDIF!][!//
        [!ENDLOOP!][!//
    [!ENDLOOP!][!//
    [!LOOP "PortContainer/*"!][!//
        [!LOOP "PortPin/*"!][!//
            [!VAR "PortPinPcrVar" = "PortPinPcr"!][!//
            [!IF "($PortPinPcrVar>ecu:get('PortMaxPinNumber'))"!][!//
                [!ERROR!][!//
                    Error in PortPin list:[!"name(.)"!] [!"': PortPinPcr '"!] [!"string($PortPinPcrVar)"!] [!"concat('- Physical pin numbers greater then ',ecu:get('PortMaxPinNumber'),' are not available in this package')"!][!//
                [!ENDERROR!][!//
            [!ENDIF!][!//
        [!ENDLOOP!][!//
    [!ENDLOOP!][!//
    [!// Check if the PCRs in UnTouchedPins are unique
    [!VAR "OuterLoopCounter" = "0"!][!//
    [!VAR "InnerLoopCounter" = "0"!][!//
    [!LOOP "UnTouchedPortPin/*"!][!//
        [!VAR "OuterLoopCounter" = "$OuterLoopCounter + 1"!]
        [!VAR "InnerLoopCounter" = "0"!]
        [!VAR "MatchCounter" = "0"!]
        [!VAR "OuterPortPinPcr" = "./PortPinPcr"!]
        [!LOOP "../../UnTouchedPortPin/*"!][!//
            [!VAR "InnerLoopCounter" = "$InnerLoopCounter + 1"!]
            [!IF "$OuterLoopCounter >= $InnerLoopCounter"!]
                [!IF "($OuterPortPinPcr = ./PortPinPcr)"!]
                    [!VAR "MatchCounter" = "$MatchCounter + 1"!]
                [!ENDIF!][!//
            [!ENDIF!][!//
        [!ENDLOOP!][!//
        [!IF "$MatchCounter > 1"!]
            [!ERROR!][!//
            Error in UnTouchedPortPin list: [!"name(.)"!] with [!"'PortPin Pcr'"!] set to [!"string($OuterPortPinPcr)"!] [!"Pcr is repeated for two or more ports."!][!//
            [!ENDERROR!][!//
        [!ENDIF!][!//
    [!ENDLOOP!][!//
    [!// Check if the configured PCRs in UnTouchedPortPin list are in range for the specified SIU instance
    [!VAR "MscrIdxStart"="ecu:get('PortPcrIdxStart')"!][!//
    [!VAR "MscrIdxEnd"="ecu:get('PortPcrIdxEnd')"!][!//
    [!LOOP "UnTouchedPortPin/*"!][!//
        [!VAR "PortPinPcrVar" = "PortPinPcr"!][!//
        [!IF "($PortPinPcrVar < $MscrIdxStart)"!][!//
            [!ERROR!][!//
            Error in UnTouchedPortPin list: [!"name(.)"!] with [!"'PortPin Pcr'"!] set to [!"string($PortPinPcrVar)"!] [!"Pcr numbers lower than ',$MscrIdxStart,' are not available in this package"!][!//
            [!ENDERROR!][!//
        [!ENDIF!][!//
        [!IF "($PortPinPcrVar > $MscrIdxEnd)"!][!//
            [!ERROR!][!//
            Error in UnTouchedPortPin list: [!"name(.)"!] with [!"'PortPin Pcr'"!] set to [!"string($PortPinPcrVar)"!] [!"Pcr numbers greater than ',$MscrIdxEnd,' are not available in this package"!][!//
            [!ENDERROR!][!//
        [!ENDIF!][!//
    [!ENDLOOP!][!//
    [!// Check if the configured PCRs are not on the list of excluded pins
    [!VAR "resourceName" = "'PortNotAvailablePins'"!][!//
    [!LOOP "UnTouchedPortPin/*"!][!//
        [!VAR "PortPinPcrVar" = "PortPinPcr"!][!//
        [!IF "contains(concat(',',string(ecu:get($resourceName)),','), concat(',',$PortPinPcrVar,','))"!][!//
            [!ERROR!][!//
            Error in UnTouchedPortPin list: [!"name(.)"!] with [!"'PortPin Pcr'"!] set to [!"string($PortPinPcrVar)"!] [!"Pcr not available in this package."!][!//
            [!ENDERROR!][!//
        [!ENDIF!][!//
    [!ENDLOOP!][!//
    [!// Check if there is no PCR that appears both in list of configured pins and in the list of UnTouchedPortPins
    [!LOOP "PortContainer/*"!][!//
        [!VAR "PortContainerName" = "name(.)"!]
        [!LOOP "PortPin/*"!][!//
            [!VAR "MatchCounter" = "0"!]
            [!VAR "ConfiguredPortPinPcr" = "./PortPinPcr"!]
            [!LOOP "../../../../UnTouchedPortPin/*"!][!//
                [!IF "($ConfiguredPortPinPcr = ./PortPinPcr)"!]
                    [!ERROR!][!//
                    Error: PCR [!"string($ConfiguredPortPinPcr)"!] appears in the UnTouchedPortPin list and also in the list of configured pins in Port container [!"string($PortContainerName)"!]. Please remove it from one of the 2 lists[!//
                    [!ENDERROR!][!//
                [!ENDIF!][!//
            [!ENDLOOP!][!//
        [!ENDLOOP!][!//
    [!ENDLOOP!][!//
[!ENDSELECT!][!//
[!ENDNOCODE!][!//
/**
* @brief Port Pin symbolic names
* @details Get All Symbolic Names from configuration tool
*
*
*/
[!NOCODE!]
    [!VAR "OutConfigLoopCounter" = "0"!][!//
    [!VAR "ConfigSetIndex"="0"!]
    [!SELECT "PortConfigSet"!][!//
        [!VAR "ConfigSetName" = "as:name(.)"!][!//
        [!VAR "OutConfigLoopCounter" = "$OutConfigLoopCounter + 1"!][!//
        [!VAR "OutPinLoopCounter" = "0"!][!//
        [!LOOP "PortContainer/*"!][!//
            [!VAR "ContName" = "node:name(.)"!][!//
            [!LOOP "PortPin/*"!][!//
                [!VAR "OutPinLoopCounter" = "$OutPinLoopCounter + 1"!][!//
                [!VAR "Name" = "node:name(.)"!][!//
                [!VAR "MatchCounter" = "0"!][!//
                [!VAR "InConfigLoopCounter" = "0"!][!//
                [!VAR "MatchConfigSet" = "0"!][!//
                [!SELECT "../../../../../PortConfigSet"!][!//
                    [!VAR "InConfigLoopCounter" = "$InConfigLoopCounter + 1"!][!//
                    [!VAR "InPinLoopCounter" = "0"!][!//
                    [!LOOP "PortContainer/*"!][!//
                        [!VAR "ContNameNew" = "node:name(.)"!][!//
                        [!LOOP "PortPin/*"!][!//
                            [!VAR "InPinLoopCounter" = "$InPinLoopCounter + 1"!][!//
                            [!IF "$InConfigLoopCounter < $OutConfigLoopCounter"!][!//
                                [!IF "($ContName = $ContNameNew)"!][!//
                                    [!IF "($Name = node:name(.))"!][!//
                                        [!IF "$InPinLoopCounter = $OutPinLoopCounter"!][!//
                                            [!IF "$MatchConfigSet = $ConfigSetIndex"!][!//
                                                [!VAR "MatchCounter" = "$MatchCounter + 1"!][!//
                                            [!ENDIF!][!//
                                        [!ELSE!][!//
                                            [!ERROR!][!//
                                               Error in PortPin list:[!"concat('- The same Abstract Name ',($Name),' is used for different index values')"!][!//
                                            [!ENDERROR!][!//
                                        [!ENDIF!][!//
                                    [!ENDIF!][!//
                                [!ENDIF!][!//
                            [!ENDIF!][!//
                        [!ENDLOOP!][!//
                    [!ENDLOOP!][!//
                    [!VAR "$MatchConfigSet" = "$MatchConfigSet+1"!][!//
                [!ENDSELECT!][!//
                [!IF "$MatchCounter = 0"!][!//
                    [!VAR "PortPinIdVar"="PortPinId"!][!//
[!CODE!][!//

#define [!"$ConfigSetName"!]_[!"$ContName"!]_[!"node:name(.)"!]  [!"num:i($PortPinIdVar - 1)"!]
[!ENDCODE!][!//
                [!ENDIF!][!//
            [!ENDLOOP!][!//
        [!ENDLOOP!][!//
    [!ENDSELECT!][!//
[!ENDNOCODE!]

/**
* @brief Number of INMUX registers
* @details Platform constant
*/
#define PORT_NMBR_INMUX_REGS_U16    ((uint16)[!"ecu:get('PortMaxInmuxRegs')"!])
/**
* @brief Number of available pad modes options
* @details Platform constant
*/
#define PAD_MODE_OPTIONS_U8         ((uint8)[!"ecu:get('PortPadModeNumber')"!])
/**
* @brief Number of pad 16 blocks
* @details Platform constant
*/
#define PAD_16BLOCK_NO_U8           ((uint8)[!"ecu:get('PortPin16BlocksNo')"!])

[!IF "IMPLEMENTATION_CONFIG_VARIANT='VariantPreCompile' and variant:size()<=1"!][!//
/**
* @brief Port driver Pre-Compile configuration switch
*/
#define PORT_PRECOMPILE_SUPPORT     (STD_ON)
[!ELSE!][!//
/**
* @brief Port driver Post-build configuration switch
*/
#define PORT_PRECOMPILE_SUPPORT     (STD_OFF)
[!ENDIF!][!//

/**
* @brief Number of UnUsed pin array
*/
[!NOCODE!]
    [!SELECT "PortConfigSet"!][!//
        [!VAR "MaxNoOfPins" = "num:i(ecu:get('PortMaxPinNumber')+1)"!][!//
        [!VAR "UnimplementedPadsNumber" = "num:i(count(ecu:list('PortUnimplementedPads')))"!][!//
        [!VAR "UserPadsNumber" = "num:i(count(PortContainer/*/PortPin/*))"!][!//
        [!VAR "NoOfUntouchedPortPin" = "num:i(count(UnTouchedPortPin/*))"!][!//
        [!LOOP "PortContainer/*/PortPin/*"!][!//
            [!IF "contains(concat(',',string(ecu:get('PortUnimplementedPads')),','),concat(',',PortPinPcr,','))"!][!//
                [!VAR "UnimplementedPadsNumber"= "$UnimplementedPadsNumber - 1"!][!//
            [!ENDIF!][!//
        [!ENDLOOP!][!//
        [!VAR "DefaultPinNumber" = "$UnimplementedPadsNumber + $UserPadsNumber"!][!//
        [!VAR "NoOfUnusedPins" = "num:i($MaxNoOfPins - $DefaultPinNumber - $NoOfUntouchedPortPin)"!][!//
[!CODE!][!//
#define PORT_MAX_UNUSED_PADS_U16   ([!"$NoOfUnusedPins"!]U)
[!ENDCODE!][!//
    [!ENDSELECT!][!//
[!ENDNOCODE!][!//

/**
* @brief The maximum number of configured pins
*/
#define PORT_MAX_CONFIGURED_PADS_U16                        ((uint16)[!"num:i(count(PortConfigSet/PortContainer/*/PortPin/*))"!])

#if (STD_ON == PORT_SET_PIN_MODE_API)
[!IF "((ecu:get('PortPackage'))='Port_mapbga416')"!][!//
#define  PORT_INDEX_TABLE_NUM_ENTRIES_U16  [!"$SIZE_OF_INDEX_TABLE_1"!]
[!ELSE!][!//
#define  PORT_INDEX_TABLE_NUM_ENTRIES_U16  [!"$SIZE_OF_INDEX_TABLE_2"!]
[!ENDIF!][!//
#endif /* (STD_ON == PORT_SET_PIN_MODE_API) */

#define PORT_USER_MODE_SOFT_LOCKING    (STD_OFF)

/*=================================================================================================
*                                             ENUMS
=================================================================================================*/


/*=================================================================================================
*                                STRUCTURES AND OTHER TYPEDEFS
=================================================================================================*/
/**
* @brief   Structure needed by @p Port_Init().
* @details The structure @p Port_IgfConfigType is a type for the external data
*          structure containing the initialization data for the IGF IP.
* @note    The user must use the symbolic names defined in the configuration
*          tool.
*
*
* @api
*/
typedef struct
{
    VAR(uint8, AUTOMATIC) u8NumChannels;                                                 /**< @brief Number of used IGF channels (to be configured) */
    P2CONST(Port_Igf_ChannelConfigType, AUTOMATIC, PORT_APPL_CONST) pChannelConfig;      /**< @brief Used IGF channels data configuration */
} Port_IgfConfigType;

/**
* @brief   Structure needed by @p Port_Init().
* @details The structure @p Port_ConfigType is a type for the external data
*          structure containing the initialization data for the PORT Driver.
* @note    The user must use the symbolic names defined in the configuration
*          tool.
*
* @implements Port_ConfigType_struct
*
* @api
*/
typedef struct
{
    VAR(uint16, AUTOMATIC) u16NumPins;                                                   /**< @brief Number of used pads (to be configured) */
    VAR(uint16, AUTOMATIC) u16NumUnusedPins;                                             /**< @brief Number of unused pads */
    P2CONST(uint16, AUTOMATIC, PORT_APPL_CONST) au16UnusedPads;                          /**< @brief Unused pad id's array */
    P2CONST(Port_Siu_UnUsedPinConfigType, AUTOMATIC, PORT_APPL_CONST) pUnusedPadConfig;  /**< @brief Unused pad configuration */
    P2CONST(Port_Siu_PinConfigType, AUTOMATIC, PORT_APPL_CONST) pUsedPadConfig;          /**< @brief Used pads data configuration */
    P2CONST(Port_Siu_PadSelConfigType, AUTOMATIC, PORT_APPL_CONST) pPadSelConfig;        /**< @brief Used pads INMUX configuration */
    VAR(Port_IgfConfigType, AUTOMATIC) IgfConfig;                                        /**< @brief IGF IP configuration structure */
} Port_ConfigType;


/**
* @brief Settings for a INMUX register
* @details The structure @p Port_InMuxSettingType manages ExtraFunctions PinMode.
*
* @api
*/
typedef struct
{
    VAR(uint16,                AUTOMATIC) u16InMuxId;   /**< @brief The id of the INMUX register to be configured */
    VAR(uint8,                 AUTOMATIC) u8InMuxCode;  /**< @brief The value of the INMUX reg for signal allocation */
    VAR(Port_PinDirectionType, AUTOMATIC) eDirection;   /**< @brief The direction of the signal (In, Out, Inout) */
} Port_InMuxSettingType;


/**
* @brief Strucure of an entry in the index table that directs the setting of a pad 
*        functionality to either a Mux or Inmux entry
*
* @api
*/
typedef struct
{
    VAR(uint16, AUTOMATIC) u16PCR;                /**< @brief The PCR number of the register to be configured */
    VAR(uint8,  AUTOMATIC) u8Mode;                /**< @brief The mode value of the pad functionality */
    VAR(uint16, AUTOMATIC) u16IdxMuxOrInmuxTable; /**< @brief Depending on the u8Mode variable, this is the index in Mux or Inmux settings table */
} Port_SettingsIndexType;

/*=================================================================================================
                                 GLOBAL VARIABLE DECLARATIONS
=================================================================================================*/
#define PORT_START_SEC_CONFIG_DATA_16

#include "Port_MemMap.h"

#if (STD_ON == PORT_SET_PIN_MODE_API)
/**
* @brief External declaration of the Port pin description array
*/
/** @violates @ref Port_Cfg_h_REF_1 An object should be defined at block scope if its identifier only appears in a single function. */
extern CONST(uint16, PORT_CONST) Port_au16PinDescription[[!"ecu:get('PortPadModeNumber')"!]][[!"ecu:get('PortPin16BlocksNo')"!]];

#endif

#define PORT_STOP_SEC_CONFIG_DATA_16

#include "Port_MemMap.h"

#define PORT_START_SEC_CONFIG_DATA_UNSPECIFIED

#include "Port_MemMap.h"

[!MACRO "PortExportDriverConfiguration"!][!//
[!NOCODE!][!//
[!VAR "configName" = "as:name(PortConfigSet)"!][!//
[!IF "var:defined('postBuildVariant')"!][!//
    [!VAR "variantIndex"="0"!][!//
    [!VAR "variantNumber"="variant:size()"!][!//
    [!LOOP "variant:all()"!][!VAR "variantIndex"="$variantIndex + 1"!][!//
[!CODE!][!//

extern CONST(Port_ConfigType, PORT_CONST) [!"$configName"!]_[!"."!];[!CR!][!//
[!ENDCODE!][!//
    [!ENDLOOP!][!//
[!ELSE!][!//
[!CODE!][!//

extern CONST(Port_ConfigType, PORT_CONST) [!"$configName"!];[!CR!][!//
[!ENDCODE!][!//
[!ENDIF!][!//
[!ENDNOCODE!][!//
[!ENDMACRO!][!//

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

#if (STD_ON == PORT_SET_PIN_MODE_API)

[!IF "((ecu:get('PortPackage'))='Port_mapbga416')"!][!//

/** @brief Port Mux settings data (for pads that do not require setting of Inmux register) */
/** @violates @ref Port_Cfg_h_REF_1 An object should be defined at block scope if its identifier only appears in a single function. */
extern CONST(Port_PinDirectionType,  PORT_CONST) Port_aPadFunctMuxSettings[[!"$SIZE_OF_MUX_TABLE_1"!]];

/** @brief Port Inmux settings data (for pads that do require setting of Inmux register) */
/** @violates @ref Port_Cfg_h_REF_1 An object should be defined at block scope if its identifier only appears in a single function. */
extern CONST(Port_InMuxSettingType,  PORT_CONST) Port_aPadFunctInMuxSettings[[!"$SIZE_OF_INMUX_TABLE_1"!]];

/** @brief Pad index data to either Mux settings table or Inmux settings table */
extern CONST(Port_SettingsIndexType, PORT_CONST) Port_aPadFunctIndex[PORT_INDEX_TABLE_NUM_ENTRIES_U16];

[!ELSE!][!//

/** @brief Port Mux settings data (for pads that do not require setting of Inmux register) */
/** @violates @ref Port_Cfg_h_REF_1 An object should be defined at block scope if its identifier only appears in a single function. */
extern CONST(Port_PinDirectionType,  PORT_CONST) Port_aPadFunctMuxSettings[[!"$SIZE_OF_MUX_TABLE_2"!]];

/** @brief Port Inmux settings data (for pads that do require setting of Inmux register) */
/** @violates @ref Port_Cfg_h_REF_1 An object should be defined at block scope if its identifier only appears in a single function. */
extern CONST(Port_InMuxSettingType,  PORT_CONST) Port_aPadFunctInMuxSettings[[!"$SIZE_OF_INMUX_TABLE_2"!]];

/** @brief Pad index data to either Mux settings table or Inmux settings table */
extern CONST(Port_SettingsIndexType, PORT_CONST) Port_aPadFunctIndex[PORT_INDEX_TABLE_NUM_ENTRIES_U16];

[!ENDIF!][!//

#endif /* (STD_ON == PORT_SET_PIN_MODE_API) */

#define PORT_STOP_SEC_CONFIG_DATA_UNSPECIFIED

#include "Port_MemMap.h"

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


#ifdef __cplusplus
}
#endif

#endif /* PORT_CFG_H */

/** @} */

/* End of File */
[!ENDCODE!][!//
