#define UVW_OUT   (P321)
#define P123  0
#define P132  1
#define P213  2
#define P231  3
#define P312  4
#define P321  5  

#if(UVW_OUT == P123) 
  #define UH_ON     {TIM1->CCER |= TIM_CCER_CC1E;TIM1->CCER |= TIM_CCER_CC1NE;GPIOA->MODER&=~(1<<16);GPIOA->MODER|=(2<<16);}// TIM1->CR1  |= TIM_CR1_CEN;} 
  #define UH_OFF    {TIM1->CCER &= ~TIM_CCER_CC1E;TIM1->CCER &= ~TIM_CCER_CC1NE;}
  #define VH_ON     {TIM1->CCER |= TIM_CCER_CC2E;TIM1->CCER |= TIM_CCER_CC2NE;GPIOA->MODER&=~(1<<18);GPIOA->MODER|=(2<<18);}//TIM1->CR1 |= TIM_CR1_CEN;} 
  #define VH_OFF    {TIM1->CCER &= ~TIM_CCER_CC2E;TIM1->CCER &= ~TIM_CCER_CC2NE;} 
  #define WH_ON     {TIM1->CCER |= TIM_CCER_CC3E;TIM1->CCER |= TIM_CCER_CC3NE;GPIOA->MODER&=~(1<<20);GPIOA->MODER|=(2<<20);}// TIM1->CR1 |= TIM_CR1_CEN;}  
  #define WH_OFF    {TIM1->CCER &= ~TIM_CCER_CC3E;TIM1->CCER &= ~TIM_CCER_CC3NE;} 
 
  #define UL_ON     {GPIOA->MODER&=~(2<<16);GPIOA->MODER|=(1<<16);GPIOA->BSRR = GPIO_Pin_8;}// {GPIO_SetBits(GPIOA, GPIO_Pin_8);}
	#define UL_OFF    {GPIOA->MODER&=~(2<<16);GPIOA->MODER|=(1<<16);GPIOA->BRR = GPIO_Pin_8;}
	#define VL_ON    {GPIOA->MODER&=~(2<<18);GPIOA->MODER|=(1<<18);GPIOA->BSRR = GPIO_Pin_9;}// {GPIO_SetBits(GPIOA, GPIO_Pin_9);}
	#define VL_OFF   {GPIOA->MODER&=~(2<<18);GPIOA->MODER|=(1<<18);GPIOA->BRR = GPIO_Pin_9;}// {GPIO_ResetBits(GPIOA, GPIO_Pin_9);}
	#define WL_ON    {GPIOA->MODER&=~(2<<20);GPIOA->MODER|=(1<<20);GPIOA->BSRR = GPIO_Pin_10;}// {GPIO_SetBits(GPIOA, GPIO_Pin_10);}
	#define WL_OFF   {GPIOA->MODER&=~(2<<20);GPIOA->MODER|=(1<<20);GPIOA->BRR = GPIO_Pin_10;}// {GPIO_ResetBits(GPIOA, GPIO_Pin_10);}
	
	
  #define UH_GPIO_PORT GPIOA
  #define UH_GPIO_PIN  GPIO_Pin_11

  #define VH_GPIO_PORT GPIOA
  #define VH_GPIO_PIN  GPIO_Pin_12

  #define WH_GPIO_PORT GPIOA
  #define WH_GPIO_PIN  GPIO_Pin_15
#elif(UVW_OUT == P132)
  #define UH_ON     {TIM1->CCER |= TIM_CCER_CC1E;TIM1->CCER |= TIM_CCER_CC1NE;GPIOA->MODER&=~(1<<16);GPIOA->MODER|=(2<<16);}// TIM1->CR1  |= TIM_CR1_CEN;} 
  #define UH_OFF    {TIM1->CCER &= ~TIM_CCER_CC1E;TIM1->CCER &= ~TIM_CCER_CC1NE;}
  #define VH_ON     {TIM1->CCER |= TIM_CCER_CC3E;TIM1->CCER |= TIM_CCER_CC3NE;GPIOA->MODER&=~(1<<20);GPIOA->MODER|=(2<<20);}// TIM1->CR1 |= TIM_CR1_CEN;}  
  #define VH_OFF    {TIM1->CCER &= ~TIM_CCER_CC3E;TIM1->CCER &= ~TIM_CCER_CC3NE;}
	#define WH_ON     {TIM1->CCER |= TIM_CCER_CC2E;TIM1->CCER |= TIM_CCER_CC2NE;GPIOA->MODER&=~(1<<18);GPIOA->MODER|=(2<<18);}//TIM1->CR1 |= TIM_CR1_CEN;} 
  #define WH_OFF    {TIM1->CCER &= ~TIM_CCER_CC2E;TIM1->CCER &= ~TIM_CCER_CC2NE;} 
   
  #define UL_ON     {GPIOA->MODER&=~(2<<16);GPIOA->MODER|=(1<<16);GPIOA->BSRR = GPIO_Pin_8;}// {GPIO_SetBits(GPIOA, GPIO_Pin_8);}
	#define UL_OFF    {GPIOA->MODER&=~(2<<16);GPIOA->MODER|=(1<<16);GPIOA->BRR = GPIO_Pin_8;}
	#define VL_ON     {GPIOA->MODER&=~(2<<20);GPIOA->MODER|=(1<<20);GPIOA->BSRR = GPIO_Pin_10;}// {GPIO_SetBits(GPIOA, GPIO_Pin_10);}
	#define VL_OFF    {GPIOA->MODER&=~(2<<20);GPIOA->MODER|=(1<<20);GPIOA->BRR = GPIO_Pin_10;}
	#define WL_ON     {GPIOA->MODER&=~(2<<18);GPIOA->MODER|=(1<<18);GPIOA->BSRR = GPIO_Pin_9;}// {GPIO_SetBits(GPIOA, GPIO_Pin_9);}
	#define WL_OFF    {GPIOA->MODER&=~(2<<18);GPIOA->MODER|=(1<<18);GPIOA->BRR = GPIO_Pin_9;}// {GPIO_ResetBits(GPIOA, GPIO_Pin_9);}
  #define UH_GPIO_PIN  GPIO_Pin_11 

  #define VH_GPIO_PORT GPIOA
  #define VH_GPIO_PIN  GPIO_Pin_15 

  #define WH_GPIO_PORT GPIOA
  #define WH_GPIO_PIN  GPIO_Pin_12
#elif(UVW_OUT == P213)
  #define UH_ON     {TIM1->CCER |= TIM_CCER_CC2E;TIM1->CCER |= TIM_CCER_CC2NE;GPIOA->MODER&=~(1<<18);GPIOA->MODER|=(2<<18);}//TIM1->CR1 |= TIM_CR1_CEN;} 
  #define UH_OFF    {TIM1->CCER &= ~TIM_CCER_CC2E;TIM1->CCER &= ~TIM_CCER_CC2NE;} 
  #define VH_ON     {TIM1->CCER |= TIM_CCER_CC1E;TIM1->CCER |= TIM_CCER_CC1NE;GPIOA->MODER&=~(1<<16);GPIOA->MODER|=(2<<16);}// TIM1->CR1  |= TIM_CR1_CEN;} 
  #define VH_OFF    {TIM1->CCER &= ~TIM_CCER_CC1E;TIM1->CCER &= ~TIM_CCER_CC1NE;}
	#define WH_ON      {TIM1->CCER |= TIM_CCER_CC3E;TIM1->CCER |= TIM_CCER_CC3NE;GPIOA->MODER&=~(1<<20);GPIOA->MODER|=(2<<20);}// TIM1->CR1 |= TIM_CR1_CEN;}  
  #define WH_OFF     {TIM1->CCER &= ~TIM_CCER_CC3E;TIM1->CCER &= ~TIM_CCER_CC3NE;} 

  #define UL_ON     {GPIOA->MODER&=~(2<<18);GPIOA->MODER|=(1<<18);GPIOA->BSRR = GPIO_Pin_9;}// {GPIO_SetBits(GPIOA, GPIO_Pin_9);}
	#define UL_OFF    {GPIOA->MODER&=~(2<<18);GPIOA->MODER|=(1<<18);GPIOA->BRR = GPIO_Pin_9;}
	#define VL_ON     {GPIOA->MODER&=~(2<<16);GPIOA->MODER|=(1<<16);GPIOA->BSRR = GPIO_Pin_8;}// {GPIO_SetBits(GPIOA, GPIO_Pin_8);}
	#define VL_OFF    {GPIOA->MODER&=~(2<<16);GPIOA->MODER|=(1<<16);GPIOA->BRR = GPIO_Pin_8;}
	#define WL_ON     {GPIOA->MODER&=~(2<<20);GPIOA->MODER|=(1<<20);GPIOA->BSRR = GPIO_Pin_10;}// {GPIO_SetBits(GPIOA, GPIO_Pin_10);}
	#define WL_OFF    {GPIOA->MODER&=~(2<<20);GPIOA->MODER|=(1<<20);GPIOA->BRR = GPIO_Pin_10;}
	#define UH_GPIO_PIN  GPIO_Pin_12  

  #define VH_GPIO_PORT GPIOA
  #define VH_GPIO_PIN  GPIO_Pin_11  

  #define WH_GPIO_PORT GPIOA
  #define WH_GPIO_PIN  GPIO_Pin_15
#elif(UVW_OUT == P231)
 #define  UH_ON     {TIM1->CCER |= TIM_CCER_CC2E;TIM1->CCER |= TIM_CCER_CC2NE;GPIOA->MODER&=~(1<<18);GPIOA->MODER|=(2<<18);}//TIM1->CR1 |= TIM_CR1_CEN;} 
  #define UH_OFF    {TIM1->CCER &= ~TIM_CCER_CC2E;TIM1->CCER &= ~TIM_CCER_CC2NE;} 
 #define  VH_ON     {TIM1->CCER |= TIM_CCER_CC3E;TIM1->CCER |= TIM_CCER_CC3NE;GPIOA->MODER&=~(1<<20);GPIOA->MODER|=(2<<20);}// TIM1->CR1 |= TIM_CR1_CEN;}  
  #define VH_OFF    {TIM1->CCER &= ~TIM_CCER_CC3E;TIM1->CCER &= ~TIM_CCER_CC3NE;}  
  #define WH_ON     {TIM1->CCER |= TIM_CCER_CC1E;TIM1->CCER |= TIM_CCER_CC1NE;GPIOA->MODER&=~(1<<16);GPIOA->MODER|=(2<<16);}// TIM1->CR1  |= TIM_CR1_CEN;} 
  #define WH_OFF    {TIM1->CCER &= ~TIM_CCER_CC1E;TIM1->CCER &= ~TIM_CCER_CC1NE;}
	
  #define UL_ON     {GPIOA->MODER&=~(2<<18);GPIOA->MODER|=(1<<18);GPIOA->BSRR = GPIO_Pin_9;}// {GPIO_SetBits(GPIOA, GPIO_Pin_9);}
	#define UL_OFF    {GPIOA->MODER&=~(2<<18);GPIOA->MODER|=(1<<18);GPIOA->BRR = GPIO_Pin_9;} 
	#define VL_ON     {GPIOA->MODER&=~(2<<20);GPIOA->MODER|=(1<<20);GPIOA->BSRR = GPIO_Pin_10;}// {GPIO_SetBits(GPIOA, GPIO_Pin_10);}
	#define VL_OFF    {GPIOA->MODER&=~(2<<20);GPIOA->MODER|=(1<<20);GPIOA->BRR = GPIO_Pin_10;}// {GPIO_ResetBits(GPIOA, GPIO_Pin_10);}
	#define WL_ON     {GPIOA->MODER&=~(2<<16);GPIOA->MODER|=(1<<16);GPIOA->BSRR = GPIO_Pin_8;}// {GPIO_SetBits(GPIOA, GPIO_Pin_8);}
	#define WL_OFF    {GPIOA->MODER&=~(2<<16);GPIOA->MODER|=(1<<16);GPIOA->BRR = GPIO_Pin_8;}
	#define UH_GPIO_PIN  GPIO_Pin_12  

  #define VH_GPIO_PORT GPIOA
  #define VH_GPIO_PIN  GPIO_Pin_15   

  #define WH_GPIO_PORT GPIOA
  #define WH_GPIO_PIN  GPIO_Pin_11
#elif(UVW_OUT == P312)
  #define UH_ON     {TIM1->CCER |= TIM_CCER_CC3E;TIM1->CCER |= TIM_CCER_CC3NE;GPIOA->MODER&=~(1<<20);GPIOA->MODER|=(2<<20);}// TIM1->CR1 |= TIM_CR1_CEN;}  
  #define UH_OFF    {TIM1->CCER &= ~TIM_CCER_CC3E;TIM1->CCER &= ~TIM_CCER_CC3NE;}  
  #define VH_ON     {TIM1->CCER |= TIM_CCER_CC1E;TIM1->CCER |= TIM_CCER_CC1NE;GPIOA->MODER&=~(1<<16);GPIOA->MODER|=(2<<16);}// TIM1->CR1  |= TIM_CR1_CEN;} 
  #define VH_OFF    {TIM1->CCER &= ~TIM_CCER_CC1E;TIM1->CCER &= ~TIM_CCER_CC1NE;}
	#define WH_ON     {TIM1->CCER |= TIM_CCER_CC2E;TIM1->CCER |= TIM_CCER_CC2NE;GPIOA->MODER&=~(1<<18);GPIOA->MODER|=(2<<18);}//TIM1->CR1 |= TIM_CR1_CEN;} 
  #define WH_OFF    {TIM1->CCER &= ~TIM_CCER_CC2E;TIM1->CCER &= ~TIM_CCER_CC2NE;} 
 
	#define UL_ON    {GPIOA->MODER&=~(2<<20);GPIOA->MODER|=(1<<20);GPIOA->BSRR = GPIO_Pin_10;}// {GPIO_SetBits(GPIOA, GPIO_Pin_10);}
	#define UL_OFF   {GPIOA->MODER&=~(2<<20);GPIOA->MODER|=(1<<20);GPIOA->BRR = GPIO_Pin_10;}// {GPIO_ResetBits(GPIOA, GPIO_Pin_10);}
	#define VL_ON     {GPIOA->MODER&=~(2<<16);GPIOA->MODER|=(1<<16);GPIOA->BSRR = GPIO_Pin_8;}// {GPIO_SetBits(GPIOA, GPIO_Pin_8);}
	#define VL_OFF    {GPIOA->MODER&=~(2<<16);GPIOA->MODER|=(1<<16);GPIOA->BRR = GPIO_Pin_8;}
	#define WL_ON    {GPIOA->MODER&=~(2<<18);GPIOA->MODER|=(1<<18);GPIOA->BSRR = GPIO_Pin_9;}// {GPIO_SetBits(GPIOA, GPIO_Pin_9);}
	#define WL_OFF   {GPIOA->MODER&=~(2<<18);GPIOA->MODER|=(1<<18);GPIOA->BRR = GPIO_Pin_9;}// {GPIO_ResetBits(GPIOA, GPIO_Pin_9);}
  #define UH_GPIO_PIN  GPIO_Pin_15   

  #define VH_GPIO_PORT GPIOA
  #define VH_GPIO_PIN  GPIO_Pin_11   

  #define WH_GPIO_PORT GPIOA
  #define WH_GPIO_PIN  GPIO_Pin_12 
#elif(UVW_OUT == P321)
  #define UH_ON     {TIM1->CCER |= TIM_CCER_CC3E;TIM1->CCER |= TIM_CCER_CC3NE;GPIOA->MODER&=~(1<<20);GPIOA->MODER|=(2<<20);}// TIM1->CR1 |= TIM_CR1_CEN;}  
  #define UH_OFF    {TIM1->CCER &= ~TIM_CCER_CC3E;TIM1->CCER &= ~TIM_CCER_CC3NE;} 
  #define VH_ON     {TIM1->CCER |= TIM_CCER_CC2E;TIM1->CCER |= TIM_CCER_CC2NE;GPIOA->MODER&=~(1<<18);GPIOA->MODER|=(2<<18);}//TIM1->CR1 |= TIM_CR1_CEN;} 
  #define VH_OFF    {TIM1->CCER &= ~TIM_CCER_CC2E;TIM1->CCER &= ~TIM_CCER_CC2NE;} 
  #define WH_ON     {TIM1->CCER |= TIM_CCER_CC1E;TIM1->CCER |= TIM_CCER_CC1NE;GPIOA->MODER&=~(1<<16);GPIOA->MODER|=(2<<16);}// TIM1->CR1  |= TIM_CR1_CEN;} 
  #define WH_OFF    {TIM1->CCER &= ~TIM_CCER_CC1E;TIM1->CCER &= ~TIM_CCER_CC1NE;}
 
	#define UL_ON    {GPIOA->MODER&=~(2<<20);GPIOA->MODER|=(1<<20);GPIOA->BSRR = GPIO_Pin_10;}// {GPIO_SetBits(GPIOA, GPIO_Pin_10);}
	#define UL_OFF   {GPIOA->MODER&=~(2<<20);GPIOA->MODER|=(1<<20);GPIOA->BRR = GPIO_Pin_10;}// {GPIO_ResetBits(GPIOA, GPIO_Pin_10);}
	#define VL_ON    {GPIOA->MODER&=~(2<<18);GPIOA->MODER|=(1<<18);GPIOA->BSRR = GPIO_Pin_9;}// {GPIO_SetBits(GPIOA, GPIO_Pin_9);}
	#define VL_OFF   {GPIOA->MODER&=~(2<<18);GPIOA->MODER|=(1<<18);GPIOA->BRR = GPIO_Pin_9;}// {GPIO_ResetBits(GPIOA, GPIO_Pin_9);}
	#define WL_ON    {GPIOA->MODER&=~(2<<16);GPIOA->MODER|=(1<<16);GPIOA->BSRR = GPIO_Pin_8;}// {GPIO_SetBits(GPIOA, GPIO_Pin_8);}
	#define WL_OFF   {GPIOA->MODER&=~(2<<16);GPIOA->MODER|=(1<<16);GPIOA->BRR = GPIO_Pin_8;}// {GPIO_ResetBits(GPIOA, GPIO_Pin_8);}
 
  #define UH_GPIO_PORT GPIOA
  #define UH_GPIO_PIN  GPIO_Pin_15

  #define VH_GPIO_PORT GPIOA
  #define VH_GPIO_PIN  GPIO_Pin_12

  #define WH_GPIO_PORT GPIOA
  #define WH_GPIO_PIN  GPIO_Pin_11
#endif

//PWM操作函数
#define PWM_START()     {TIM1->BDTR |= TIM_BDTR_MOE;}
#define PWM_STOP()      {TIM1->BDTR &= (~TIM_BDTR_MOE);}
//#define PWM_AL_ON       UL_ON
#define PWM_UPDATA      {TIM1->CR2 |= TIM_CR2_CCPC;TIM1->EGR |= TIM_EGR_COMG;}
//#define PWM_AL_BH_ON()  {VL_OFF;UH_OFF;WH_OFF;WL_OFF;VH_ON;UL_ON;PWM_UPDATA;}
//#define PWM_AL_CH_ON()  {WL_OFF;UH_OFF;VH_OFF;VL_OFF;WH_ON;UL_ON;PWM_UPDATA;}// {WH_ON;UH_OFF;VH_OFF;VL_OFF;WL_OFF;UL_ON;}
//#define PWM_BL_CH_ON()  {WL_OFF;VH_OFF;UH_OFF;UL_OFF;WH_ON;VL_ON;PWM_UPDATA;}
//#define PWM_BL_AH_ON()  {UL_OFF;VH_OFF;WH_OFF;WL_OFF;UH_ON;VL_ON;PWM_UPDATA;}
//#define PWM_CL_AH_ON()  {UL_OFF;WH_OFF;VH_OFF;VL_OFF;UH_ON;WL_ON;PWM_UPDATA;}
//#define PWM_CL_BH_ON()  {VL_OFF;UH_OFF;WH_OFF;UL_OFF;VH_ON;WL_ON;PWM_UPDATA;}

#define PWM_AL_BH_ON()  {UH_OFF;WH_OFF;WL_OFF;UL_ON;VH_ON;PWM_UPDATA;}//
#define PWM_AL_CH_ON()  {UH_OFF;VH_OFF;VL_OFF;UL_ON;WH_ON;PWM_UPDATA;}// TIM1->CR1 &= ~TIM_CR1_CEN;TIM1->CR1 |= TIM_CR1_CEN; {WH_ON;UH_OFF;VH_OFF;VL_OFF;WL_OFF;UL_ON;}
#define PWM_BL_CH_ON()  {VH_OFF;UH_OFF;UL_OFF;VL_ON;WH_ON;PWM_UPDATA;}
#define PWM_BL_AH_ON()  {VH_OFF;WH_OFF;WL_OFF;VL_ON;UH_ON;PWM_UPDATA;}
#define PWM_CL_AH_ON()  {WH_OFF;VH_OFF;VL_OFF;WL_ON;UH_ON;PWM_UPDATA;}
#define PWM_CL_BH_ON()  {UH_OFF;WH_OFF;UL_OFF;WL_ON;VH_ON;PWM_UPDATA;}

#define PWM_AL_BH_CH_ON()  {VL_OFF;UH_OFF;WL_OFF;VH_ON;WH_ON;UL_ON;PWM_UPDATA;}
#define PWM_AL_BL_CH_ON()  {VH_OFF;UH_OFF;WL_OFF;VL_ON;WH_ON;UL_ON;PWM_UPDATA;}
#define PWM_BL_AH_CH_ON()  {VH_OFF;UL_OFF;WH_OFF;VL_ON;WH_ON;UH_ON;PWM_UPDATA;}
#define PWM_BH_AH_CL_ON()  {VL_OFF;UL_OFF;WH_OFF;VH_ON;WL_ON;UH_ON;PWM_UPDATA;}	
#define UH_VL    {UH_ON;VH_OFF;WH_OFF;UL_OFF;WL_OFF;VL_ON;}
#define UH_WL    {UH_ON;VH_OFF;WH_OFF;UL_OFF;VL_OFF;WL_ON;}

#define VH_UL    {VH_ON;UH_OFF;WH_OFF;VL_OFF;WL_OFF;UL_ON;}
#define VH_WL    {VH_ON;UH_OFF;WH_OFF;UL_OFF;VL_OFF;WL_ON;}

#define WH_UL    {WH_ON;UH_OFF;VH_OFF;VL_OFF;WL_OFF;UL_ON;}
#define WH_VL    {WH_ON;UH_OFF;VH_OFF;UL_OFF;WL_OFF;VL_ON;}

#define UH_WH_VL  {UH_ON;VH_OFF;WH_ON;UL_OFF;VL_ON;WL_OFF;}

//#define AB  UH_VL
//#define AC  UH_WL
//#define BC  VH_WL
//#define BA  VH_UL
//#define CA  WH_UL
//#define CB  WH_VL


#define UH_ON2 {GPIO_SetBits(UH_GPIO_PORT,UH_GPIO_PIN);}
#define UH_OFF2 {GPIO_ResetBits(UH_GPIO_PORT,UH_GPIO_PIN);}
#define VH_ON2 {GPIO_SetBits(VH_GPIO_PORT,VH_GPIO_PIN);}
#define VH_OFF2 {GPIO_ResetBits(VH_GPIO_PORT,VH_GPIO_PIN);}
#define WH_ON2 {GPIO_SetBits(WH_GPIO_PORT,WH_GPIO_PIN);}
#define WH_OFF2 {GPIO_ResetBits(WH_GPIO_PORT,WH_GPIO_PIN);}

#define AB   {VH_OFF2 WH_OFF2 WL_OFF UL_OFF UH_ON2 VL_ON}
#define AC   {WH_OFF2 VH_OFF2 UL_OFF VL_OFF UH_ON2 WL_ON} 
#define BC   {WH_OFF2 UH_OFF2 UL_OFF VL_OFF VH_ON2 WL_ON}
#define BA   {WH_OFF2 UH_OFF2 WL_OFF VL_OFF VH_ON2 UL_ON}
#define CA   {VH_OFF2 UH_OFF2 WL_OFF VL_OFF WH_ON2 UL_ON}
#define CB   {VH_OFF2 UH_OFF2 WL_OFF UL_OFF WH_ON2 VL_ON}
#define  ALL_OFF {WH_OFF2 VH_OFF2 UH_OFF2 WL_OFF UL_OFF VL_OFF }
//***********************Fan Soft Start Config**********************
#define M_IPD_TIME              1
#define M_IPDd_TIME             200

#define M_PRESTART_TIME			    (8)
#define M_PRESTOPSTART_TIME			(M_PRESTART_TIME+8)//  25//50//60	//0.1
#define M_RESET_TIME			      (M_PRESTOPSTART_TIME+2)//50//60	//0.1


#define FAN_SOFTSTART_DELAY		  10//150	//ms
#define M_PWM_ADDDUTY	          1//35//15//25	//%


#define M_SOFTSTART_MAXDUTY	    13//  启动最大占空比设置（15%）
#define M_SOFTSTART_MINDUTY	    (M_SOFTSTART_MAXDUTY-4)  //11%  启动最小占空比设置（11%）
#define M_SOFTSTART_ENDDUTY	    (M_SOFTSTART_MAXDUTY+2)  //  软件启动结束占空比
#define M_PRE_PWMDUTY           (M_SOFTSTART_MAXDUTY*4/5)//22
//************************************************************************************************//
#define PWM_PRD_CNT			           PWM_PERIOD//((SystemCoreClock / PWM_CLK ) - 1)//	(((IHRC_FREQ<<5)/PWM_OUT_FREQ)/2)		//?f?B????~?p??2
#define PWM_DUTY_PERCENT(DUTY)		((PWM_PRD_CNT*DUTY)/100)

#define FSS_START_DUTY				     PWM_DUTY_PERCENT(M_SOFTSTART_MAXDUTY)
#define FSS_END_DUTY				       PWM_DUTY_PERCENT(M_SOFTSTART_ENDDUTY)
//#define FSS_PRE_DUTY				       PWM_DUTY_PERCENT(M_PRE_PWMDUTY)
#define START_PWM_MINDUTY				   PWM_DUTY_PERCENT(M_SOFTSTART_MINDUTY)    //启动最小占空比
#define PWM_SET_DUTY(DUTY)  {TIM1->CCR2 = DUTY;TIM1->CCR1 = DUTY;TIM1->CCR3 = DUTY;TIM1->EGR |= TIM_EGR_COMG;}
#define  FSS_PRE_DUTY()        {PWM_SET_DUTY(PWM_DUTY_PERCENT(M_PRE_PWMDUTY));}
#define M_WMAX_VDD                 (8.4)     //电机最高工作电压
#define M_WMIX_VDD                  (6.2)      //电机最低工作电压
#define PWM_COM                    (((M_WMAX_VDD-M_WMIX_VDD)*(4096/AD_REF*R_DOWN/(R_DOWN+R_UP)))/(FSS_START_DUTY-START_PWM_MINDUTY))

#define PWM_CAPTURE_IO              GPIO_Pin_4
//******************************************************************//
void TIM1_PWM_Config(void);
void TIM3_PwmCap_Init(void);
void PwmCap_IRQ(void);
void pwm_cap_process(void);


