#include "pit.h"

//动态显示的定时器
void PIT1_Init(void)	
{
	NVIC_Init(1, 1, PIT1_IRQn, 2);
	
	PIT1->PCSR &= (~PIT_PCSR_EN);
	PIT1->PCSR = (5<<8)|PIT_PCSR_OVW|PIT_PCSR_PIE|PIT_PCSR_RLD|PIT_PCSR_PDBG; //125mhz/32  中断模式
	PIT1->PMR = 39062;//10ms	
	PIT1->PCSR |= PIT_PCSR_EN;
}

void PIT1_Init_1(void)	
{
	NVIC_Init(1, 1, PIT1_IRQn, 2);
	
	PIT1->PCSR = (5<<8)|PIT_PCSR_OVW|PIT_PCSR_RLD|PIT_PCSR_PDBG; //125mhz/32  中断模式
	
	PIT1->PCSR&=~PIT_PCSR_PIE;
	
	PIT1->PMR = 58594;//15ms
	PIT1->PCSR&=~PIT_PCSR_EN;	
}

void PIT1_IRQHandler(void)
{	
	
}

void LT_UsartTimeDisable(void)
{
	PIT1->PCSR &=~PIT_PCSR_PIE;
	PIT1->PCSR &=~PIT_PCSR_EN;
}

//使能定时器14
void LT_UsartTimeEnable(void)
{
//	gRxfist = 0;
	PIT1->PCSR |=PIT_PCSR_PIE;
	PIT1->PCSR |=PIT_PCSR_EN;
}

//设置定时器14装载值
void LT_UsartTimeSetCounter(UINT32 Counter)
{
	PIT1->PMR = Counter;//
	PIT1->PCSR |=PIT_PCSR_PIF;
	LT_UsartTimeEnable();
}

#if WAV_FLAG
//控制Wav播放的定时器
void PIT2_Init(UINT16 arr)
{
	NVIC_Init(2, 0, PIT2_IRQn, 2);
	
	PIT2->PCSR &= (~PIT_PCSR_EN);
	PIT2->PCSR = (0<<8)|PIT_PCSR_OVW|PIT_PCSR_PIE|PIT_PCSR_RLD|PIT_PCSR_PDBG; //125mhz/1  中断模式
	PIT2->PMR = arr-3;	
	
	PIT2->PCSR &=~PIT_PCSR_EN;
}

void PIT2_IRQHandler(void)
{
				
}
#endif
