/**********************************************************************************************************************
 *  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.  All rights reserved.
 *
 *  \endverbatim
 *  -------------------------------------------------------------------------------------------------------------------
 *  FILE DESCRIPTION
 *  -------------------------------------------------------------------------------------------------------------------
 *         File:  Pwm_PBCfg.c
 *      Project:  Tms570_AutosarPwmDriver
 *       Module:  DriverPwm
 *    Generator:  EB Tresos
 *
 *  Description:  This component provides services for initialization and control of the microcontroller internal
 *                PWM unit (pulse width modulation). The PWM module generates pulses with variable pulse width. 
 *                It allows the selection of the duty cycle and the signal period time.
 *  
 *********************************************************************************************************************/

/**********************************************************************************************************************
 *---------------------------------------------------------------------------------------------------------------------
 * Author:  Vineeth Thomas Alex
 *---------------------------------------------------------------------------------------------------------------------
 * Revision History
 *---------------------------------------------------------------------------------------------------------------------
 * Version     Date           Author                   Change ID          Description
 *---------------------------------------------------------------------------------------------------------------------
 * 02.21.00    30Sep2014     Vineeth Thomas Alex      SDOCM00113122      Initial version adapted from TMS570LS3137
 * 02.21.01    23Aug2016     Vishwanath Reddy         SDOCM00122620      Vresion info updated.
 * 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 PWM_CFG_SOURCE
/**********************************************************************************************************************
 *  INCLUDES
 *********************************************************************************************************************/

#include "Std_Types.h"
#include "Pwm_Het.h"
#include "Pwm.h"
#include "Pwm_Cfg.h"
/**********************************************************************************************************************
 *  VERSION CHECK
 *********************************************************************************************************************/
#define PWM_CFG_C_MAJOR_VERSION               (5U)
#define PWM_CFG_C_MINOR_VERSION               (30U)
#define PWM_CFG_C_PATCH_VERSION               (0U)

/* ---- Perform version checking  ----------------------------------------- */
#if (   (PWM_SW_MAJOR_VERSION != PWM_CFG_C_MAJOR_VERSION) \
     || (PWM_SW_MINOR_VERSION != PWM_CFG_C_MINOR_VERSION))
  #error "Version numbers of Pwm_PBcfg.c and Pwm.h are inconsistent!"
#endif

#if (   (PWM_CFG_MAJOR_VERSION != PWM_CFG_C_MAJOR_VERSION) \
     || (PWM_CFG_MINOR_VERSION != PWM_CFG_C_MINOR_VERSION))
  #error "Version numbers of Pwm_PBcfg.c and Pwm_Cfg.h are inconsistent!"
#endif

#define PWM_START_SEC_CONST_PBCFG
#include "MemMap.h"

/* SourceId : PWM_SourceId_047 */
/* DesignId : PWM_DesignId_25  */
/* Requirements : AR_PWM_SR107, AR_PWM_SR108, AR_PWM_SR109, AR_PWM_SR110, AR_PWM_SR111, AR_PWM_SR99, AR_PWM_SR112,
 * AR_PWM_SR113, AR_PWM_SR114, AR_PWM_SR115 */
/* Pwm Channel Configuration parameters */
[!VAR "Index" = "0"!]
[!LOOP "as:modconf('Pwm')[1]/PwmChannelConfigSet/*"!]
static CONST(Pwm_ChannelConfigType, PWM_PBCFG) Pwm_ChannelCfg[!"num:i($Index)"!] [] =
{
  [!LOOP "PwmChannel/*"!][!/*Channel Loop */!]
  {
    [!"PwmChannelClass"!],
    [!"num:i(PwmPeriodDefault)"!]U,/* Default Period Length */
    [!"PwmIdleState"!],/* Idle State */
    [!"PwmPolarity"!],/* Polarity */
    [!"PwmDutycycleDefault"!]U,/* Default Dutycycle out of 0x8000 */
    [!IF "PwmNotification != ''"!]    [!"PwmNotification"!][!ELSE!]    NULL_PTR[!ENDIF!],/*Notification Function*/
    [!"PwmHet"!],/*HET used*/
    [!"num:i(substring-after(PwmOutputPin,'NHET'))"!]U/* Output Pin */
  }[!IF "not(node:islast())"!],[!ENDIF!][!CR!][!ENDLOOP!]
};
[!VAR "Index" = "$Index+1"!][!ENDLOOP!][!/*End of PwmChannelConfigSet Loop*/!]
/*</PWM_HET1_PROGRAM>*/
[!/* Pwm HET1 Global CNT */!]
[!VAR "Index" = "0"!][!VAR "Count"="0"!]
[!LOOP "as:modconf('Pwm')[1]/PwmChannelConfigSet/*"!][!AUTOSPACING!]
[!CR!]static CONST(Het_Pwm_InstructionType, PWM_PBCFG) Pwm_Het1ProgramBlock1_Cfg[!"num:i($Index)"!] [] =
{
   [!LOOP "PwmChannel/*"!][!IF "PwmHet = 'HET1'"!][!/*Channel Loop */!][!VAR "Count"="$Count+1"!][!BREAK!][!ENDIF!][!ENDLOOP!][!/*End of Channel Loop */!]
   [!IF "$Count=0"!]
   {[!"num:inttohex(0,8)"!]U,[!"num:inttohex(0,8)"!]U,[!"num:inttohex(0,8)"!]U,[!"num:inttohex(0,1)"!]U} /*void*/
   [!ELSE!]
   {0x00060C80U,0x01FFFFFFU,0xFFFFFF80U,0x0U}   /* Pwm HET1 Global CNT */
   [!ENDIF!]
};
[!VAR "Index"="$Index+1"!][!VAR "Count"="0"!][!ENDLOOP!][!/*End of PwmChannelConfigSet Loop*/!]
[!/* Pwm Ch PWCNT Period */!]
[!VAR "Index" = "0"!][!VAR "Count" = "0"!][!VAR "PwcntPrgFld_Initial" = "660928"!][!VAR "PwcntPrgFld"="0"!][!VAR "PwcntCntFld"="0"!]
[!LOOP "as:modconf('Pwm')[1]/PwmChannelConfigSet/*"!]
[!VAR "NoofChs"="0"!][!LOOP "PwmChannel/*"!][!IF "PwmHet = 'HET1'"!][!VAR "NoofChs"="$NoofChs+1"!][!ENDIF!][!ENDLOOP!]
static CONST(Het_Pwm_InstructionType, PWM_PBCFG) Pwm_Het1ProgramBlock0_Cfg[!"num:i($Index)"!] [] = 
{
  [!LOOP "PwmChannel/*"!][!IF "PwmHet = 'HET1'"!][!/*Channel Loop */!]
  [!VAR "PwcntPrgFld"="num:inttohex(bit:or(bit:shl($Count,13),$PwcntPrgFld_Initial),8)"!][!/*Program Field*/!]
  {[!"$PwcntPrgFld"!]U,[!IF "PwmPolarity = 'PWM_HIGH'"!][!VAR "PwcntCntFld_Initial" = "4849694"!][!ELSE!][!VAR "PwcntCntFld_Initial" = "4849678"!][!ENDIF!][!VAR "PwcntCntFld"="num:inttohex(bit:or(bit:or(bit:shl($Count,13),$PwcntCntFld_Initial),bit:shl(num:dectoint(string(num:i(substring-after(PwmOutputPin,'NHET')))),8)))"!][!/*Control Field*/!][!"$PwcntCntFld"!]U,[!"num:inttohex(0,8)"!]U,[!"num:inttohex(0,1)"!]U}[!IF "$Count < (num:i($NoofChs)-1)"!],[!ENDIF!]
  [!"concat(concat('/* Pwm Chl',string(num:i(substring-after(PwmOutputPin,'NHET')))),' PWCNT */')"!][!VAR "Count"="$Count+1"!][!CR!][!ENDIF!][!ENDLOOP!][!/*End of Channel Loop */!]
  [!IF "$Count=0"!]
  {[!"num:inttohex(0,8)"!]U,[!"num:inttohex(0,8)"!]U,[!"num:inttohex(0,8)"!]U,[!"num:inttohex(0,2)"!]U}[!CR!]
  [!ENDIF!]
};
[!VAR "Index"="$Index+1"!][!VAR "Count" = "0"!][!ENDLOOP!][!/*End of PwmChannelConfigSet Loop*/!]
[!/* Pwm Ch DJZ Period */!]
[!VAR "Index" = "0"!][!VAR "NoofChs"="0"!][!VAR "Count" = "0"!][!VAR "DjzPrgFld" = "0"!][!VAR "DjzPrgFld_Initial" = "406656"!][!VAR "DjzCntrFld"="0"!][!VAR "DjzCntrFld_Initial" = "786438"!]
[!LOOP "as:modconf('Pwm')[1]/PwmChannelConfigSet/*"!]
[!VAR "NoofChs"="0"!][!LOOP "PwmChannel/*"!][!IF "PwmHet = 'HET1'"!][!VAR "NoofChs"="$NoofChs+1"!][!ENDIF!][!ENDLOOP!]
static CONST(Het_Pwm_InstructionType, PWM_PBCFG) Pwm_Het1ProgramBlock2_Cfg[!"num:i($Index)"!] [] = 
{
  [!LOOP "PwmChannel/*"!][!IF "PwmHet='HET1'"!][!/*Channel Loop */!]
  {[!IF "$Count < 15"!][!VAR "DjzPrgFld"="num:inttohex(num:add(bit:shl($Count,13),$DjzPrgFld_Initial),8)"!][!ELSE!][!VAR "DjzPrgFld"="num:inttohex(5248,8)"!][!ENDIF!][!"$DjzPrgFld"!]U,[!VAR "DjzCntrFld"="num:inttohex(bit:or(bit:shl($Count,13),$DjzCntrFld_Initial),8)"!][!"$DjzCntrFld"!]U,[!"num:inttohex(0,8)"!]U,[!"num:inttohex(0,1)"!]U}[!IF "$Count < (num:i($NoofChs)-1)"!],[!ENDIF!]
  [!"concat(concat('/* Pwm Chl',string(num:i(substring-after(PwmOutputPin,'NHET')))),' DJZ */')"!]
  [!VAR "Count"="$Count+1"!][!ENDIF!][!ENDLOOP!][!/*End of Channel Loop*/!]
  [!IF "$Count=0"!]
  {[!"num:inttohex(0,8)"!]U,[!"num:inttohex(0,8)"!]U,[!"num:inttohex(0,8)"!]U,[!"num:inttohex(0,2)"!]U}[!CR!]
  [!ENDIF!]
};
[!VAR "Index"="$Index+1"!][!VAR "Count"="0"!][!ENDLOOP!][!/*End of PwmChannelConfigSet Loop*/!]
[!/* Pwm Ch Mov64 Duty Cycle */!]
[!VAR "Index" = "0"!][!VAR "NoofChs"="0"!][!VAR "MovDCPrgFld"="0"!][!VAR "MovDCDataFld"="0"!][!VAR "MovDCNxtAddr" = "112"!][!VAR "MovDCRmtAddr" = "48"!][!VAR "MovDCPrgFld_Initial" = "512"!][!VAR "MovDCCntFld" = "0"!][!VAR "DutyCycleMax"="32768"!][!VAR "Count"="0"!]
[!LOOP "as:modconf('Pwm')[1]/PwmChannelConfigSet/*"!]
[!VAR "NoofChs"="0"!][!LOOP "PwmChannel/*"!][!IF "PwmHet = 'HET1'"!][!VAR "NoofChs"="$NoofChs+1"!][!ENDIF!][!ENDLOOP!]
static CONST(Het_Pwm_InstructionType, PWM_PBCFG) Pwm_Het1ProgramBlock3_Cfg[!"num:i($Index)"!] [] =
{
  [!LOOP "PwmChannel/*"!][!IF "PwmHet = 'HET1'"!]
  [!VAR "MovDCPrgFld"="num:inttohex(num:add(bit:or(bit:shl($MovDCNxtAddr+($Count),13),$MovDCPrgFld_Initial),$MovDCRmtAddr+$Count),8)"!]
  [!VAR "MovDCDataFld" = "num:inttohex(bit:shl(num:add(bit:shr((PwmDutycycleDefault*PwmPeriodDefault),15),1),7),8)"!]  
  {[!"$MovDCPrgFld"!]U,[!IF "PwmPolarity = 'PWM_HIGH'"!][!VAR "MovDCCntFld_Initial" = "4849694"!][!ELSE!][!VAR "MovDCCntFld_Initial" = "4849678"!][!ENDIF!][!VAR "MovDCCntFld"="num:inttohex(bit:or(bit:or(bit:shl($Count,13),$MovDCCntFld_Initial),bit:shl(num:dectoint(string(num:i(substring-after(PwmOutputPin,'NHET')))),8)))"!][!/*Control Field*/!][!"$MovDCCntFld"!]U,[!"$MovDCDataFld"!]U,[!"num:inttohex(0,1)"!]U}[!IF "$Count < (num:i($NoofChs)-1)"!],[!ENDIF!]
  [!"concat(concat('/* Pwm Chl',string(num:i(substring-after(PwmOutputPin,'NHET')))),' MOV64 DutyCycle */')"!]
  [!VAR "Count"="$Count+1"!][!ENDIF!][!ENDLOOP!][!/*End of Channel Loop*/!]
  [!IF "$Count=0"!][!/*Void*/!]
  {[!"num:inttohex(0,8)"!]U,[!"num:inttohex(0,8)"!]U,[!"num:inttohex(0,8)"!]U,[!"num:inttohex(0,2)"!]U}
  [!ENDIF!]
};
[!VAR "Index"="$Index+1"!][!VAR "Count"="0"!][!ENDLOOP!][!/*End of PwmChannelConfigSet Loop*/!]
[!/* Pwm Ch Mov64 Period */!]
[!VAR "Index" = "0"!][!VAR "NoofChs"="0"!][!VAR "MovPdPrgFld"="0"!][!VAR "MovPdDataFld"="0"!][!VAR "MovPdNxtAddr" = "49"!][!VAR "MovPdRmtAddr" = "80"!][!VAR "MovPdPrgFld_Initial" = "512"!][!VAR "MovPdCntFld" = "0"!][!VAR "MovPdCntFld_Initial" = "786438"!][!VAR "Count"="0"!]
[!LOOP "as:modconf('Pwm')[1]/PwmChannelConfigSet/*"!]
[!VAR "NoofChs"="0"!][!LOOP "PwmChannel/*"!][!IF "PwmHet = 'HET1'"!][!VAR "NoofChs"="$NoofChs+1"!][!ENDIF!][!ENDLOOP!]
static CONST(Het_Pwm_InstructionType, PWM_PBCFG) Pwm_Het1ProgramBlock4_Cfg[!"num:i($Index)"!] [] =
{
  [!LOOP "PwmChannel/*"!][!IF "PwmHet = 'HET1'"!]
  [!VAR "MovPdPrgFld"="num:inttohex(num:add(bit:or(bit:shl($MovPdNxtAddr+($Count),13),$MovPdPrgFld_Initial),$MovPdRmtAddr+$Count),8)"!]
  [!VAR "MovPdDataFld" = "num:inttohex(bit:shl(num:sub(PwmPeriodDefault,1),7),8)"!]  
  {[!"$MovPdPrgFld"!]U,[!VAR "MovPdCntFld"="num:inttohex(bit:or(bit:shl($Count,13),$MovPdCntFld_Initial),8)"!][!"$MovPdCntFld"!]U,[!"$MovPdDataFld"!]U,[!"num:inttohex(0,1)"!]U}[!IF "$Count < (num:i($NoofChs)-1)"!],[!ENDIF!]
  [!"concat(concat('/* Pwm Chl',string(num:i(substring-after(PwmOutputPin,'NHET')))),' MOV64 Period */')"!]
  [!VAR "Count"="$Count+1"!][!ENDIF!][!ENDLOOP!][!/*End of Channel Loop*/!]
  [!IF "$Count=0"!][!/*Void*/!]
  {[!"num:inttohex(0,8)"!]U,[!"num:inttohex(0,8)"!]U,[!"num:inttohex(0,8)"!]U,[!"num:inttohex(0,2)"!]U}
  [!ENDIF!]
};
[!VAR "Index"="$Index+1"!][!VAR "Count"="0"!][!ENDLOOP!][!/*End of PwmChannelConfigSet Loop*/!]

[!VAR "Index" = "0"!][!VAR "Count"="0"!]
[!LOOP "as:modconf('Pwm')[1]/PwmChannelConfigSet/*"!]
[!LOOP "PwmChannel/*"!][!IF "PwmHet='HET1'"!][!VAR "Count"="$Count+1"!][!ENDIF!]
[!ENDLOOP!][!/*End of PwmChannel Loop*/!]
static CONST(Het_Pwm_BlockType, PWM_PBCFG) Pwm_Het1Program_Cfg[!"num:i($Index)"!][] =
{
    { Pwm_Het1ProgramBlock0_Cfg[!"num:i($Index)"!], [!"num:i($Count)"!]U },
    { Pwm_Het1ProgramBlock1_Cfg[!"num:i($Index)"!], [!IF "$Count=0"!]0U[!ELSE!]1U[!ENDIF!]},
    { Pwm_Het1ProgramBlock2_Cfg[!"num:i($Index)"!], [!"num:i($Count)"!]U },
    { Pwm_Het1ProgramBlock3_Cfg[!"num:i($Index)"!], [!"num:i($Count)"!]U },
    { Pwm_Het1ProgramBlock4_Cfg[!"num:i($Index)"!], [!"num:i($Count)"!]U }
};
[!VAR "Index"="$Index+1"!][!VAR "Count"="0"!][!ENDLOOP!][!/*End of PwmChannelConfigSet Loop*/!]
/*</PWM_HET1_PROGRAM>*/


/*</PWM_HET2_PROGRAM>*/
[!/* Pwm HET2 Global CNT */!]
[!VAR "Index" = "0"!][!VAR "Count"="0"!]
[!LOOP "as:modconf('Pwm')[1]/PwmChannelConfigSet/*"!][!AUTOSPACING!]
[!CR!]static CONST(Het_Pwm_InstructionType, PWM_PBCFG) Pwm_Het2ProgramBlock1_Cfg[!"num:i($Index)"!] [] =
{
   [!LOOP "PwmChannel/*"!][!IF "PwmHet = 'HET2'"!][!/*Channel Loop */!][!VAR "Count"="$Count+1"!][!BREAK!][!ENDIF!][!ENDLOOP!][!/*End of Channel Loop */!]
   [!IF "$Count=0"!]
   {[!"num:inttohex(0,8)"!]U,[!"num:inttohex(0,8)"!]U,[!"num:inttohex(0,8)"!]U,[!"num:inttohex(0,1)"!]U} /*void*/
   [!ELSE!]
   {0x00060C80U,0x01FFFFFFU,0xFFFFFF80U,0x0U}   /* Pwm HET2 Global CNT */
   [!ENDIF!]
};
[!VAR "Index"="$Index+1"!][!VAR "Count"="0"!][!ENDLOOP!][!/*End of PwmChannelConfigSet Loop*/!]
[!/* Pwm Ch PWCNT Period */!]
[!VAR "Index" = "0"!][!VAR "Count" = "0"!][!VAR "PwcntPrgFld_Initial" = "660928"!][!VAR "PwcntPrgFld"="0"!][!VAR "PwcntCntFld"="0"!]
[!LOOP "as:modconf('Pwm')[1]/PwmChannelConfigSet/*"!]
[!VAR "NoofChs"="0"!][!LOOP "PwmChannel/*"!][!IF "PwmHet = 'HET2'"!][!VAR "NoofChs"="$NoofChs+1"!][!ENDIF!][!ENDLOOP!]
static CONST(Het_Pwm_InstructionType, PWM_PBCFG) Pwm_Het2ProgramBlock0_Cfg[!"num:i($Index)"!] [] = 
{
  [!LOOP "PwmChannel/*"!][!IF "PwmHet = 'HET2'"!][!/*Channel Loop */!]
  [!VAR "PwcntPrgFld"="num:inttohex(bit:or(bit:shl($Count,13),$PwcntPrgFld_Initial),8)"!][!/*Program Field*/!]
  {[!"$PwcntPrgFld"!]U,[!IF "PwmPolarity = 'PWM_HIGH'"!][!VAR "PwcntCntFld_Initial" = "4849694"!][!ELSE!][!VAR "PwcntCntFld_Initial" = "4849678"!][!ENDIF!][!VAR "PwcntCntFld"="num:inttohex(bit:or(bit:or(bit:shl($Count,13),$PwcntCntFld_Initial),bit:shl(num:dectoint(string(num:i(substring-after(PwmOutputPin,'NHET')))),8)))"!][!/*Control Field*/!][!"$PwcntCntFld"!]U,[!"num:inttohex(0,8)"!]U,[!"num:inttohex(0,1)"!]U}[!IF "$Count < (num:i($NoofChs)-1)"!],[!ENDIF!]
  [!"concat(concat('/* Pwm Chl',string(num:i(substring-after(PwmOutputPin,'NHET')))),' PWCNT */')"!][!VAR "Count"="$Count+1"!][!CR!][!ENDIF!][!ENDLOOP!][!/*End of Channel Loop */!]
  [!IF "$Count=0"!]
  {[!"num:inttohex(0,8)"!]U,[!"num:inttohex(0,8)"!]U,[!"num:inttohex(0,8)"!]U,[!"num:inttohex(0,2)"!]U}[!CR!]
  [!ENDIF!]
};
[!VAR "Index"="$Index+1"!][!VAR "Count" = "0"!][!ENDLOOP!][!/*End of PwmChannelConfigSet Loop*/!]
[!/* Pwm Ch DJZ Period */!]
[!VAR "Index" = "0"!][!VAR "NoofChs"="0"!][!VAR "Count" = "0"!][!VAR "DjzPrgFld" = "0"!][!VAR "DjzPrgFld_Initial" = "406656"!][!VAR "DjzCntrFld"="0"!][!VAR "DjzCntrFld_Initial" = "786438"!]
[!LOOP "as:modconf('Pwm')[1]/PwmChannelConfigSet/*"!]
[!VAR "NoofChs"="0"!][!LOOP "PwmChannel/*"!][!IF "PwmHet = 'HET2'"!][!VAR "NoofChs"="$NoofChs+1"!][!ENDIF!][!ENDLOOP!]
static CONST(Het_Pwm_InstructionType, PWM_PBCFG) Pwm_Het2ProgramBlock2_Cfg[!"num:i($Index)"!] [] = 
{
  [!LOOP "PwmChannel/*"!][!IF "PwmHet='HET2'"!][!/*Channel Loop */!]
  {[!IF "$Count < 15"!][!VAR "DjzPrgFld"="num:inttohex(num:add(bit:shl($Count,13),$DjzPrgFld_Initial),8)"!][!ELSE!][!VAR "DjzPrgFld"="num:inttohex(5248,8)"!][!ENDIF!][!"$DjzPrgFld"!]U,[!VAR "DjzCntrFld"="num:inttohex(bit:or(bit:shl($Count,13),$DjzCntrFld_Initial),8)"!][!"$DjzCntrFld"!]U,[!"num:inttohex(0,8)"!]U,[!"num:inttohex(0,1)"!]U}[!IF "$Count < (num:i($NoofChs)-1)"!],[!ENDIF!]
  [!"concat(concat('/* Pwm Chl',string(num:i(substring-after(PwmOutputPin,'NHET')))),' DJZ */')"!]
  [!VAR "Count"="$Count+1"!][!ENDIF!][!ENDLOOP!][!/*End of Channel Loop*/!]
  [!IF "$Count=0"!]
  {[!"num:inttohex(0,8)"!]U,[!"num:inttohex(0,8)"!]U,[!"num:inttohex(0,8)"!]U,[!"num:inttohex(0,2)"!]U}[!CR!]
  [!ENDIF!]
};
[!VAR "Index"="$Index+1"!][!VAR "Count"="0"!][!ENDLOOP!][!/*End of PwmChannelConfigSet Loop*/!]
[!/* Pwm Ch Mov64 Duty Cycle */!]
[!VAR "Index" = "0"!][!VAR "NoofChs"="0"!][!VAR "MovDCPrgFld"="0"!][!VAR "MovDCDataFld"="0"!][!VAR "MovDCNxtAddr" = "112"!][!VAR "MovDCRmtAddr" = "48"!][!VAR "MovDCPrgFld_Initial" = "512"!][!VAR "MovDCCntFld" = "0"!][!VAR "DutyCycleMax"="32768"!][!VAR "Count"="0"!]
[!LOOP "as:modconf('Pwm')[1]/PwmChannelConfigSet/*"!]
[!VAR "NoofChs"="0"!][!LOOP "PwmChannel/*"!][!IF "PwmHet = 'HET2'"!][!VAR "NoofChs"="$NoofChs+1"!][!ENDIF!][!ENDLOOP!]
static CONST(Het_Pwm_InstructionType, PWM_PBCFG) Pwm_Het2ProgramBlock3_Cfg[!"num:i($Index)"!] [] =
{
  [!LOOP "PwmChannel/*"!][!IF "PwmHet = 'HET2'"!]
  [!VAR "MovDCPrgFld"="num:inttohex(num:add(bit:or(bit:shl($MovDCNxtAddr+($Count),13),$MovDCPrgFld_Initial),$MovDCRmtAddr+$Count),8)"!]
  [!VAR "MovDCDataFld" = "num:inttohex(bit:shl(num:add(bit:shr((PwmDutycycleDefault*PwmPeriodDefault),15),1),7),8)"!]  
  {[!"$MovDCPrgFld"!]U,[!IF "PwmPolarity = 'PWM_HIGH'"!][!VAR "MovDCCntFld_Initial" = "4849694"!][!ELSE!][!VAR "MovDCCntFld_Initial" = "4849678"!][!ENDIF!][!VAR "MovDCCntFld"="num:inttohex(bit:or(bit:or(bit:shl($Count,13),$MovDCCntFld_Initial),bit:shl(num:dectoint(string(num:i(substring-after(PwmOutputPin,'NHET')))),8)))"!][!/*Control Field*/!][!"$MovDCCntFld"!]U,[!"$MovDCDataFld"!]U,[!"num:inttohex(0,1)"!]U}[!IF "$Count < (num:i($NoofChs)-1)"!],[!ENDIF!]
  [!"concat(concat('/* Pwm Chl',string(num:i(substring-after(PwmOutputPin,'NHET')))),' MOV64 DutyCycle */')"!]
  [!VAR "Count"="$Count+1"!][!ENDIF!][!ENDLOOP!][!/*End of Channel Loop*/!]
  [!IF "$Count=0"!][!/*Void*/!]
  {[!"num:inttohex(0,8)"!]U,[!"num:inttohex(0,8)"!]U,[!"num:inttohex(0,8)"!]U,[!"num:inttohex(0,2)"!]U}
  [!ENDIF!]
};
[!VAR "Index"="$Index+1"!][!VAR "Count"="0"!][!ENDLOOP!][!/*End of PwmChannelConfigSet Loop*/!]
[!/* Pwm Ch Mov64 Period */!]
[!VAR "Index" = "0"!][!VAR "NoofChs"="0"!][!VAR "MovPdPrgFld"="0"!][!VAR "MovPdDataFld"="0"!][!VAR "MovPdNxtAddr" = "49"!][!VAR "MovPdRmtAddr" = "80"!][!VAR "MovPdPrgFld_Initial" = "512"!][!VAR "MovPdCntFld" = "0"!][!VAR "MovPdCntFld_Initial" = "786438"!][!VAR "Count"="0"!]
[!LOOP "as:modconf('Pwm')[1]/PwmChannelConfigSet/*"!]
[!VAR "NoofChs"="0"!][!LOOP "PwmChannel/*"!][!IF "PwmHet = 'HET2'"!][!VAR "NoofChs"="$NoofChs+1"!][!ENDIF!][!ENDLOOP!]
static CONST(Het_Pwm_InstructionType, PWM_PBCFG) Pwm_Het2ProgramBlock4_Cfg[!"num:i($Index)"!] [] =
{
  [!LOOP "PwmChannel/*"!][!IF "PwmHet = 'HET2'"!]
  [!VAR "MovPdPrgFld"="num:inttohex(num:add(bit:or(bit:shl($MovPdNxtAddr+($Count),13),$MovPdPrgFld_Initial),$MovPdRmtAddr+$Count),8)"!]
  [!VAR "MovPdDataFld" = "num:inttohex(bit:shl(PwmPeriodDefault,7),8)"!]  
  {[!"$MovPdPrgFld"!]U,[!VAR "MovPdCntFld"="num:inttohex(bit:or(bit:shl($Count,13),$MovPdCntFld_Initial),8)"!][!"$MovPdCntFld"!]U,[!"$MovPdDataFld"!]U,[!"num:inttohex(0,1)"!]U}[!IF "$Count < (num:i($NoofChs)-1)"!],[!ENDIF!]
  [!"concat(concat('/* Pwm Chl',string(num:i(substring-after(PwmOutputPin,'NHET')))),' MOV64 Period */')"!]
  [!VAR "Count"="$Count+1"!][!ENDIF!][!ENDLOOP!][!/*End of Channel Loop*/!]
  [!IF "$Count=0"!][!/*Void*/!]
  {[!"num:inttohex(0,8)"!]U,[!"num:inttohex(0,8)"!]U,[!"num:inttohex(0,8)"!]U,[!"num:inttohex(0,2)"!]U}
  [!ENDIF!]
};
[!VAR "Index"="$Index+1"!][!VAR "Count"="0"!][!ENDLOOP!][!/*End of PwmChannelConfigSet Loop*/!]

[!VAR "Index" = "0"!][!VAR "Count"="0"!]
[!LOOP "as:modconf('Pwm')[1]/PwmChannelConfigSet/*"!]
[!LOOP "PwmChannel/*"!][!IF "PwmHet='HET2'"!][!VAR "Count"="$Count+1"!][!ENDIF!]
[!ENDLOOP!][!/*End of PwmChannel Loop*/!]
static CONST(Het_Pwm_BlockType, PWM_PBCFG) Pwm_Het2Program_Cfg[!"num:i($Index)"!][] =
{
    { Pwm_Het2ProgramBlock0_Cfg[!"num:i($Index)"!], [!"num:i($Count)"!]U },
    { Pwm_Het2ProgramBlock1_Cfg[!"num:i($Index)"!], [!IF "$Count=0"!]0U[!ELSE!]1U[!ENDIF!]},
    { Pwm_Het2ProgramBlock2_Cfg[!"num:i($Index)"!], [!"num:i($Count)"!]U },
    { Pwm_Het2ProgramBlock3_Cfg[!"num:i($Index)"!], [!"num:i($Count)"!]U },
    { Pwm_Het2ProgramBlock4_Cfg[!"num:i($Index)"!], [!"num:i($Count)"!]U }
};
[!VAR "Index"="$Index+1"!][!VAR "Count"="0"!][!ENDLOOP!][!/*End of PwmChannelConfigSet Loop*/!]
/*</PWM_HET2_PROGRAM>*/

/* global pwm runtime configuration Het1,Het2*/
/*<PWM_CONFIGURATION>*/
[!VAR "Index" = "0"!][!VAR "Count"="0"!]
[!LOOP "as:modconf('Pwm')[1]/PwmChannelConfigSet/*"!]
[!LOOP "PwmChannel/*"!][!VAR "Count" = "$Count+1"!][!ENDLOOP!]
CONST(Pwm_ConfigType, PWM_PBCFG) [!"@name"!] =
{
    Pwm_Het1Program_Cfg[!"num:i($Index)"!],
    Pwm_Het2Program_Cfg[!"num:i($Index)"!],
    Pwm_ChannelCfg[!"num:i($Index)"!],
    [!"num:i($Count)"!]U
};
[!VAR "Index"="$Index+1"!][!VAR "Count"="0"!][!ENDLOOP!]

/*</PWM_CONFIGURATION>*/
/*SAFETYMCUSW 580 S MR:1.1 <APPROVED> "Reason - This is the format for specifying memory sections" */
#define PWM_STOP_SEC_CONST_PBCFG
/*SAFETYMCUSW 338 S MR:19.1 <APPROVED> "Reason - This is the format for specifying memory sections" */
#include "MemMap.h"

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