Board logo

标题: STM32的USB例程JoyStickMouse代码分析(4) [打印本页]

作者: yuyang911220    时间: 2014-9-22 12:40     标题: STM32的USB例程JoyStickMouse代码分析(4)

4、中断处理过程大致理解

1usb_istr()函数中的中断处理简单分析

有用的代码大概以下几段,首先是处理复位的代码,调用设备结构中的复位处理函数。


wIstr = _GetISTR();


if (wIstr & ISTR_RESET & wInterrupt_Mask)


{


_SetISTR((u16)CLR_RESET); //
清复位中断



Device_Property.Reset();


}

处理唤醒的代码:


if (wIstr & ISTR_WKUP & wInterrupt_Mask)


{


_SetISTR((u16)CLR_WKUP);


Resume(RESUME_EXTERNAL);


}

处理总线挂起的代码:


if (wIstr & ISTR_SUSP & wInterrupt_Mask)


{


if (fSuspendEnabled) /* check if SUSPEND is possible */


{


Suspend();


}


else


{


/* if not possible then resume after xx ms */



Resume(RESUME_LATER);


}


/* clear of the ISTR bit must be done after setting of CNTR_FSUSP */


_SetISTR((u16)CLR_SUSP);


}

处理端点传输完成的代码,这段是最重要的,它调用底层usb_int.c()文件中的CTR_LP()函数来处理端点数据传输完成中断。


if (wIstr & ISTR_CTR & wInterrupt_Mask)


{


CTR_LP(); /* servicing of the endpoint correct transfer interrupt */


}






欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) Powered by Discuz! 7.0.0