中级会员
 
- 积分
- 378
- 金钱
- 378
- 注册时间
- 2018-7-16
- 在线时间
- 58 小时
|
1金钱
本帖最后由 wgb123 于 2018-10-8 11:22 编辑
/** * @brief Checks whether the TIM interrupt has occurred or not. //判断是否发生定时器中断
* @param TIMx: where x can be 1 to 17 to select the TIM peripheral. //选择外设TIMx
* @param TIM_IT: specifies the TIM interrupt source to check. //中断源 下面八种之一
* This parameter can be one of the following values:
* @arg TIM_IT_Update: TIM update Interrupt source
* @arg TIM_IT_CC1: TIM Capture Compare 1 Interrupt source
* @arg TIM_IT_CC2: TIM Capture Compare 2 Interrupt source
* @arg TIM_IT_CC3: TIM Capture Compare 3 Interrupt source
* @arg TIM_IT_CC4: TIM Capture Compare 4 Interrupt source
* @arg TIM_IT_COM: TIM Commutation Interrupt source
* @arg TIM_IT_Trigger: TIM Trigger Interrupt source
* @arg TIM_IT_Break: TIM Break Interrupt source
* @note
* - TIM6 and TIM7 can generate only an update interrupt.
* - TIM9, TIM12 and TIM15 can have only TIM_IT_Update, TIM_IT_CC1,
* TIM_IT_CC2 or TIM_IT_Trigger.
* - TIM10, TIM11, TIM13, TIM14, TIM16 and TIM17 can have TIM_IT_Update or TIM_IT_CC1.
* - TIM_IT_Break is used only with TIM1, TIM8 and TIM15.
* - TIM_IT_COM is used only with TIM1, TIM8, TIM15, TIM16 and TIM17.
* @retval The new state of the TIM_IT(SET or RESET). //返回值
*/
ITStatus TIM_GetITStatus(TIM_TypeDef* TIMx, uint16_t TIM_IT)
{
ITStatus bitstatus = RESET;
uint16_t itstatus = 0x0, itenable = 0x0;
/* Check the parameters */
assert_param(IS_TIM_ALL_PERIPH(TIMx));
assert_param(IS_TIM_GET_IT(TIM_IT));
TIM_IT = TIM_IT_CC1=0x0002
itstatus = TIMx->SR & TIM_IT; // CC1IF 当捕获事件发生时该位由硬件置,这里怎么由软件置一?(输入捕获实验)
itenable = TIMx->DIER & TIM_IT; //使能 CC1IE
if ((itstatus != (uint16_t)RESET) && (itenable != (uint16_t)RESET)) //由上面两个语句这个条件不是一直成立么?
{
bitstatus = SET;
}
else
{
bitstatus = RESET;
}
return bitstatus;
}
|
最佳答案
查看完整内容[请看2#楼]
后面不是已经判断过了啊,之后还要它干啥呢。就判断他们是否SET的时候,要用到的bitstatus已经返回了啊,itstatus和itenable只是用来判断决定bitstatus的值的么不是
|