[!CODE!][!//
/**
*   @file    Spi_Cfg.h
*
*   @version 1.0.0
*
*   @brief   AUTOSAR Spi - Spi configuration header file.
*   @details This file is the header containing all the necessary information for SPI
*            module configuration(s).
*   @addtogroup [SPI_MODULE]
*   @{
*/
/*==================================================================================================
*   Project              : AUTOSAR 4.3 MCAL
*   Platform             : PA
*   Peripheral           : DSPI
*   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.
==================================================================================================*/
/*==================================================================================================
==================================================================================================*/
#ifndef SPI_CFG_H
#define SPI_CFG_H

#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 Spi_Cfg_h_REF_1
* Violates MISRA 2012 Advisory Rule 2.5, A project should not contain unused macro declarations.
* Macros that are used in the code only in some configuration.
*
*/

/*==================================================================================================
*                                        INCLUDE FILES
* 1) system and project includes
* 2) needed interfaces from external units
* 3) internal and external interfaces from this unit
* 4) user callback header files
==================================================================================================*/
[!LOOP "SpiGeneral/SpiUserCallbackHeaderFile/*"!][!//
[!IF "(node:value(.) != '')"!][!//
#include "[!"node:value(.)"!]"
[!ENDIF!][!//
[!ENDLOOP!][!//
[!NOCODE!][!//
[!INCLUDE "Spi_VersionCheck_Inc.m"!][!//
[!INCLUDE "Spi_RegOperations.m"!][!//
[!ENDNOCODE!][!//
/*==================================================================================================
*                              SOURCE FILE VERSION INFORMATION
==================================================================================================*/

#define SPI_MODULE_ID_CFG                       83
#define SPI_VENDOR_ID_CFG                       43
#define SPI_AR_RELEASE_MAJOR_VERSION_CFG        4
#define SPI_AR_RELEASE_MINOR_VERSION_CFG        3
#define SPI_AR_RELEASE_REVISION_VERSION_CFG     1
#define SPI_SW_MAJOR_VERSION_CFG                1
#define SPI_SW_MINOR_VERSION_CFG                0
#define SPI_SW_PATCH_VERSION_CFG                0

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

[!NOCODE!][!//
[!//Check repeat of Job, Seq, External device
[!CALL "Spi_CheckRepeatOfJobSeqExternalDevice"!]
[!//Check repeat of SpiPhyTxDmaChannel, SpiPhyTxDmaChannelAux, SpiPhyRxDmaChannel
[!CALL "Spi_CheckRepeatOfDmaChannels"!]
[!ENDNOCODE!][!//
/*==================================================================================================
*                                          CONSTANTS
==================================================================================================*/
[!NOCODE!][!//
[!CALL "Spi_CheckNumberOfSequenceJobChannel"!]
[!ENDNOCODE!][!//
/**
* @brief Switches the Development Error functionality ON or OFF.
* @details Switches the Development Error Detection and Notification ON or OFF.
* @implements SPI_DEV_ERROR_DETECT_define
*/
/*
* @violates @ref Spi_Cfg_h_REF_1 A project should not contain unused macro declarations.
* Macros that are used in the code only in some configuration. 
*/
#define SPI_DEV_ERROR_DETECT           ([!IF "SpiGeneral/SpiDevErrorDetect"!]STD_ON[!ELSE!]STD_OFF[!ENDIF!])

/**
* @brief Switches the Version Information API functionality ON or OFF.
* @details Switches the Spi_GetVersionInfo function ON or OFF.
*/
/*
* @violates @ref Spi_Cfg_h_REF_1 A project should not contain unused macro declarations.
* Macros that are used in the code only in some configuration. 
*/
#define SPI_VERSION_INFO_API           ([!IF "SpiGeneral/SpiVersionInfoApi"!]STD_ON[!ELSE!]STD_OFF[!ENDIF!])

/**
* @brief Switches the Interruptible Sequences handling functionality ON or OFF. 
* @details This parameter depends on SPI_LEVEL_DELIVERED value. 
*        It is only used for SPI_LEVEL_DELIVERED configured to 1 or 2.
* @implements SPI_INTERRUPTIBLE_SEQ_ALLOWED_define
*/
/*
* @violates @ref Spi_Cfg_h_REF_1 A project should not contain unused macro declarations.
* Macros that are used in the code only in some configuration. 
*/
#define SPI_INTERRUPTIBLE_SEQ_ALLOWED  ([!IF "SpiGeneral/SpiInterruptibleSeqAllowed"!]STD_ON[!ELSE!]STD_OFF[!ENDIF!])

/**
* @brief Switches the Spi_GetHWUnitStatus function ON or OFF.
* @details Switches the Spi_GetHWUnitStatus function ON or OFF.
* @implements SPI_HW_STATUS_API_define
*/
/*
* @violates @ref Spi_Cfg_h_REF_1 A project should not contain unused macro declarations.
* Macros that are used in the code only in some configuration. 
*/
#define SPI_HW_STATUS_API          ([!IF "SpiGeneral/SpiHwStatusApi"!]STD_ON[!ELSE!]STD_OFF[!ENDIF!])

/**
* @brief Switches the Spi_Cancel function ON or OFF.
* @details Switches the Spi_Cancel function ON or OFF. (see chapter 8.3.13)
* @implements SPI_CANCEL_API_define
*/
/*
* @violates @ref Spi_Cfg_h_REF_1 A project should not contain unused macro declarations.
* Macros that are used in the code only in some configuration. 
*/
#define SPI_CANCEL_API             ([!IF "SpiGeneral/SpiCancelApi"!]STD_ON[!ELSE!]STD_OFF[!ENDIF!])

/* Only Internal Buffers are allowed in Handler Driver.*/
/*
* @violates @ref Spi_Cfg_h_REF_1 A project should not contain unused macro declarations.
* Macros that are used in the code only in some configuration. 
*/
#define USAGE0                          0x00u

/* Only External Buffers are allowed in Handler Driver.*/
/*
* @violates @ref Spi_Cfg_h_REF_1 A project should not contain unused macro declarations.
* Macros that are used in the code only in some configuration. 
*/
#define USAGE1                          0x01u

/* Both Buffer types are allowd in Handler Driver. */
/*
* @violates @ref Spi_Cfg_h_REF_1 A project should not contain unused macro declarations.
* Macros that are used in the code only in some configuration. 
*/
#define USAGE2                          0x02u

/**
* @brief Selects the SPI Handler Driver Channel Buffers usage allowed and delivered.
* @details Selects the SPI Handler Driver Channel Buffers usage allowed and delivered.
*        (see chapter 7.2.1)
* @implements SPI_CHANNEL_BUFFERS_ALLOWED_define
*/
#define SPI_CHANNEL_BUFFERS_ALLOWED    (USAGE[!"SpiGeneral/SpiChannelBuffersAllowed"!])

/* The LEVEL 0 Simple Synchronous SPI Handler Driver functionalities are selected.*/
#define LEVEL0                          0x00u

/* The LEVEL 1 Basic Asynchronous SPI Handler Driver functionalities are selected.*/
#define LEVEL1                          0x01u

/* The LEVEL 2 Enhanced SPI Handler Driver functionalities are selected. */
#define LEVEL2                          0x02u

/**
* @brief Selects the SPI Handler Driver level of scalable functionality.
* @details Selects the SPI Handler Driver level of scalable functionality that 
* is available and delivered. (see chapter 7.1)
* @implements SPI_LEVEL_DELIVERED_define
*/
#define SPI_LEVEL_DELIVERED            (LEVEL[!"SpiGeneral/SpiLevelDelivered"!])

/** 
* @brief            Support for User mode.
*                   STD_ON: the Spi driver can be executed from both supervisor and user mode. 
*                   STD_OFF: the Spi driver can be executed only from supervisor mode. 
*/
#define SPI_ENABLE_USER_MODE_SUPPORT     ([!IF "SpiAutosarExt/SpiEnableUserModeSupport"!]STD_ON[!ELSE!]STD_OFF[!ENDIF!])


/**
* @brief Defines the maximum number of supported channels.
* @details Defines the maximum number of supported channels
*     for all the driver configurations.
*/
[!NOCODE!][!//
[!VAR "OuterLoopCounter" = "0"!][!//
[!VAR "InnerLoopCounter" = "0"!][!//
[!ENDNOCODE!][!//
[!LOOP "SpiDriver/SpiChannel/*"!][!//
[!CALL "Spi_CheckChannelAttributes"!][!//
[!IF "$Matchcounter = 1"!][!//
/*
* @violates @ref Spi_Cfg_h_REF_4 The compiler/linker shall be checked to
* ensure that 31 character signifiance and case sensitivity are supported for
* external identifiers.
*/
#define SpiConf_SpiChannel_[!"name(.)"!]    ((Spi_ChannelType)[!"SpiChannelId"!])
[!ENDIF!][!//
[!ENDLOOP!][!//
#define SPI_MAX_CHANNEL  ([!"num:i($SpiMaxChannelsCount)"!]u)

/**
* @brief Total number of Jobs configured.
* @details Defines the maximum number of supported jobs
*     for all the driver configurations.
*/
[!LOOP "SpiDriver/SpiJob/*"!][!//
/*
* @violates @ref Spi_Cfg_h_REF_1 A project should not contain unused macro declarations.
* Macros that are used in the code only in some configuration. 
*/
#define SpiConf_SpiJob_[!"name(.)"!]   ((Spi_JobType)[!"SpiJobId"!])
[!ENDLOOP!][!//
/*
* @violates @ref Spi_Cfg_h_REF_1 A project should not contain unused macro declarations.
* Macros that are used in the code only in some configuration. 
*/
#define SPI_MAX_JOB     ([!"num:i($SpiMaxJobsCount)"!]u)

/**
* @brief Total number of Sequences configured.
* @details Defines the maximum number of supported sequences
*     for all the driver configurations.
*/
[!LOOP "SpiDriver/SpiSequence/*"!][!//
/*
* @violates @ref Spi_Cfg_h_REF_1 A project should not contain unused macro declarations.
* Macros that are used in the code only in some configuration. 
*/
#define SpiConf_SpiSequence_[!"name(.)"!]   ((Spi_SequenceType)[!"SpiSequenceId"!])
[!ENDLOOP!][!//
/*
* @violates @ref Spi_Cfg_h_REF_1 A project should not contain unused macro declarations.
* Macros that are used in the code only in some configuration. 
*/
#define SPI_MAX_SEQUENCE  ([!"num:i($SpiMaxSequencesCount)"!]u)

[!IF "SpiGeneral/SpiOptimizeOneJobSequences"!][!//
[!//
/**
* @brief Define the size of sequence cached data buffer.
* @details Define the size of sequence cached data buffer for sequences having only one job.
*/
/*
* @violates @ref Spi_Cfg_h_REF_1 A project should not contain unused macro declarations.
* Macros that are used in the code only in some configuration. 
*/
#define SPI_OPTIMIZED_SEQ_BUFFER_SIZE ((Spi_SequenceType)[!//
[!IF "SpiGeneral/SpiOptimizedSeqNumber > 0"!][!//
[!"SpiGeneral/SpiOptimizedSeqNumber"!][!//
[!ELSE!][!//
[!"num:i($SpiMaxOneJobSequences)"!][!//
[!ENDIF!][!//
)

/**
* @brief Define the size of channel cached data buffer.
* @details Define the size of channel cached data buffer 
*    for sequences having only one job.
*/
/*
* @violates @ref Spi_Cfg_h_REF_1 A project should not contain unused macro declarations.
* Macros that are used in the code only in some configuration. 
*/
#define SPI_OPTIMIZED_CHANNEL_BUFFER_SIZE ((Spi_ChannelType)[!//
[!IF "SpiGeneral/SpiOptimizedChannelsNumber > 0"!][!//
[!"SpiGeneral/SpiOptimizedChannelsNumber"!][!//
[!ELSE!][!//
[!"num:i($SpiMaxOneJobSeqChannels)"!][!//
[!ENDIF!][!//
)
[!//
[!ENDIF!][!//

/**
* @brief Defines the peripherals used throughout the configuration(s).
* @details Defines the peripherals used throughout the configuration(s).
*/
[!LOOP "SpiGeneral/SpiPhyUnit/*"!][!//
/*
* @violates @ref Spi_Cfg_h_REF_1 A project should not contain unused macro declarations.
* Macros that are used in the code only in some configuration. 
*/
#define CSIB[!"@index"!]  ((uint8)[!"@index"!]u)
[!ENDLOOP!][!//
/*
* @violates @ref Spi_Cfg_h_REF_1 A project should not contain unused macro declarations.
* Macros that are used in the code only in some configuration. 
*/
#define SPI_MAX_HWUNIT   ([!"num:i(count(SpiGeneral/SpiPhyUnit/*))"!]u)

/**
* @brief Physical HWUnits definition - as from resource manager.
* @details Physical HWUnits definition - as from resource manager.
*/
[!VAR "DSPI_A_Counter" = "0"!][!//
[!VAR "DSPI_B_Counter" = "0"!][!//
[!VAR "DSPI_C_Counter" = "0"!][!//
[!VAR "DSPI_D_Counter" = "0"!][!//
[!VAR "DSPI_E_Counter" = "0"!][!//

[!VAR "DSPI_SLAVE_FLAG" = "0"!][!//
[!LOOP "SpiGeneral/SpiPhyUnit/*"!][!//
[!IF "SpiPhyUnitMapping = 'DSPI_A'"!][!//
[!VAR "DSPI_A_Counter" = "$DSPI_A_Counter + 1"!][!//
#define DSPI_A_HWUNIT   (CSIB[!"@index"!])
[!ENDIF!][!//
[!IF "SpiPhyUnitMapping = 'DSPI_B'"!][!//
[!VAR "DSPI_B_Counter" = "$DSPI_B_Counter + 1"!][!//
#define DSPI_B_HWUNIT   (CSIB[!"@index"!])
[!ENDIF!][!//
[!IF "SpiPhyUnitMapping = 'DSPI_C'"!][!//
[!VAR "DSPI_C_Counter" = "$DSPI_C_Counter + 1"!][!//
#define DSPI_C_HWUNIT   (CSIB[!"@index"!])
[!ENDIF!][!//
[!IF "SpiPhyUnitMapping = 'DSPI_D'"!][!//
[!VAR "DSPI_D_Counter" = "$DSPI_D_Counter + 1"!][!//
#define DSPI_D_HWUNIT   (CSIB[!"@index"!])
[!ENDIF!][!//
[!IF "SpiPhyUnitMapping = 'DSPI_E'"!][!//
[!VAR "DSPI_E_Counter" = "$DSPI_E_Counter + 1"!][!//
#define DSPI_E_HWUNIT   (CSIB[!"@index"!])
[!ENDIF!][!//
[!IF "SpiPhyUnitMode = 'SPI_SLAVE'"!][!//
[!VAR "DSPI_SLAVE_FLAG" = "1"!][!//
[!ENDIF!][!//
[!ENDLOOP!][!//

/**
* @brief Physical HWUnits enabled/disabled
* @details Physical HWUnits enabled/disabled
*/
#define DSPI_A_ENABLED  ([!IF "$DSPI_A_Counter = 1"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!])
#define DSPI_B_ENABLED  ([!IF "$DSPI_B_Counter = 1"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!])
#define DSPI_C_ENABLED  ([!IF "$DSPI_C_Counter = 1"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!])
#define DSPI_D_ENABLED  ([!IF "$DSPI_D_Counter = 1"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!])
#define DSPI_E_ENABLED  ([!IF "$DSPI_E_Counter = 1"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!])

#define SPI_SLAVE_SUPPORT  ([!IF "$DSPI_SLAVE_FLAG = 1"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!])

[!IF "$DSPI_A_Counter = 1"!][!//
#define DSPI_A_OFFSET  0u
[!ENDIF!][!//
[!IF "$DSPI_B_Counter = 1"!][!//
#define DSPI_B_OFFSET  1u
[!ENDIF!][!//
[!IF "$DSPI_C_Counter = 1"!][!//
#define DSPI_C_OFFSET  2u
[!ENDIF!][!//
[!IF "$DSPI_D_Counter = 1"!][!//
#define DSPI_D_OFFSET  3u
[!ENDIF!][!//
[!IF "$DSPI_E_Counter = 1"!][!//
#define DSPI_E_OFFSET  4u
[!ENDIF!][!//


#define SPI_FIFO_SIZE_DSPI   ((uint8)[!"ecu:get('SpiFifoSize')"!]u)

#define SPI_NUMBER_OF_UNITS   ((uint8)[!"ecu:get('SpiNumberOfUnits')"!]u)
/*
* @violates @ref Spi_Cfg_h_REF_1 A project should not contain unused macro declarations.
* Macros that are used in the code only in some configuration. 
*/
#define DSPI      0u

/**
* @brief Defines the external devices the driver will use.
* @details Reference to the external device used by this job.
*/
[!LOOP "SpiDriver/SpiExternalDevice/*"!][!//
/*
* @violates @ref Spi_Cfg_h_REF_4 The compiler/linker shall be checked to
* ensure that 31 character signifiance and case sensitivity are supported for
* external identifiers.
*/
#define SPI_[!"name(.)"!]  ((Spi_ExternalDeviceType)[!"@index"!]u)
[!ENDLOOP!][!//

[!NOCODE!]
[!VAR "SpiDemErrorEnable" = "'false'"!]
[!IF "SpiAutosarExt/SpiDisableDemReportErrorStatus ='false'"!][!//
    [!VAR "nconf" = "count(SpiDriver/*)"!]
    [!VAR "iconf" = "0"!]
    [!FOR "iconf" = "1" TO "$nconf"!]
        [!IF "node:exists(SpiDemEventParameterRefs)"!]
            [!VAR "SpiDemErrorEnable" = "'true'"!]
        [!ENDIF!]
    [!ENDFOR!]
[!ENDIF!]
[!ENDNOCODE!]
/**
* @brief   Switches the Production Error Detection and Notification OFF
*
* @implements SPI_DISABLE_DEM_REPORT_ERROR_STATUS_define
* 
*/
/*
* @violates @ref Spi_Cfg_h_REF_1 A project should not contain unused macro declarations.
* Macros that are used in the code only in some configuration. 
*/
#define SPI_DISABLE_DEM_REPORT_ERROR_STATUS   [!IF "$SpiDemErrorEnable"!](STD_OFF)  /* Enable Production Error Detection */[!ELSE!](STD_ON) /* Disable Production Error Detection */[!ENDIF!]


/*==================================================================================================
 *                                     DEFINES AND MACROS
==================================================================================================*/
/**
* @brief Define values for Autosar configuration variants.
* @details Define values for Autosar configuration variants.
*/
/*
* @violates @ref Spi_Cfg_h_REF_1 A project should not contain unused macro declarations.
* Macros that are used in the code only in some configuration. 
*/
#define SPI_VARIANT_PRECOMPILE  (0)
/*
* @violates @ref Spi_Cfg_h_REF_1 A project should not contain unused macro declarations.
* Macros that are used in the code only in some configuration. 
*/
#define SPI_VARIANT_POSTBUILD   (1)
/*
* @violates @ref Spi_Cfg_h_REF_1 A project should not contain unused macro declarations.
* Macros that are used in the code only in some configuration. 
*/
#define SPI_VARIANT_LINKTIME    (2)

[!IF "IMPLEMENTATION_CONFIG_VARIANT='VariantPreCompile'"!][!//
/**
* @brief Defines the use of Pre-Compile(PC) support
* @details VARIANT-PRE-COMPILE: Only parameters with "Pre-compile time" configu-ration are allowed 
*        in this variant.
*/
/* Pre-Compile(PC) Support. */
[!ELSEIF "IMPLEMENTATION_CONFIG_VARIANT='VariantPostBuild'"!][!//
/**
* @brief Defines the use of Post-Build(PB) support.
* @details VARIANT-POST-BUILD: Parameters with "Pre-compile time", 
*        "Link time" and "Post-build time" are allowed in this variant.
*/
/* Post-Build(PB) Support. */
[!ELSEIF "IMPLEMENTATION_CONFIG_VARIANT='VariantLinkTime'"!][!//
/**
* @brief Defines the use of Link-Time(L) support.
* @details VARIANT-LINK-TIME: Only parameters with "Pre-compile time" 
*        and "Link time" are allowed in this variant.
*/
/* Link Time Support. */
[!ENDIF!][!//

#define SPI_CONFIG_VARIANT      [!//
[!IF "IMPLEMENTATION_CONFIG_VARIANT='VariantPreCompile'"!][!//
(SPI_VARIANT_PRECOMPILE)
[!ELSEIF "IMPLEMENTATION_CONFIG_VARIANT='VariantPostBuild'"!][!//
(SPI_VARIANT_POSTBUILD)
[!ELSEIF "IMPLEMENTATION_CONFIG_VARIANT='VariantLinkTime'"!][!//
(SPI_VARIANT_LINKTIME)
[!ENDIF!][!//

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

/**
* @brief Define precompile support.
* @details Define precompile support if VariantPreCompile or VariantLinkTime is selected and number of variant <=1.
*/
/*
* @violates @ref Spi_Cfg_h_REF_1 A project should not contain unused macro declarations.
* Macros that are used in the code only in some configuration. 
*/
#define SPI_PRECOMPILE_SUPPORT  [!//
[!IF "(IMPLEMENTATION_CONFIG_VARIANT = 'VariantPreCompile' or IMPLEMENTATION_CONFIG_VARIANT='VariantLinkTime') and (variant:size() <= 1)"!][!//
    (STD_ON)
[!ELSE!][!//
    (STD_OFF)
[!ENDIF!][!//

/**
* @brief Defines if transfers are made using DMA or FIFO.
* @details Defines if transfers are made using DMA or FIFO.
* @implements SPI_DMA_USED_define
*/
#define SPI_DMA_USED [!//
[!IF "ecu:get('SpiDMAPresent') = 'TRUE' and SpiGeneral/SpiGlobalDmaEnable = 'true'"!][!//
    (STD_ON)
[!ELSE!][!//
    (STD_OFF)
[!ENDIF!][!//

/**
* @brief Defines if Spi driver optimization for sequences having only one job is activated or not.
* @details Defines if Spi driver optimization for sequences having only one job is activated or not.
*        If activated, additional RAM memory is required for internal data caching.
*/
#define SPI_OPTIMIZE_ONE_JOB_SEQUENCES ([!IF "SpiGeneral/SpiOptimizeOneJobSequences"!]STD_ON[!ELSE!]STD_OFF[!ENDIF!])

/**
* @brief Number of CPU clock cycles consumed by a wait loop during the wait for TX/RX transmission to complete one frame in Spi_SyncTransmit().
* @details This value is set to the minimum measure retrieved for GHS, DIAB and CW compilers,
*       with all optimizations activated.
*/
#define SPI_WAIT_LOOP_TICKS       23u

/**
* @brief Defines the "Number of Loops" timeout.
* @details Defines the "Number of Loops" timeout used by Spi_SyncTransmit and Spi_AsyncTransmit
*        function during the wait on TX/RX transmission to complete one frame.
*        One timeout unit means that no TX or RX was executed(the IF statements are returning FALSE).
*/
[!NOCODE!][!//
    [!SELECT "node:ref(SpiGeneral/SpiCPUClockRef)"!]
    [!VAR "CoreFrequency" = "McuClockReferencePointFrequency"!]
    [!ENDSELECT!]
    
[!ENDNOCODE!][!//
/*
* @violates @ref Spi_Cfg_h_REF_1 A project should not contain unused macro declarations.
* Macros that are used in the code only in some configuration. 
*/
#define SPI_TIMEOUT_COUNTER ((sint32)(([!"num:i(SpiGeneral/SpiTransmitTimeout* $CoreFrequency div 1000000)"!]u) / SPI_WAIT_LOOP_TICKS))

/**
* @brief Allow simultaneous calls to Spi_SyncTransmit() for different threads.
* @details Two concurrent calls to Spi_SyncTransmit() will be allowed only if the related sequences
*       do not share HW units.
*/
#define SPI_SUPPORT_CONCURRENT_SYNC_TRANSMIT    ([!IF "SpiGeneral/SpiSupportConcurrentSyncTransmit"!]STD_ON[!ELSE!]STD_OFF[!ENDIF!])

/*==================================================================================================
 *                                           Non AUTOSAR DEFINES
==================================================================================================*/
/**
* @brief If enabled, the asyncronous operation mode (POLLING or INTERRUPT)
* @details If enabled, the asyncronous operation mode (POLLING or INTERRUPT) can
*       be defined independently for each HWUnit using Spi_SetHWUnitAsyncMode().
* @implements SPI_HWUNIT_ASYNC_MODE_define
*/
#define SPI_HWUNIT_ASYNC_MODE [!//
[!IF "(SpiGeneral/SpiLevelDelivered = 2)"!][!//
 ([!IF "SpiAutosarExt/SpiEnableHWUnitAsyncMode"!]STD_ON[!ELSE!]STD_OFF[!ENDIF!])
[!ELSE!][!//
 (STD_OFF)
[!ENDIF!][!//

/**
* @brief If enabled, allows dual MCU clock configuration settings.
* @details If enabled, allows dual MCU clock configuration settings.
* @implements SPI_DUAL_CLOCK_MODE_define
*/
#define SPI_DUAL_CLOCK_MODE [!//
[!IF "(node:exists(SpiAutosarExt/SpiAlternateClockRef))"!][!//
 (STD_ON)
[!ELSE!][!//
 (STD_OFF)
[!ENDIF!][!//

/**
* @brief   Specifies if TSB implementation is supported
*/
[!IF "ecu:get('SpiTSBSupport') = 'TRUE'"!][!//
#define TSB_MODE_SUPPORTED
[!ELSE!][!//
[!ENDIF!][!//

/**
* @brief   Specifies if TSB feature/mode is available
*/
/*
* @violates @ref Spi_Cfg_h_REF_1 A project should not contain unused macro declarations.
* Macros that are used in the code only in some configuration. 
*/
#define SPI_TSB_MODE  [!//
[!IF "(node:value(SpiAutosarExt/SpiTSBModeSupport) = 'true')"!][!//
(STD_ON)
[!ELSE!][!//
(STD_OFF)
[!ENDIF!][!//

[!IF "(node:value(SpiAutosarExt/SpiTSBModeSupport) = 'true')"!][!//
[!VAR "TSBJobCount"="0"!][!//
[!LOOP "SpiDriver/SpiJob/*"!][!//
[!IF "(TSBModeEnable = 'true')"!][!//
[!VAR "TSBJobCount" = "$TSBJobCount +1"!] [!ENDIF!][!//
[!ENDLOOP!][!//
/*
* @violates @ref Spi_Cfg_h_REF_1 A project should not contain unused macro declarations.
* Macros that are used in the code only in some configuration. 
*/
#define SPI_MAX_TSBJOBS ([!"num:i($TSBJobCount)"!]u)
[!ENDIF!][!//

/**
* @brief If enabled, allows to configure more than 256 sequences, jobs and channels.
*/
/*
* @violates @ref Spi_Cfg_h_REF_1 A project should not contain unused macro declarations.
* Macros that are used in the code only in some configuration. 
*/
#define SPI_ALLOW_BIGSIZE_COLLECTIONS  [!//
[!IF "(node:value(SpiAutosarExt/SpiAllowBigSizeCollections) = 'true')"!][!//
(STD_ON)
[!ELSE!][!//
(STD_OFF)
[!ENDIF!][!//

/**
* @brief If enabled, SpiDataType is declared as uint8 instead of uint16.
*/
/*
* @violates @ref Spi_Cfg_h_REF_1 A project should not contain unused macro declarations.
* Macros that are used in the code only in some configuration. 
*/
#define SPI_DATA_WIDTH_8  0u
/*
* @violates @ref Spi_Cfg_h_REF_1 A project should not contain unused macro declarations.
* Macros that are used in the code only in some configuration. 
*/
#define SPI_DATA_WIDTH_16 1u

/**
* @brief Spi data buffer element (Spi_DataBufferType) is always declared as uint8 on ASR4.2.1  
*/
/*
* @violates @ref Spi_Cfg_h_REF_1 A project should not contain unused macro declarations.
* Macros that are used in the code only in some configuration. 
*/
#define SPI_FORCE_DATA_TYPE (STD_ON)

/**
* @brief If enabled, SPI_MAIN_FUNCTION_PERIOD defines the cycle time of the function Spi_MainFunction_Handling in seconds
*/
/*
* @violates @ref Spi_Cfg_h_REF_1 A project should not contain unused macro declarations.
* Macros that are used in the code only in some configuration. 
*/
[!IF " node:exists(SpiGeneral/SpiMainFunctionPeriod)"!][!//
#define SPI_MAIN_FUNCTION_PERIOD            ([!"num:f(SpiGeneral/SpiMainFunctionPeriod)"!])
[!ENDIF!][!//


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


/*==================================================================================================
*                               STRUCTURES AND OTHER TYPEDEFS
==================================================================================================*/


/*==================================================================================================
*                                GLOBAL VARIABLE DECLARATIONS
==================================================================================================*/


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


#ifdef __cplusplus
}
#endif

#endif /*SPI_CFG_H*/

/** @} */
[!ENDCODE!][!//
