/**
*   @file    Lin_PBcfg.c
*   @implements Lin_PBcfg.c_Artifact
*   @version 1.0.0
*
*   @brief   AUTOSAR Lin - Brief file description (one line).
*   @details Detailed file description (can be multiple lines).
*
*   @addtogroup LIN
*   @{
*/
/*==================================================================================================
*   Project              : AUTOSAR 4.3 MCAL
*   Platform             : PA
*   Peripheral           : ESCI
*   Dependencies         : 
*
*   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.
* 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.
*
* @section Lin[!IF "var:defined('postBuildVariant')"!]_[!"$postBuildVariant"!][!ENDIF!]_PBcfg_c_REF_1
* Violates MISRA 2012 Advisory Rule 20.1, #include directives should only be preceded by preprocessor directives or comments.
* <MA>_MemMap.h is included after each section define in order to set the current memory section as defined by AUTOSAR.
*
* @section Lin[!IF "var:defined('postBuildVariant')"!]_[!"$postBuildVariant"!][!ENDIF!]_PBcfg_c_REF_2
* 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 <MA>_MemMap.h is as per AUTOSAR requirement [SWS_MemMap_00003].
*
* @section Lin[!IF "var:defined('postBuildVariant')"!]_[!"$postBuildVariant"!][!ENDIF!]_PBcfg_c_REF_3
* Violates MISRA 2012 Required Rule 8.4, A compatible declaration shall be visible when an object or function with external linkage is defined.
* Some object or function with external linkage are defined just for check for other parameters.
*
* @section Lin[!IF "var:defined('postBuildVariant')"!]_[!"$postBuildVariant"!][!ENDIF!]_PBcfg_c_REF_4
* Violates MISRA 2012 Advisory Rule 8.7, Functions and objects should not be defined with external linkage
* if they are referenced in only one translation unit.
*
* @section Lin[!IF "var:defined('postBuildVariant')"!]_[!"$postBuildVariant"!][!ENDIF!]_PBcfg_c_REF_5
* 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 initialization structure used by the "Lin_Init" function.
*/


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

#if (LIN_DISABLE_DEM_REPORT_ERROR_STATUS == STD_OFF)
#include "Dem.h"
#endif /* (LIN_DISABLE_DEM_REPORT_ERROR_STATUS == STD_OFF) */

/*==================================================================================================
*                              SOURCE FILE VERSION INFORMATION
==================================================================================================*/
/**
* @file           Lin_PBcfg.c
*/
#define LIN_VENDOR_ID_PBCFG_C                      43
#define LIN_AR_RELEASE_MAJOR_VERSION_PBCFG_C       4
#define LIN_AR_RELEASE_MINOR_VERSION_PBCFG_C       3
#define LIN_AR_RELEASE_REVISION_VERSION_PBCFG_C    1
#define LIN_SW_MAJOR_VERSION_PBCFG_C               1
#define LIN_SW_MINOR_VERSION_PBCFG_C               0
#define LIN_SW_PATCH_VERSION_PBCFG_C               0

/*==================================================================================================
*                                     FILE VERSION CHECKS
==================================================================================================*/
[!NOCODE!][!//
[!INCLUDE "Lin_VersionCheck_Src_PB.m"!][!//
[!ENDNOCODE!][!//
/* Check if current file and LIN header file are of the same vendor */
#if (LIN_VENDOR_ID_PBCFG_C != LIN_VENDOR_ID_CFG)
    #error "Lin_PBcfg.c and Lin_Cfg.h have different vendor ids"
#endif
/* Check if current file and LIN header file are of the same Autosar version */
#if ((LIN_AR_RELEASE_MAJOR_VERSION_PBCFG_C    != LIN_AR_RELEASE_MAJOR_VERSION_CFG) || \
     (LIN_AR_RELEASE_MINOR_VERSION_PBCFG_C    != LIN_AR_RELEASE_MINOR_VERSION_CFG) || \
     (LIN_AR_RELEASE_REVISION_VERSION_PBCFG_C != LIN_AR_RELEASE_REVISION_VERSION_CFG))
    #error "AutoSar Version Numbers of Lin_PBcfg.c and Lin_Cfg.h are different"
#endif
/* Check if current file and LIN header file are of the same Software version */
#if ((LIN_SW_MAJOR_VERSION_PBCFG_C != LIN_SW_MAJOR_VERSION_CFG) || \
     (LIN_SW_MINOR_VERSION_PBCFG_C != LIN_SW_MINOR_VERSION_CFG) || \
     (LIN_SW_PATCH_VERSION_PBCFG_C != LIN_SW_PATCH_VERSION_CFG))
    #error "Software Version Numbers of Lin_PBcfg.c and Lin_Cfg.h are different"
#endif

#ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
  #if ((LIN_AR_RELEASE_MAJOR_VERSION_PBCFG_C != STD_AR_RELEASE_MAJOR_VERSION) || \
       (LIN_AR_RELEASE_MINOR_VERSION_PBCFG_C != STD_AR_RELEASE_MINOR_VERSION))
    #error "AutoSar Version Numbers of Lin_PBCfg.c and Std_Types.h are different"
  #endif
  #if (LIN_DISABLE_DEM_REPORT_ERROR_STATUS == STD_OFF)
    /* Check if current file and Dem.h header file are of the same Autosar version */
    #if ((LIN_AR_RELEASE_MAJOR_VERSION_PBCFG_C != DEM_AR_RELEASE_MAJOR_VERSION) || \
         (LIN_AR_RELEASE_MINOR_VERSION_PBCFG_C != DEM_AR_RELEASE_MINOR_VERSION))
        #error "AutoSar Version Numbers of Lin_PBcfg.c and Dem.h are different"
    #endif
  #endif /* (LIN_DISABLE_DEM_REPORT_ERROR_STATUS == STD_OFF) */
#endif

/*==================================================================================================
*                          LOCAL TYPEDEFS (STRUCTURES, UNIONS, ENUMS)
==================================================================================================*/


/*==================================================================================================
*                                       LOCAL MACROS
==================================================================================================*/


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


/*==================================================================================================
*                                      LOCAL VARIABLES
==================================================================================================*/


/*==================================================================================================
*                                      GLOBAL CONSTANTS
==================================================================================================*/
#define LIN_START_SEC_CONFIG_DATA_UNSPECIFIED
/**
* @violates @ref Lin[!IF "var:defined('postBuildVariant')"!]_[!"$postBuildVariant"!][!ENDIF!]_PBcfg_c_REF_1 <MA>_MemMap.h is included
                 after each section define in order to set the current memory section as defined by AUTOSAR.
* @violates @ref Lin[!IF "var:defined('postBuildVariant')"!]_[!"$postBuildVariant"!][!ENDIF!]_PBcfg_c_REF_2 This violation is not fixed
                  since the inclusion of <MA>_MemMap.h is as per AUTOSAR requirement [SWS_MemMap_00003].
*/
#include "Lin_MemMap.h"


[!NOCODE!][!//
[!VAR "SBR"="0"!][!//
[!VAR "temp1" = "0"!][!//
[!VAR "temp2" = "0"!][!//
[!VAR "ESCISBR" = "0"!][!//
[!VAR "ECUM_WAKE_UP_SOURCE" = "0"!][!//
[!VAR "DualClockEnabled"= "'false'"!]
    [!LOOP "LinGlobalConfig/LinChannel/*"!][!//
        [!IF "(node:exists(LinClockRef_Alternate))"!][!//
            [!VAR "DualClockEnabled" = "'true'"!]
        [!ENDIF!][!//
    [!ENDLOOP!][!//
[!ENDNOCODE!][!//

/**
* @brief          Configuration for Lin Channel - Configuration:
*
*
* @api
*/
[!VAR "nodeName" = "as:name(./LinGlobalConfig)"!][!//
[!LOOP "LinGlobalConfig/LinChannel/*"!][!//
/**
* @brief          Configuration for Lin Channel - Configuration:
*
*
* @api
*/
/**
* @violates @ref Lin[!IF "var:defined('postBuildVariant')"!]_[!"$postBuildVariant"!][!ENDIF!]_PBcfg_c_REF_3 Function with external linkage is not visible.
* @violates @ref Lin[!IF "var:defined('postBuildVariant')"!]_[!"$postBuildVariant"!][!ENDIF!]_PBcfg_c_REF_4 These functions
*                represent the API of the driver. External linkage is needed to "export" the API.
*/
CONST(Lin_ChannelConfigType,LIN_CONST) Lin_[!"node:name(.)"!][!IF "var:defined('postBuildVariant')"!]_[!"$postBuildVariant"!][!ENDIF!]=
{
    &Lin_[!"node:name(.)"!]_PC,
[!NOCODE!][!//
    [!VAR "linBaudrate" = "LinChannelBaudRate"!]
    [!SELECT "node:ref(LinClockRef)"!]
        [!INCLUDE "Lin_BaudRate_Comp.m"!][!//
    [!ENDSELECT!]
[!ENDNOCODE!][!//
    [!"$ESCISBR"!]U,    /* Baudrate [!"LinChannelBaudRate"!] */
[!CODE!]
#if (STD_ON == LIN_DUAL_CLOCK_MODE)
[!ENDCODE!]
[!NOCODE!][!//
    [!IF "$DualClockEnabled = 'true'"!]
        [!IF "node:exists(node:value(LinClockRef_Alternate))"!]
            [!VAR "linBaudrate" = "LinChannelBaudRate"!]
            [!SELECT "node:ref(LinClockRef_Alternate)"!]
                [!INCLUDE "Lin_BaudRate_Comp.m"!][!//
            [!ENDSELECT!][!//
            [!CODE!]
                [!"$ESCISBR"!]U,    /* Alternate Baudrate [!"LinChannelBaudRate"!] */
            [!ENDCODE!]
        [!ELSE!]
            [!CODE!]
                [!"$ESCISBR"!]U,    /* LIN is not enable Alternate Mode, Set Alternate Baudrate is the same configuration as Normal Mode */
            [!ENDCODE!]
        [!ENDIF!][!//
    [!ENDIF!]
[!CODE!]
#endif
[!ENDCODE!]
[!ENDNOCODE!][!//
};

[!ENDLOOP!][!//


[!NOCODE!][!//
[!VAR "nodeName" = "as:name(./LinGlobalConfig)"!][!//
[!CODE!]
/**
* @brief          Lin Configuration data for [!"$nodeName"!].
*
* @api
*/
/**
* @violates @ref Lin[!IF "var:defined('postBuildVariant')"!]_[!"$postBuildVariant"!][!ENDIF!]_PBcfg_c_REF_3 Function with external linkage is not visible.
* @violates @ref Lin[!IF "var:defined('postBuildVariant')"!]_[!"$postBuildVariant"!][!ENDIF!]_PBcfg_c_REF_4 These functions
                 represent the API of the driver. External linkage is needed to "export" the API.
* @violates @ref Lin[!IF "var:defined('postBuildVariant')"!]_[!"$postBuildVariant"!][!ENDIF!]_PBcfg_c_REF_5 This violation is due to exporting
                 the externally configured initialization structure used by the "<MA>_Init" function.
*/
[!IF "(IMPLEMENTATION_CONFIG_VARIANT = 'VariantPreCompile') and (variant:size() <= 1)"!]
CONST(Lin_ConfigType,LIN_CONST) Lin_PBCfgVariantPredefined =
[!ELSE!]
CONST(Lin_ConfigType,LIN_CONST) [!"$nodeName"!][!IF "var:defined('postBuildVariant')"!]_[!"$postBuildVariant"!][!ENDIF!] =
[!ENDIF!]
{
    {
[!ENDCODE!]
    [!VAR "count"="0"!]
    [!VAR "MaxChannelNr" = "num:i(count(LinGlobalConfig/LinChannel/*))"!]
    [!FOR "count" = "0" TO "$MaxChannelNr - 1"!]
        [!LOOP "LinGlobalConfig/LinChannel/*"!]
            [!IF "$count = num:i(LinChannelId)"!]
                [!CODE!]
        /**
        * @brief   Configuration for Lin Channel.
        */
                [!ENDCODE!]
                [!IF "$count > $MaxChannelNr - 2"!]
                    [!CODE!]
        &Lin_[!"node:name(.)"!][!IF "var:defined('postBuildVariant')"!]_[!"$postBuildVariant"!][!ENDIF!]
                    [!ENDCODE!]
                [!ELSE!]
                    [!CODE!]
        &Lin_[!"node:name(.)"!][!IF "var:defined('postBuildVariant')"!]_[!"$postBuildVariant"!][!ENDIF!],
                    [!ENDCODE!]
                [!ENDIF!]
            [!ENDIF!]
        [!ENDLOOP!]
    [!ENDFOR!]
[!CODE!]
    }
};
[!ENDCODE!]
[!ENDNOCODE!]

#define LIN_STOP_SEC_CONFIG_DATA_UNSPECIFIED
/**
* @violates @ref Lin[!IF "var:defined('postBuildVariant')"!]_[!"$postBuildVariant"!][!ENDIF!]_PBcfg_c_REF_1 <MA>_MemMap.h is included
                 after each section define in order to set the current memory section as defined by AUTOSAR.
* @violates @ref Lin[!IF "var:defined('postBuildVariant')"!]_[!"$postBuildVariant"!][!ENDIF!]_PBcfg_c_REF_2 This violation is not fixed
                  since the inclusion of <MA>_MemMap.h is as per AUTOSAR requirement [SWS_MemMap_00003].
*/
#include "Lin_MemMap.h"


/*==================================================================================================
*                                      GLOBAL VARIABLES
==================================================================================================*/

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


/*==================================================================================================
*                                       LOCAL FUNCTIONS
==================================================================================================*/
#define LIN_START_SEC_CODE
/**
* @violates @ref Lin[!IF "var:defined('postBuildVariant')"!]_[!"$postBuildVariant"!][!ENDIF!]_PBcfg_c_REF_1 <MA>_MemMap.h is included
                 after each section define in order to set the current memory section as defined by AUTOSAR.
* @violates @ref Lin[!IF "var:defined('postBuildVariant')"!]_[!"$postBuildVariant"!][!ENDIF!]_PBcfg_c_REF_2 This violation is not fixed
                  since the inclusion of <MA>_MemMap.h is as per AUTOSAR requirement [SWS_MemMap_00003].
*/

#include "Lin_MemMap.h"

/*==================================================================================================
*                                       GLOBAL FUNCTIONS
==================================================================================================*/

#define LIN_STOP_SEC_CODE
/**
* @violates @ref Lin[!IF "var:defined('postBuildVariant')"!]_[!"$postBuildVariant"!][!ENDIF!]_PBcfg_c_REF_1 <MA>_MemMap.h is included
                 after each section define in order to set the current memory section as defined by AUTOSAR.
* @violates @ref Lin[!IF "var:defined('postBuildVariant')"!]_[!"$postBuildVariant"!][!ENDIF!]_PBcfg_c_REF_2 This violation is not fixed
                  since the inclusion of <MA>_MemMap.h is as per AUTOSAR requirement [SWS_MemMap_00003].
*/

#include "Lin_MemMap.h"

#ifdef __cplusplus
}
#endif

/** @} */
