/**********************************************************************************************************************
 *  COPYRIGHT
 *  -------------------------------------------------------------------------------------------------------------------
 *  \verbatim
 *                 TEXAS INSTRUMENTS INCORPORATED PROPRIETARY INFORMATION
 *
 *                 Property of Texas Instruments, Unauthorized reproduction and/or distribution
 *                 is strictly prohibited.  This product  is  protected  under  copyright  law
 *                 and  trade  secret law as an  unpublished work.
 *                 (C) Copyright Texas Instruments - 2011.  All rights reserved.
 *
 *  \endverbatim
 *  -------------------------------------------------------------------------------------------------------------------
 *  FILE DESCRIPTION
 *  -------------------------------------------------------------------------------------------------------------------
 *         File:  Spi_PBCfg.c
 *      Project:  --
 *       Module:  SpiDriver PostBuild Configuration Source File Spi_PBCfg.c
 *    Generator:  Elektrobit Tresos
 *
 *  Description:  This file is generated by EB Tresos.Do not modify this file, otherwise the software may 
 *                behave in unexpected way.
 *---------------------------------------------------------------------------------------------------------------------
 * Author:  Prathap Srinivasan
 *---------------------------------------------------------------------------------------------------------------------
 * Template Revision History
 *---------------------------------------------------------------------------------------------------------------------
 * Version        Date         Author               Change ID        Description
 *---------------------------------------------------------------------------------------------------------------------
 * 02.10.00       24Jan2013    Prathap Srinivasan  0000000000000    Initial Version adapted for TMS570LS1227
 * 02.20.00       08Aug2013    Enrique Lizarraga   SDOCM00103201    -SpiCsPolarity and SpiShiftClockIdleLevel were 
 *                                                                   inverted.
 *                                                                  -Use SpiDefaultData configuration parameter instead
 *                                                                   of hard coded value.
 *                                                                  -Corrected line indentation.
 *                                                                  -Corrected error if SpiCsIdleTime is set to 0.
 *                                                                  -SpiShiftClockIdleLevel was used incorrectly to
 *                                                                   select SPI Mode.
 *                                                                  -Update version info
 *                                                                  -Added traceability tags
 *                                                                  -Added protection to avoid selecting invalid CS
 *                                                                   pins in SPI2 and SPI4 HW Units
 * 02.21.00       30Sep2014    Enrique Lizarraga   SDOCM00112317    -Update version info
 *                                                                  -Traceability tags
 * 02.21.01       29Feb2016    Enrique Lizarraga   SDOCM00121246    -Update version info
 *                                                                  -Change SpiDataWidth type from enum to int
 *                                                                  -Change SpiCsIdentifier type from enum to string
 * 02.22.00       18Jul2016    Prathap Srinivasan  SDOCM00122408    -Update version info
 * 02.22.01       10Aug2016    Prathap Srinivasan  SDOCM00122593    -Bug Fix: Spi_IrqTxRxERR function checks for
 *                                                                   wrong error status bit
 * 02.22.02       23Aug2016    Vishwanath Reddy    SDOCM00121246    -Update version info
 * 02.22.03       26Sep2016    Prathap Srinivasan  SDOCM00122695    -Update version info
 *                                                                   Add code to get EXTERNAL NOTIFICATION PROTOTYPES.
 * 02.30.00       01Dec2016    Sudhakar Singh         None          -Update version info
 * 05.30.00       15Mar2017    Sudhakar Singh      SDOCM00122834    Version supports TMS570LSxx Family of Devices.
 *
 *********************************************************************************************************************/

 /**********************************************************************************************************************
    Project: [!"$project"!]
	Date   : [!"$datetime"!] 
	
    This file is generated by EB Tresos 
    Do not modify this file, otherwise the software may behave in unexpected way.
    
 *********************************************************************************************************************/


#define SPI_PBCFG_SOURCE 1

/**********************************************************************************************************************
 *  INCLUDES
 *********************************************************************************************************************/
/* SourceId : SPI_SourceId_038 */
/* DesignId : SPI_DesignId_019 */
/* Requirements : AR_SPI_SR13 */
#include "Spi.h"
#include "Spi_Hw.h"

/**********************************************************************************************************************
 *  VERSION CHECK
 *********************************************************************************************************************/
#define SPI_CFG_C_MAJOR_VERSION               (5U)
#define SPI_CFG_C_MINOR_VERSION               (30U)
#define SPI_CFG_C_PATCH_VERSION               (0U)

#if (  (SPI_CFG_MAJOR_VERSION != SPI_CFG_C_MAJOR_VERSION) \
    || (SPI_CFG_MINOR_VERSION != SPI_CFG_C_MINOR_VERSION) \
	|| (SPI_CFG_PATCH_VERSION != SPI_CFG_C_PATCH_VERSION))
#error "Version numbers of Spi_PbCfg.c and Spi_Cfg.h are inconsistent!"
#endif

/**********************************************************************************************************************
 *  LOCAL CONSTANT MACROS
 **********************************************************************************************************************/

/**********************************************************************************************************************
 *  LOCAL FUNCTION MACROS
 **********************************************************************************************************************/

/**********************************************************************************************************************
 *  LOCAL DATA TYPES AND STRUCTURES
 **********************************************************************************************************************/

/**********************************************************************************************************************
 *  LOCAL DATA PROTOTYPES
 **********************************************************************************************************************/

 /**********************************************************************************************************************
 *  EXTERNAL NOTIFICATION PROTOTYPES
 **********************************************************************************************************************/

[!LOOP "as:modconf('Spi')[1]/SpiDriver/*[1]/SpiJob/*"!][!IF "SpiJobEndNotification = 'NULL_PTR'"!][!ELSE!]extern [!"SpiJobEndNotification"!]();[!CR!][!ENDIF!][!IF "not(node:islast())"!][!ENDIF!][!ENDLOOP!][!LOOP "as:modconf('Spi')[1]/SpiDriver/*[1]/SpiSequence/*"!][!IF "SpiSeqEndNotification = 'NULL_PTR'"!][!ELSE!]extern [!"SpiSeqEndNotification"!]();[!CR!][!ENDIF!][!IF "not(node:islast())"!][!ENDIF!][!ENDLOOP!]	

/**********************************************************************************************************************
 *  GLOBAL DATA
 **********************************************************************************************************************/
/* SourceId : SPI_SourceId_039 */
/* DesignId : SPI_DesignId_019 */
/* Requirements : AR_SPI_SR14 */
#define SPI_START_SEC_VAR_INIT_UNSPECIFIED
/*SAFETYMCUSW 338 S MR:19.1 <APPROVED> "Based on Autosar Memory Map strategy" */
#include "MemMap.h"

/* internal buffer descriptor */
/*<T_SPI_BUFFER_DEF/>*/ 
static VAR(Spi_BufferDescriptorType, SPI_VAR_INIT) Spi_Buffer[] =
{
[!LOOP "as:modconf('Spi')[1]/SpiDriver/*[1]/SpiChannel/*"!]    {[!CR!]        NULL_PTR,[!CR!]        NULL_PTR,[!CR!]        0U[!CR!]    }[!IF "not(node:islast())"!],[!CR!][!ENDIF!][!ENDLOOP!]
};


#define SPI_STOP_SEC_VAR_INIT_UNSPECIFIED
/*SAFETYMCUSW 338 S MR:19.1 <APPROVED> "Based on Autosar Memory Map strategy" */
#include "MemMap.h"

#define SPI_START_SEC_VAR_ZERO_INIT_UNSPECIFIED
/*SAFETYMCUSW 338 S MR:19.1 <APPROVED> "Based on Autosar Memory Map strategy" */
#include "MemMap.h"
/* job priority conversion table */
/*<T_SPI_JOB_PRIO_TBL_OPEN/>*/ 
VAR(uint8, SPI_VAR_ZERO_INIT) Spi_JobPrioConvTbl_at[] = 
{
/*<T_SPI_JOB_PRIO_TBL_DEF>*/
[!LOOP "as:modconf('Spi')[1]/SpiDriver/*[1]/SpiJob/*"!]    0U[!IF "not(node:islast())"!],[!CR!][!ENDIF!][!ENDLOOP!]
/*</T_SPI_JOB_PRIO_TBL_DEF>*/
/*<T_SPI_JOB_PRIO_TBL_CLOSE/>*/ 
};

/* Job priority queue */
/*<T_SPI_JOB_SORTED_DEF>*/
VAR(Spi_JobSortedType, SPI_VAR_ZERO_INIT) Spi_JobsSorted_at[] =
{
[!LOOP "as:modconf('Spi')[1]/SpiDriver/*[1]/SpiJob/*"!]    {[!CR!]        NULL_PTR, 0U, 0U, 0U[!CR!]    }[!IF "not(node:islast())"!],[!CR!][!ENDIF!][!ENDLOOP!]
};
/*</T_SPI_JOB_SORTED_DEF>*/

/* event queue */
/*<T_SPI_SEQ_EVENT_DEF>*/
VAR(Spi_HwEventType, SPI_VAR_ZERO_INIT) Spi_HwSeqEvent_at[] =
{
[!LOOP "as:modconf('Spi')[1]/SpiDriver/*[1]/SpiSequence/*"!]    {[!CR!]        NULL_PTR, NULL_PTR, 0U, 0U, 0U[!CR!]    }[!IF "not(node:islast())"!],[!CR!][!ENDIF!][!ENDLOOP!]
};
/*</T_SPI_SEQ_EVENT_DEF>*/

/* SourceId : SPI_SourceId_055 */
/* DesignId : SPI_DesignId_020 */
/* Requirements : AR_SPI_SR144 */
/* job status array */
/*<T_SPI_JOB_STATUS_OPEN/>*/ 
static VAR(Spi_JobResultType, SPI_VAR_ZERO_INIT) Spi_JobStatus_at[] = 
{
    /*<T_SPI_JOB_STATUS_DEF>*/
[!LOOP "as:modconf('Spi')[1]/SpiDriver/*[1]/SpiJob/*"!]    SPI_JOB_OK[!IF "not(node:islast())"!],[!CR!][!ENDIF!][!ENDLOOP!]
/*</T_SPI_JOB_STATUS_DEF>*/
/*<T_SPI_JOB_STATUS_CLOSE/>*/ 
};

/* SourceId : SPI_SourceId_054 */
/* DesignId : SPI_DesignId_020 */
/* Requirements : AR_SPI_SR149 */
/* sequence status array */
/*<T_SPI_SEQ_STATUS_OPEN/>*/ 
static VAR(Spi_SeqResultType, SPI_VAR_ZERO_INIT) Spi_SequenceStatus_at[] = 
{
    /*<T_SPI_SEQ_STATUS_DEF>*/
[!LOOP "as:modconf('Spi')[1]/SpiDriver/*[1]/SpiSequence/*"!]    SPI_SEQ_OK[!IF "not(node:islast())"!],[!CR!][!ENDIF!][!ENDLOOP!]
/*</T_SPI_SEQ_STATUS_DEF>*/
/*<T_SPI_SEQ_STATUS_CLOSE/>*/ 
};

/* dlc status array */
/*<T_SPI_DLC_STATUS_OPEN/>*/ 
static VAR(Spi_HwUnitResultType, SPI_VAR_ZERO_INIT) Spi_DlcStatus_at[] = 
{
    /*<T_SPI_DLC_STATUS_DEF>*/
[!LOOP "as:modconf('Spi')[1]/SpiDriver/*[1]/SpiHardwareUnit/*"!]    SPI_DLC_OK[!IF "not(node:islast())"!],[!CR!][!ENDIF!][!ENDLOOP!]
/*</T_SPI_DLC_STATUS_DEF>*/
/*<T_SPI_DLC_STATUS_CLOSE/>*/ 
};

#define SPI_STOP_SEC_VAR_ZERO_INIT_UNSPECIFIED
/*SAFETYMCUSW 338 S MR:19.1 <APPROVED> "Based on Autosar Memory Map strategy" */
#include "MemMap.h"

#define SPI_START_SEC_CONST_UNSPECIFIED
/*SAFETYMCUSW 338 S MR:19.1 <APPROVED> "Based on Autosar Memory Map strategy" */
#include "MemMap.h"
/* Hardware unit array */
/*<T_SPI_HW_UNIT_OPEN/>*/ 
CONST(Spi_RegisterPtrType, SPI_CONST) Spi_HWUnit_at[] = 
{
    /*<T_SPI_HW_UNIT_DEF>*/
[!LOOP "as:modconf('Spi')[1]/SpiDriver/*[1]/SpiHardwareUnit/*"!]    (Spi_RegisterPtrType) [!IF "SpiUnitEnable = 'false'"!]NULL_PTR[!ELSE!]SPI_REGISTER_BASE_[!"SpiUnitId"!][!ENDIF!][!IF "not(node:islast())"!],[!CR!][!ENDIF!][!ENDLOOP!]
/*</T_SPI_HW_UNIT_DEF>*/
/*<T_SPI_HW_UNIT_CLOSE/>*/ 
};

/* Spi RAM Hardware array */
/*<T_SPI_RAM_UNIT_OPEN/>*/ 
CONST(Spi_RamBufferPtrType, SPI_CONST) Spi_RamUnit_at[] = 
{
    /*<T_SPI_RAM_UNIT_DEF>*/
[!LOOP "as:modconf('Spi')[1]/SpiDriver/*[1]/SpiHardwareUnit/*"!]    (Spi_RamBufferPtrType) [!IF "SpiUnitHasRam = 'true'"!]SPI_RAM_BASE_[!"SpiUnitId"!][!ELSE!]NULL_PTR[!ENDIF!][!IF "not(node:islast())"!],[!CR!][!ENDIF!][!ENDLOOP!]
/*</T_SPI_RAM_UNIT_DEF>*/
/*<T_SPI_RAM_UNIT_CLOSE/>*/ 
};

/*<T_SPI_UNIT_PROPERTY_OPEN/>*/ 
CONST(Spi_HWUnitPropertyType, SPI_CONST) Spi_UnitProperty_at[] = 
{
    /*<T_SPI_UNIT_PROPERTY_DEF>*/
[!LOOP "as:modconf('Spi')[1]/SpiDriver/*[1]/SpiHardwareUnit/*"!]    {[!IF "SpiUnitHasRam = 'true'"!]1U[!ELSE!]0U[!ENDIF!], [!IF "SpiUnitUsesDma = 'true'"!]1U[!ELSE!]0U[!ENDIF!], [!"SpiUnitId"!]U}[!IF "not(node:islast())"!],[!CR!][!ENDIF!][!ENDLOOP!]
/*</T_SPI_UNIT_PROPERTY_DEF>*/
/*<T_SPI_UNIT_PROPERTY_CLOSE/>*/ 
};

#define SPI_STOP_SEC_CONST_UNSPECIFIED
/*SAFETYMCUSW 338 S MR:19.1 <APPROVED> "Based on Autosar Memory Map strategy" */
#include "MemMap.h"


#define SPI_START_SEC_VAR_INIT_UNSPECIFIED
/*SAFETYMCUSW 338 S MR:19.1 <APPROVED> "Based on Autosar Memory Map strategy" */
#include "MemMap.h"

/* global status array */
/*<T_SPI_GLOBAL_STATUS_DEF>*/
static VAR(Spi_ResultType, SPI_VAR_INIT) Spi_GlobalStatus_at =
{
    Spi_JobStatus_at,
    Spi_SequenceStatus_at,
    Spi_DlcStatus_at
};
/*</T_SPI_GLOBAL_STATUS_DEF>*/

#define SPI_STOP_SEC_VAR_INIT_UNSPECIFIED
/*SAFETYMCUSW 338 S MR:19.1 <APPROVED> "Based on Autosar Memory Map strategy" */
#include "MemMap.h"

#define SPI_START_SEC_PBCFG
/*SAFETYMCUSW 338 S MR:19.1 <APPROVED> "Based on Autosar Memory Map strategy" */
#include "MemMap.h"


/* generation of channel assignment */
/* SourceId : SPI_SourceId_040 */
/* DesignId : SPI_DesignId_016 */
/* Requirements : AR_SPI_SR26, AR_SPI_SR28 */
/* the structure format is: { Number of channels assigned to a job, channelx .. channely } */
/*<T_SPI_JOB_TO_CHANNEL_ASSIGNMENT>*/
[!LOOP "as:modconf('Spi')[1]/SpiDriver/*[1]/SpiJob/*"!]static CONST(Spi_ChannelType, SPI_PBCFG) SpiChannelsToJob[!"@index"!]_Assignment_at[] =[!CR!]
{    
    /* Number of Channels in Job */
    [!"num:dectoint(count(./SpiChannelList/*))"!]U,
    /* Channels in Job */
[!LOOP "SpiChannelList/*"!]    Spi_[!"substring-after(substring-after(substring-after(substring-after(SpiChannelAssignment/.,'/'),'/'),'/'),'/')"!][!IF "not(node:islast())"!],[!CR!][!ENDIF!][!ENDLOOP!]
};[!CR!][!ENDLOOP!]
/*</T_SPI_JOB_TO_CHANNEL_ASSIGNMENT>*/

/* generation of job assignment to sequences */
/* the structure format is: { Number of jobs assigned to a sequence, jobx .. joby } */

/* SourceId : SPI_SourceId_041 */
/* DesignId : SPI_DesignId_016 */
/* Requirements : AR_SPI_SR29, AR_SPI_SR30 */
/*<T_SPI_SEQ_TO_JOB_ASSIGNMENT>*/
[!LOOP "as:modconf('Spi')[1]/SpiDriver/*[1]/SpiSequence/*"!]static CONST(Spi_JobType, SPI_PBCFG) SpiJobsToSeq[!"@index"!]_Assignment_at[] =
{
   /* SPI Hardware Instance */
  [!LOOP "SpiJobAssignment/*"!][!VAR "Var1"!]../../../../SpiJob/[!"substring-after(substring-after(substring-after(substring-after(.,'/'),'/'),'/'),'/')"!]/SpiDeviceAssignment[!ENDVAR!][!VAR "Var2"!]../../../../SpiExternalDevice/[!"substring-after(substring-after(substring-after(substring-after(node:value($Var1),'/'),'/'),'/'),'/')"!]/SpiHwUnit[!ENDVAR!][!BREAK!][!ENDLOOP!][!LOOP "SpiJobAssignment/*"!][!VAR "Var5"!]../../../../SpiJob/[!"substring-after(substring-after(substring-after(substring-after(.,'/'),'/'),'/'),'/')"!]/SpiDeviceAssignment[!ENDVAR!][!VAR "Var3"!]../../../../SpiExternalDevice/[!"substring-after(substring-after(substring-after(substring-after(node:value($Var5),'/'),'/'),'/'),'/')"!]/SpiHwUnit[!ENDVAR!][!IF "node:value($Var3) != node:value($Var2)"!][!ERROR "Sequence contain Jobs that belong to different Instance of SPI in the microcontroller. In a Sequence select only Jobs that uses same Instance of SPI"!][!ENDIF!][!VAR "Var4"!][!"node:value($Var2)"!][!ENDVAR!][!ENDLOOP!][!IF "$Var4 = 'CSIB0'"!][!WS "2"!]0U[!ELSEIF "$Var4 = 'CSIB1'"!][!WS "2"!]1U[!ELSEIF "$Var4 = 'CSIB2'"!][!WS "2"!]2U[!ELSEIF "$Var4 = 'CSIB3'"!][!WS "2"!]3U[!ELSE!][!WS "2"!]4U[!ENDIF!]
   /* Number of Jobs in Sequence */
   ,[!"num:dectoint(count(./SpiJobAssignment/*))"!]U
   /* Jobs in Sequence */
[!VAR "i"!][!ENDVAR!][!FOR "i" = "3" TO "0" STEP "-1"!][!LOOP "SpiJobAssignment/*"!][!VAR "Var6"!]../../../../SpiJob/[!"substring-after(substring-after(substring-after(substring-after(.,'/'),'/'),'/'),'/')"!]/SpiJobPriority[!ENDVAR!][!VAR "Var7"!][!"substring-after(substring-after(substring-after(substring-after(.,'/'),'/'),'/'),'/')"!][!ENDVAR!][!IF "node:value($Var6) = $i"!]   ,Spi_[!"$Var7"!][!CR!][!ENDIF!][!ENDLOOP!][!ENDFOR!]};[!CR!][!ENDLOOP!]
/*</T_SPI_SEQ_TO_JOB_ASSIGNMENT>*/

/* generated settings for external device container */
/* SourceId : SPI_SourceId_042 */
/* DesignId : SPI_DesignId_016 */
/* Requirements : AR_SPI_SR23 */
/*<T_SPI_EXTERNALDEVICE_CONTAINER_OPEN/>*/ 
static CONST(Spi_ExternalDeviceConfigType, SPI_PBCFG) Spi_ExternalDeviceConfig_at[] = 
{
    /*<T_SPI_EXTERNALDEVICE_CONTAINER_DEF>*/
[!LOOP "as:modconf('Spi')[1]/SpiDriver/*[1]/SpiExternalDevice/*"!]    {[!IF "SpiCsIdentifier != 'SCS0'"!][!IF "SpiCsIdentifier != 'SCS1'"!][!IF "SpiCsIdentifier != 'SCS2'"!][!IF "SpiCsIdentifier != 'SCS3'"!][!ERROR "Invalid CS identifier selected."!][!ENDIF!][!ENDIF!][!ENDIF!][!ENDIF!][!IF "SpiHwUnit = 'CSIB3'"!][!IF "SpiCsIdentifier != 'SCS0'"!][!ERROR "Invalid CS identifier selected for CSIB3"!][!ENDIF!][!ELSEIF "SpiHwUnit = 'CSIB1'"!][!IF "SpiCsIdentifier != 'SCS0'"!][!IF "SpiCsIdentifier != 'SCS1'"!][!ERROR "Invalid CS identifier selected for CSIB1"!][!ENDIF!][!ENDIF!][!ENDIF!]
        SPI_[!"SpiCsIdentifier"!],
        [!IF "SpiCsPolarity = 'HIGH'"!]1U,[!ELSE!]0U,[!ENDIF!]
        [!"num:inttohex( as:modconf('Spi')[1]/SpiDriver/*[1]/SpiClockFrequency * 1000 div SpiBaudrate - 1 )"!]U,
        [!IF "SpiShiftClockIdleLevel = 'LOW'"!][!IF "SpiDataShiftEdge = 'LEADING'"!]0U,[!ELSE!]1U,[!ENDIF!][!ELSE!][!IF "SpiDataShiftEdge = 'LEADING'"!]2U,[!ELSE!]3U,[!ENDIF!][!ENDIF!]
        [!VAR "Var1"!][!IF "num:dectoint(as:modconf('Spi')[1]/SpiDriver/*[1]/SpiClockFrequency * SpiTimeClk2Cs * 1000000 - 1) > 255 "!]255U [!ELSEIF "num:dectoint(as:modconf('Spi')[1]/SpiDriver/*[1]/SpiClockFrequency * SpiTimeClk2Cs * 1000000 - 1) < 0 "!]0U [!ELSE!][!"(num:dectoint(as:modconf('Spi')[1]/SpiDriver/*[1]/SpiClockFrequency * SpiTimeClk2Cs * 1000000 - 1))"!][!ENDIF!][!ENDVAR!][!VAR "Var2"!][!IF "num:dectoint(as:modconf('Spi')[1]/SpiDriver/*[1]/SpiClockFrequency * SpiTimeCs2Clk * 1000000 - 2) > 255 "!]255U [!ELSEIF "num:dectoint(as:modconf('Spi')[1]/SpiDriver/*[1]/SpiClockFrequency * SpiTimeCs2Clk * 1000000 - 2) < 0 "!]0U [!ELSE!][!"(num:dectoint(as:modconf('Spi')[1]/SpiDriver/*[1]/SpiClockFrequency * SpiTimeCs2Clk * 1000000 - 2))"!][!ENDIF!][!ENDVAR!]{[!"num:inttohex(bit:or(bit:shl($Var2,8),$Var1))"!]U, 0x0000U },
        [!IF "num:dectoint( SpiCsIdleTime * as:modconf('Spi')[1]/SpiDriver/*[1]/SpiClockFrequency * 1000000) < 2 "!]0x00U,[!ELSEIF "num:dectoint( SpiCsIdleTime * as:modconf('Spi')[1]/SpiDriver/*[1]/SpiClockFrequency * 1000000 - 2) > 63 "!]0x3FU,[!ELSE!][!"num:inttohex (num:dectoint( SpiCsIdleTime * as:modconf('Spi')[1]/SpiDriver/*[1]/SpiClockFrequency * 1000000 - 2))"!]U,[!ENDIF!]
        SPI_[!"SpiCsMode"!],
        [!IF "SpiHwUnit = 'CSIB0'"!]0U[!ELSEIF "SpiHwUnit = 'CSIB1'"!]1U[!ELSEIF "SpiHwUnit = 'CSIB2'"!]2U[!ELSEIF "SpiHwUnit = 'CSIB3'"!]3U[!ELSE!]4U[!ENDIF!][!CR!]    }[!IF "not(node:islast())"!],[!CR!][!ENDIF!][!ENDLOOP!]
 /*</T_SPI_EXTERNALDEVICE_CONTAINER_DEF>*/
/*<T_SPI_EXTERNALDEVICE_CONTAINER_CLOSE/>*/ 
};

/* generated settings for channel container */
/* SourceId : SPI_SourceId_043 */
/* DesignId : SPI_DesignId_016 */
/* Requirements : AR_SPI_SR27 */
/*<T_SPI_CHANNEL_CONTAINER_OPEN/>*/ 
static CONST(Spi_ChannelConfigType, SPI_PBCFG) Spi_ChannelConfig_at[] = 
{
    /*<T_SPI_CHANNEL_CONTAINER_DEF>*/
[!LOOP "as:modconf('Spi')[1]/SpiDriver/*[1]/SpiChannel/*"!]
    {
        &Spi_Buffer[[!"@index"!]],
        [!"SpiChannelId"!]U,
        SPI_[!"SpiChannelType"!],
        [!IF "SpiDataWidth = 8"!]8U,[!ELSEIF "SpiDataWidth = 16"!]16U,[!ELSEIF "SpiDataWidth = 32"!]32U,[!ELSE!][!ERROR "Invalid SpiDataWidth value selected"!][!ENDIF!]
        [!"SpiDefaultData"!]U,
        [!"SpiEbMaxLength"!]U,
        SPI_[!"SpiTransferStart"!]
    }[!IF "not(node:islast())"!],[!CR!][!ENDIF!][!ENDLOOP!]	
/*</T_SPI_CHANNEL_CONTAINER_DEF>*/
/*<T_SPI_CHANNEL_CONTAINER_CLOSE/>*/ 
};


/* generated settings for job container */
/*<T_SPI_JOB_CONTAINER_OPEN/>*/ 
static CONST(Spi_JobConfigType, SPI_PBCFG) Spi_JobsSettings_at[] = 
{
    /*<T_SPI_JOB_CONTAINER_DEF>*/
[!LOOP "as:modconf('Spi')[1]/SpiDriver/*[1]/SpiJob/*"!]
    {
        [!"SpiJobEndNotification"!],
        SpiChannelsToJob[!"@index"!]_Assignment_at,
        Spi_[!"substring-after(substring-after(substring-after(substring-after(SpiDeviceAssignment,'/'),'/'),'/'),'/')"!],
        [!"SpiJobId"!]U,
        [!"SpiJobPriority"!]U,
        [!VAR "Var1"!] ../../SpiExternalDevice/[!"substring-after(substring-after(substring-after(substring-after(SpiDeviceAssignment,'/'),'/'),'/'),'/')"!]/SpiHwUnit [!ENDVAR!][!IF "node:value($Var1) = 'CSIB0'"!]0U[!ELSEIF "node:value($Var1) = 'CSIB1'"!]1U[!ELSEIF "node:value($Var1) = 'CSIB2'"!]2U[!ELSEIF "node:value($Var1) = 'CSIB3'"!]3U[!ELSE!]4U[!ENDIF!]
    }[!IF "not(node:islast())"!],[!CR!][!ENDIF!][!ENDLOOP!]	
/*</T_SPI_JOB_CONTAINER_DEF>*/
/*<T_SPI_JOB_CONTAINER_CLOSE/>*/ 
};


/* generation of sequence container          */

/* generated settings for sequence container */
/*<T_SPI_SEQUENCE_CONTAINER_DEF>*/
static CONST(Spi_SequenceConfigType, SPI_PBCFG) Spi_SequenceSettings_at[] =
{
[!LOOP "as:modconf('Spi')[1]/SpiDriver/*[1]/SpiSequence/*"!]
    {
        [!"SpiSeqEndNotification"!],
        SpiJobsToSeq[!"@index"!]_Assignment_at,
        [!"SpiSequenceId"!]U,
        [!"text:toupper(SpiInterruptibleSequence)"!]
    }[!IF "not(node:islast())"!],[!CR!][!ENDIF!][!ENDLOOP!]	
};
/*</T_SPI_SEQUENCE_CONTAINER_DEF>*/

#define  SPI_STOP_SEC_PBCFG
/*SAFETYMCUSW 338 S MR:19.1 <APPROVED> "Based on Autosar Memory Map strategy" */
#include "MemMap.h"

#define  SPI_START_SEC_PBCFG_ROOT
/*SAFETYMCUSW 338 S MR:19.1 <APPROVED> "Based on Autosar Memory Map strategy" */
#include "MemMap.h"
/* generation of runtime configuration       */

/*<T_SPI_CFG>*/
CONST(Spi_ConfigType, SPI_PBCFG) SpiRuntime = 
{
    Spi_ExternalDeviceConfig_at,
    Spi_ChannelConfig_at,
    Spi_JobsSettings_at,
    Spi_SequenceSettings_at,
    &Spi_GlobalStatus_at,
    [!"num:dectoint(count(as:modconf('Spi')[1]/SpiDriver/*[1]/SpiExternalDevice/*))"!],
    [!"num:dectoint(count(as:modconf('Spi')[1]/SpiDriver/*[1]/SpiChannel/*))"!],
    [!"num:dectoint(count(as:modconf('Spi')[1]/SpiDriver/*[1]/SpiJob/*))"!],
    [!"num:dectoint(count(as:modconf('Spi')[1]/SpiDriver/*[1]/SpiSequence/*))"!],
    [!"num:dectoint(count(as:modconf('Spi')[1]/SpiDriver/*[1]/SpiHardwareUnit/*))"!]
};
/*</T_SPI_CFG>*/

#define  SPI_STOP_SEC_PBCFG_ROOT
/*SAFETYMCUSW 338 S MR:19.1 <APPROVED> "Based on Autosar Memory Map strategy" */
#include "MemMap.h"

/**********************************************************************************************************************
 *  END OF FILE: Spi_PBcfg.c
 *********************************************************************************************************************/
