void timer_capture_init(void)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2);
//使能定时器捕获上升沿所在GPIO
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
GPIOPinConfigure(GPIO_PB4_T1CCP0);
GPIOPinTypeTimer(GPIO_PORTB_BASE,GPIO_PIN_4);
//配置TIMER1为输入边沿计时模式
TimerConfigure(TIMER1_BASE,TIMER_CFG_SPLIT_PAIR|TIMER_CFG_A_CAP_TIME);
TimerControlEvent(TIMER1_BASE,TIMER_A,TIMER_EVENT_POS_EDGE);
//配置TIMER2为周期计数模式
TimerConfigure(TIMER2_BASE,TIMER_CFG_SPLIT_PAIR|TIMER_CFG_A_PERIODIC);
//设置两个定时器的初值
TimerLoadSet(TIMER1_BASE,TIMER_A,0xFFFF);
TimerLoadSet(TIMER2_BASE,TIMER_A,0xFFFF);
//配置定时器1和定时器2的中断,定时器1为捕获中断,定时器2为溢出中断
TimerIntEnable(TIMER1_BASE,TIMER_CAPA_EVENT);
TimerIntEnable(TIMER2_BASE,TIMER_TIMA_TIMEOUT);
IntRegister(INT_TIMER1A,Timer1IntHandler);
IntRegister(INT_TIMER2A,Timer2IntHandler);
IntEnable(INT_TIMER1A);
IntEnable(INT_TIMER2A);
IntMasterEnable();//启用处理器中断
//设置中断优先级,周期定时器抢占优先级等于捕获定时器
IntPrioritySet(INT_TIMER1A,0);
IntPrioritySet(INT_TIMER2A,0);
//两个定时器同时触发
TimerEnable(TIMER1_BASE,TIMER_A);
TimerEnable(TIMER2_BASE,TIMER_A);
TimerSynchronize(TIMER0_BASE,TIMER_1A_SYNC|TIMER_2A_SYNC);
}