/*
* Copyright (C) 2023-2024 Texas Instruments Incorporated
*
* All rights reserved not granted herein.
* Limited License.  
*
* Texas Instruments Incorporated grants a world-wide, royalty-free, 
* non-exclusive license under copyrights and patents it now or hereafter 
* owns or controls to make, have made, use, import, offer to sell and sell ("Utilize")
* this software subject to the terms herein.  With respect to the foregoing patent 
* license, such license is granted  solely to the extent that any such patent is necessary 
* to Utilize the software alone.  The patent license shall not apply to any combinations which 
* include this software, other than combinations with devices manufactured by or for TI ("TI Devices").  
* No hardware patent is licensed hereunder.
*
* Redistributions must preserve existing copyright notices and reproduce this license (including the 
* above copyright notice and the disclaimer and (if applicable) source code license limitations below) 
* in the documentation and/or other materials provided with the distribution
*
* Redistribution and use in binary form, without modification, are permitted provided that the following
* conditions are met:
*
*	* No reverse engineering, decompilation, or disassembly of this software is permitted with respect to any 
*     software provided in binary form.
*	* any redistribution and use are licensed by TI for use only with TI Devices.
*	* Nothing shall obligate TI to provide you with source code for the software licensed and provided to you in object code.
*
* If software source code is provided to you, modification and redistribution of the source code are permitted 
* provided that the following conditions are met:
*
*   * any redistribution and use of the source code, including any resulting derivative works, are licensed by 
*     TI for use only with TI Devices.
*   * any redistribution and use of any object code compiled from the source code and any resulting derivative 
*     works, are licensed by TI for use only with TI Devices.
*
* Neither the name of Texas Instruments Incorporated nor the names of its suppliers may be used to endorse or 
* promote products derived from this software without specific prior written permission.
*
* DISCLAIMER.
*
* THIS SOFTWARE IS PROVIDED BY TI AND TI'S LICENSORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
* IN NO EVENT SHALL TI AND TI'S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
* POSSIBILITY OF SUCH DAMAGE.
*/
 /***************************************************************************
  Project: [!"$project"!]
  Date   : [!"$datetime"!]
  This file is generated by EB Tresos
  Do not modify this file, otherwise the software may behave in unexpected way.

 *****************************************************************************/

/**
 *  \file     Lin_Cfg.h
 *
 *  \brief    This file contains generated pre compile configuration file for
 *            LIN MCAL driver
 *
 */

/******************************************************************************
 * \defgroup MCAL_LIN_CFG Lin Configuration
 *
 * This files defines Lin MCAL configuration structures
 *  @{
 ******************************************************************************/

#ifndef LIN_CFG_H
#define LIN_CFG_H

#ifdef __cplusplus
extern "C" {
#endif

/**
*  \brief LIN Build Variant.
*   Build variants.(i.e Pre Compile, Post Build)
*/
[!IF "as:modconf('Lin')[1]/IMPLEMENTATION_CONFIG_VARIANT = 'VariantPreCompile'"!]
#define LIN_VARIANT_PRE_COMPILE (STD_ON)[!//
[!ELSE!]
#define LIN_VARIANT_POST_BUILD	(STD_ON)[!//
[!ENDIF!]

/**
 *  \name Lin Driver Configuration SW Version Info
 *
 *  Defines for LIN Driver configuration version
 *  @{
 */
/** \brief Lin configuration Major Version */
#define LIN_CFG_MAJOR_VERSION           ([!"substring-before($moduleSoftwareVer,'.')"!]U)
/** \brief Lin configuration Minor Version */
#define LIN_CFG_MINOR_VERSION           ([!"substring-before(substring-after($moduleSoftwareVer,'.'),'.')"!]U)
/** \brief Lin configuration Patch Version */
#define LIN_CFG_PATCH_VERSION           ([!"substring-after(substring-after($moduleSoftwareVer,'.'),'.')"!]U)
/* @} */

[!IF "as:modconf('Lin')[1]/IMPLEMENTATION_CONFIG_VARIANT = 'VariantPreCompile'"!]
/* brief Pointer to Lin Config Set to be used during Pre-Compile */
#define LIN_INIT_CONFIG_PC                   LinGlobalConfig
[!ENDIF!]

/**
 *  \name Can Driver Configuration SW Version Info
 *
 *  Pre-compile switches for enabling/disabling LIN MCAL APIs
 *  @{
 */

/* Enable/Disable DEV error detection */
#define LIN_DEV_ERROR_DETECT             [!IF "as:modconf('Lin')[1]/LinGeneral/LinDevErrorDetect = 'true'"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]
/* Enable/Disable Lin_GetVersionInfo().*/
#define LIN_GET_VERSION_INFO_API         [!IF "as:modconf('Lin')[1]/LinGeneral/LinVersionInfoApi = 'true'"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]
/* LIN Timeout Duration in cycles */
#define LIN_TIMEOUT_DURATION             ([!"as:modconf('Lin')[1]/LinGeneral/LinTimeoutDuration"!]U)

/* Lin Instance to Channel ID mapping */
[!LOOP "as:modconf('Lin')[1]/LinGlobalConfig/LinChannel/*"!][!//
#define [!"LinInstance"!]                    ([!"LinChannelId"!]U)
[!ENDLOOP!][!//

/* Lin Channel Symbolic Names */
[!LOOP "as:modconf('Lin')[1]/LinGlobalConfig/LinChannel/*"!][!//
#define LinConf_LinChannel_[!"@name"!]       ([!"LinChannelId"!]U)
[!ENDLOOP!][!//

/* Lin Channel Interrupt Line Selection */
#define LIN_INSTANCE_0_LINE_NUM_0
#define LIN_INSTANCE_1_LINE_NUM_0

/* Lin Channel ISR Type Selection */
[!LOOP "as:modconf('Lin')[1]/LinGlobalConfig/LinChannel/*"!][!//
#define [!"LinInstance"!]_ISR_TYPE           ([!"LinISRType"!])
[!ENDLOOP!][!//

/* Lin Instace Node type */
[!LOOP "as:modconf('Lin')[1]/LinGlobalConfig/LinChannel/*"!][!//
#define [!"LinInstance"!]_[!"LinNodeType"!]_NODE
[!ENDLOOP!][!//

/* Lin Available Nodes */
[!VAR "SLAVE_NODE" = "0"!][!//
[!VAR "MASTER_NODE" = "0"!][!//
[!LOOP "as:modconf('Lin')[1]/LinGlobalConfig/LinChannel/*"!][!//
[!IF "LinNodeType = 'MASTER'"!][!VAR "MASTER_NODE" = "1"!][!ENDIF!][!//
[!IF "LinNodeType = 'SLAVE'"!][!VAR "SLAVE_NODE" = "1"!][!ENDIF!][!//
[!ENDLOOP!][!//

[!IF "text:match($MASTER_NODE,'1')"!][!//
#define LIN_MASTER_NODE             (STD_ON)
[!ENDIF!][!//
[!IF "text:match($SLAVE_NODE,'1')"!][!//
#define LIN_SLAVE_NODE              (STD_ON)
[!ENDIF!][!//

/* Lin Channel ECUC Wakeup Source defines */
[!LOOP "as:modconf('Lin')[1]/LinGlobalConfig/LinChannel/*"!][!//
#define  LIN_WAKEUP_SOURCE_[!"LinChannelId"!]         ([!IF "not(node:empty(LinChannelEcuMWakeupSource))"!][!"node:ref(./LinChannelEcuMWakeupSource)/EcuMWakeupSourceId"!][!ELSE!]0[!ENDIF!])
[!ENDLOOP!][!//

/* Max number of channels defined */
#define LIN_MAX_CHANNEL                      ([!"num:i(count(as:modconf('Lin')[1]/LinGlobalConfig/LinChannel/*))"!]U)

/*********************************************************************************************************************
 * Exported Type Declarations
 *********************************************************************************************************************/

/*! @enum LIN Node Type */
typedef enum Lin_NodeTag
{
   MASTER,
   SLAVE
} Lin_NodeType;

/*! @enum LIN Loopback Mode Options Type */
typedef enum Lin_LoopbackModeTag
{
   LIN_LOOPBACK_DISABLED,
   LIN_LOOPBACK_INTERNAL,
   LIN_LOOPBACK_EXTERNAL
} Lin_LoopbackModeType;

/*! @enum LIN_OVERSAMPLING_RATE */
typedef enum {
    /*! Set oversampling rate to 16x */
    LIN_OVERSAMPLING_RATE_16X = 0,
    /*! Set oversampling rate to 8x */
    LIN_OVERSAMPLING_RATE_8X,
    /*! Set oversampling rate to 3x.
     * IrDA, Manchester and DALI are not supported when 3x oversampling is
     * enabled. */
    LIN_OVERSAMPLING_RATE_3X
} LIN_OVERSAMPLING_RATE;

/* Lin Controller Configuration definition */
typedef struct Lin_ControllerTag
{
   uint32 CntrAddr;                                /* Pointer to LinReg structure */
   Lin_LoopbackModeType LoopbackMode;              /* Loopback Mode for this controller */
   Lin_NodeType Nodetype;                          /* Lin Node Operation Type */
} Lin_ControllerType;

/* Lin Controller BaudRate Configuration */
typedef struct Lin_BaudrateConfigTag
{
   uint32 baudrate;
   LIN_OVERSAMPLING_RATE oversamplingRate;
   uint32 ibrd;
   uint32 fbrd;
   uint32 tBitWidth;
} Lin_BaudRateConfigType;

/*********************************************************************************************************************
 * Exported Object Declarations
 *********************************************************************************************************************/
/** \brief LIN Configuration struct declaration */
extern const struct Lin_ConfigTag LinGlobalConfig;

#ifdef __cplusplus
}
#endif

#endif /* LIN_CFG_H */
/*********************************************************************************************************************
 *  End of File: Lin_Cfg.h
 *********************************************************************************************************************/
