/****************************************************************************
* 文件名: def.h
* 内容简述: 预处理头文件	
* 
* 文件历史:
* 版本号  日期       作者    说明
*
****************************************************************************/

#ifndef HRTIM_DEBUG_H_
#define HRTIM_DEBUG_H_

#define DEBUG_MODE    2   //0:change prd
                          //1:change duty
                          //2:change phase
													

#define   HRPWM_COUNTERMODE_UPDOWN        0
#define   HRPWM_COUNTERMODE_UP            1
#define   HRPWM_COUNTERMODE_SELECT        HRPWM_COUNTERMODE_UP   //0:updown mode,1:UpMode



/************************interleaving PWM control *****************************/
#define   HRPWM_INTERLEVE_NORM            0
#define   HRPWM_INTERLEVE_UNIT1OST        1
#define   HRPWM_INTERLEVE_SELECT          HRPWM_INTERLEVE_UNIT1OST   

/*************************BM MODE***********************************************/
#define   HRPWM_BMMODE_ENABLE             1  //0:disable 1:enable

/******************ExTERN EVENT configuration start***********************************/ 
//event source select
#define  EEVT_MODE_PORT	 		0
#define  EEVT_MODE_CMP	 		1
#define  EEVT_MODE_TIMERX	  2
#define  EEVT_MODE_ADCCMP	  3
#define  EEVT_SLECT_MASK    EEVT_MODE_PORT	


#define BlANKING_MODE     		0    	//0:Mode1  1
																		//1:Mode  2
																		
#define BLANKING_MODE2_REF    0    	//0:Ref PRD 
                                    //1: Ref ZERO															 

#define EVENT_SATE_MODE       1         //0:UP level
																			  //1: UP edge
																				//2: Low level
																				//3: low edge
#define BLANKING_Win_Offset_Slt   0     //  0:[offset,window]    ----Blanking
                                        //  1:[xxx,offset]       ----Blanking
                                        //  2:[xxx,window]       ----Blanking
																				//  3:other unit[offset,window] ----Blanking
																				//  4:[offset,window]    ----Blanking
																				//  5:[offset,window]    ----Blanking
																				

#define BlankingDelay             0     //  0(delay disable)/1(delay enable)

#if   BlankingDelay == 1
#define BlankingLatchEnable       0     //  0(Latch enable)/1(latch disable) 
#else
#define BlankingLatchEnable       0     //  0(Latch enable)/1(latch disable) 
#endif

#if BLANKING_Win_Offset_Slt   == 4
#define WINDOWM_TimeOut_Enable    0
#else
#define WINDOWM_TimeOut_Enable    0
#endif
/******************ExTERN EVENT configuration end***********************************/ 

/***************************IDLE configuration start***************************/
#define IDLE_DELAYIDLE_ENABLE       0   //0(delay idle disable) 1(enable)

//delay idle source select
#define DELAYIDLE_EEVT6             0
#define DELAYIDLE_EEVT7             1
#define DELAYIDLE_EEVT8             2
#define DELAYIDLE_EEVT9             3
#define DELAYIDLE_SW                4

#define DELAYIDLE_SR_Mask           DELAYIDLE_EEVT6

#if DELAYIDLE_SR_Mask ==  DELAYIDLE_SW
#define    DELAYIDLE_SR_SW_MASK      1     //0:IDLECR  1:SSTADIDLR

#endif

#if IDLE_DELAYIDLE_ENABLE  ==     0 

#define  DELAYIDLE_SSTARUN2_ENABLE   1    //quit idle mode 0(SSTARUN1),1(SSTARUN2)

#endif
//
/***************************IDLE configuration end***************************/

/*************************Shadow register update*******************************/
#define   SHADOW_UPDATE_SELF_ZERO         0
#define   SHADOW_UPDATE_SELF_PRD          1
#define   SHADOW_UPDATE_UNIT1_IMME        2
#define   SHADOW_UPDATE_UNIT1_FULLSWITCH  3
#define   SHADOW_UPDATE_SELF_MIX          4


#define   PWM1_SHADOW_SELECT              SHADOW_UPDATE_UNIT1_IMME
#define   PWM2_SHADOW_SELECT              SHADOW_UPDATE_UNIT1_FULLSWITCH
#define   PWM3_SHADOW_SELECT              SHADOW_UPDATE_UNIT1_FULLSWITCH
#define   PWM4_SHADOW_SELECT              SHADOW_UPDATE_UNIT1_FULLSWITCH
#define   PWM5_SHADOW_SELECT              SHADOW_UPDATE_UNIT1_FULLSWITCH
#define   PWM6_SHADOW_SELECT              SHADOW_UPDATE_UNIT1_FULLSWITCH

/*************************half mode *******************************/
#define   MODE_NORMAL_MODE                0
#define   MODE_NORMAL_HALF_MODE           1
#define   PWM1_MODE_WORK_MODE             MODE_NORMAL_HALF_MODE
#define   PWM2_MODE_WORK_MODE             MODE_NORMAL_MODE
#define   PWM3_MODE_WORK_MODE             MODE_NORMAL_MODE
#define   PWM4_MODE_WORK_MODE             MODE_NORMAL_MODE
#define   PWM5_MODE_WORK_MODE             MODE_NORMAL_MODE
#define   PWM6_MODE_WORK_MODE             MODE_NORMAL_MODE

/*************************period link*******************************/
#define   MODE_PERIOD_UPDATE_NOR          0
#define   MODE_PERIOD_UPDATE_LINK         1

#define   PWM1_PERIOD_UPDATE_MODE         MODE_PERIOD_UPDATE_NOR
#define   PWM2_PERIOD_UPDATE_MODE         MODE_PERIOD_UPDATE_NOR
#define   PWM3_PERIOD_UPDATE_MODE         MODE_PERIOD_UPDATE_NOR
#define   PWM4_PERIOD_UPDATE_MODE         MODE_PERIOD_UPDATE_NOR
#define   PWM5_PERIOD_UPDATE_MODE         MODE_PERIOD_UPDATE_NOR
#define   PWM6_PERIOD_UPDATE_MODE         MODE_PERIOD_UPDATE_NOR


/*******************************************************************************/
#define   HRPWM_LEAST_1xCLOCK               ((int32_t)(64))
#define   HRPWM_LEAST_2xCLOCK               ((int32_t)(128))
#define   HRPWM_LEAST_3xCLOCK               ((int32_t)(192))
#define   HRPWM_LEAST_4xCLOCK               ((int32_t)(256))
#define   HRPWM_LEAST_6xCLOCK               ((int32_t)(384))

//
#define   MAP_MODE_0        0
#define   MAP_MODE_1        1
#define   MAP_SELECT_MASK   MAP_MODE_0


#define PERIOD_VALUE_resonant             (58181)//(10240)
#define PERIOD_VALUE                      (30720L)//(21943)

//UNIT1
//#if HRPWM_COUNTERMODE_SELECT == HRPWM_COUNTERMODE_UP   //0:updown mode,1:UpMode
//#define UINT1_PRD_VALUE                    (uint32_t)(30720L)     //250KHZ
//#else
//#define UINT1_PRD_VALUE                    (51263)
//#endif

#define UINT1_CMPAC_VALUE                  (15360L)
#define UINT1_CMPBD_VALUE                  (7316)
#define UINT1_CMPEG_VALUE                  (10974)
#define UINT1_CMPFH_VALUE                  (14632)
#define UINT1_SCMPAC_VALUE                 (18290)
#define UINT1_SCMPBD_VALUE                 (21948)
#define UINT1_DT_UP_VALUE                  (1923L)     //250ns
#define UINT1_DT_DOWN_VALUE                (1923L)     //250ns

#if HRPWM_COUNTERMODE_SELECT == HRPWM_COUNTERMODE_UP   //0:updown mode,1:UpMode
#define UINT1_PHASE_1                      (15360L)    //phase 180
#define UINT1_PHASE_2                      (15360L)    //phase 180
#define UINT1_PHASE_3                      (7680L)     //phase 90
#define UINT1_PHASE_4                      (23040L)    //phase 270
#define UINT1_PHASE_5                      (23040L)    //phase 270
#else
#define UINT1_PHASE_1                      (8543)
#define UINT1_PHASE_2                      (17087)
#define UINT1_PHASE_3                      (25631)
#define UINT1_PHASE_4                      (34175)
#define UINT1_PHASE_5                      (42719)
#endif
//UNIT2
#if HRPWM_COUNTERMODE_SELECT == HRPWM_COUNTERMODE_UP   //0:updown mode,1:UpMode
#define UINT2_PRD_VALUE                    (uint32_t)(0x3FFFC0)
#else
#define UINT2_PRD_VALUE                    (51263)
#endif

#define UINT2_CMPAC_VALUE                  (15360L)
#define UINT2_CMPBD_VALUE                  (7316)
#define UINT2_CMPEG_VALUE                  (10974)
#define UINT2_CMPFH_VALUE                  (14632)
#define UINT2_SCMPAC_VALUE                 (18290)
#define UINT2_SCMPBD_VALUE                 (21948)
#define UINT2_DT_UP_VALUE                  (1923L)
#define UINT2_DT_DOWN_VALUE                (1923L)
//UNIT3
#if HRPWM_COUNTERMODE_SELECT == HRPWM_COUNTERMODE_UP   //0:updown mode,1:UpMode
#define UINT3_PRD_VALUE                    (uint32_t)(0x3FFFC0)
#else
#define UINT3_PRD_VALUE                    (51263)
#endif
#define UINT3_CMPAC_VALUE                  (1923L)
#define UINT3_CMPBD_VALUE                  (17283L)    //15360+1293
#define UINT3_CMPEG_VALUE                  (15360L)
#define UINT3_CMPFH_VALUE                  (30720L)
#define UINT3_SCMPAC_VALUE                 (0)
#define UINT3_SCMPBD_VALUE                 (27600)
#define UINT3_DT_UP_VALUE                  (256) 
#define UINT3_DT_DOWN_VALUE                (512) 
//UNIT4
#if HRPWM_COUNTERMODE_SELECT == HRPWM_COUNTERMODE_UP   //0:updown mode,1:UpMode
#define UINT4_PRD_VALUE                    (uint32_t)(0x3FFFC0)
#else
#define UINT4_PRD_VALUE                    (51263)
#endif
#define UINT4_CMPAC_VALUE                  (15360L)
#define UINT4_CMPBD_VALUE                  (13001)
#define UINT4_CMPEG_VALUE                  (12800)
#define UINT4_CMPFH_VALUE                  (13800)
#define UINT4_SCMPAC_VALUE                 (0)
#define UINT4_SCMPBD_VALUE                 (27600)
#define UINT4_DT_UP_VALUE                  (1923L) 
#define UINT4_DT_DOWN_VALUE                (1923L)
//UNIT5
#if HRPWM_COUNTERMODE_SELECT == HRPWM_COUNTERMODE_UP   //0:updown mode,1:UpMode
#define UINT5_PRD_VALUE                    (uint32_t)(0x3FFFC0)
#else
#define UINT5_PRD_VALUE                    (51263)
#endif
#define UINT5_CMPAC_VALUE                  (15360L)
#define UINT5_CMPBD_VALUE                  (26600)
#define UINT5_CMPEG_VALUE                  (12800)
#define UINT5_CMPFH_VALUE                  (13800)
#define UINT5_SCMPAC_VALUE                 (0)
#define UINT5_SCMPBD_VALUE                 (27600)
#define UINT5_DT_UP_VALUE                  (1923L)
#define UINT5_DT_DOWN_VALUE                (1923L) 
//UNIT6
#if HRPWM_COUNTERMODE_SELECT == HRPWM_COUNTERMODE_UP   //0:updown mode,1:UpMode
#define UINT6_PRD_VALUE                    (uint32_t)(0x3FFFC0)
#else
#define UINT6_PRD_VALUE                    (51263)
#endif
#define UINT6_CMPAC_VALUE                  (1923L)
#define UINT6_CMPBD_VALUE                  (17283L)
#define UINT6_CMPEG_VALUE                  (15360L)
#define UINT6_CMPFH_VALUE                  (30720L)
#define UINT6_SCMPAC_VALUE                 (0)
#define UINT6_SCMPBD_VALUE                 (27600)
#define UINT6_DT_UP_VALUE                  (256) 
#define UINT6_DT_DOWN_VALUE                (512) 

#endif

