/* Initialize the trigger timer when in Comparator Timer-Trigger Mode.  */
void CMP_TimerTrigCmd(u8 Tim_Idx, u32 PeriodMs, u32 NewState)
/* Initialize the trigger timer when in Comparator Timer-Trigger Mode.  */
void CMP_TimerTrigCmd(u8 Tim_Idx, u32 PeriodMs, u32 NewState)
{
	CMP_TypeDef *comparator = COMPARATOR;
	RTIM_TimeBaseInitTypeDef TIM_InitStruct;
	comparator->COMP_EXT_TRIG_TIMER_SEL = Tim_Idx;
	if(NewState != DISABLE) {
		RTIM_TimeBaseStructInit(&TIM_InitStruct);
		TIM_InitStruct.TIM_Idx = Tim_Idx;
		TIM_InitStruct.TIM_Period = (PeriodMs *32768)/1000/2;
		RTIM_TimeBaseInit(TIMx_LP[Tim_Idx], &TIM_InitStruct, TIMx_irq_LP[Tim_Idx], (IRQ_FUN)NULL, (u32)NULL);
		RTIM_Cmd(TIMx_LP[Tim_Idx], ENABLE);
		comparator->COMP_EXT_TRIG_CTRL = BIT_COMP_EXT_WK_TIMER;
	} else {
		RTIM_Cmd(TIMx_LP[Tim_Idx], DISABLE);
		comparator->COMP_EXT_TRIG_CTRL = 0;
	}
}