新手入门
- 积分
- 15
- 金钱
- 15
- 注册时间
- 2016-3-18
- 在线时间
- 1 小时
|
1金钱
[mw_shl_code=c,true]void cap_Init(void)
{
irda_state = IR_STATE_IDLE;
irda_Index = 0;
cap_IO_Init();
//定时器周期1us
TIM2_TimeBaseInit(TIM2_PRESCALER_16, 0xffff);
// TIM2_Cmd(ENABLE);
//下降沿捕获
TIM2_ICInit(TIM2_CHANNEL_2, TIM2_ICPOLARITY_FALLING, TIM2_ICSELECTION_DIRECTTI, TIM2_ICPSC_DIV1, 0x0F);
//开启捕获2中断和更新中断
TIM2_ITConfig(TIM2_IT_UPDATE, ENABLE);
TIM2_ITConfig(TIM2_IT_CC2, ENABLE);
TIM2_ClearFlag(TIM2_FLAG_CC2);
TIM2_Cmd(ENABLE);
// TIM2_GenerateEvent(TIM2_EVENTSOURCE_CC2);
}[/mw_shl_code][mw_shl_code=c,true]void cap_IO_Init(void)
{
GPIO_DeInit(GPIOD);
GPIO_Init(GPIOD, GPIO_PIN_3, GPIO_MODE_IN_PU_NO_IT);
//GPIO_Init(GPIOD, GPIO_PIN_3, GPIO_MODE_IN_PU_IT);
//EXTI_SetExtIntSensitivity(EXTI_PORT_GPIOD, EXTI_SENSITIVITY_FALL_ONLY);
}[/mw_shl_code]
|
|