求香主和各位高手指教,我现在的USB收发数据仅仅只是通过查询的方式实现,现在需要用中断实现,
问题1:不知道怎么进入中断函数USB_LP_CAN1_RX0_IRQHandler();
问题2:进了USB_LP_CAN1_RX0_IRQHandler(),然后进USB_Istr(),代码如下
#if (IMR_MSK & ISTR_CTR)
if (wIstr & ISTR_CTR & wInterrupt_Mask)
{
/* servicing of the endpoint correct transfer interrupt */
/* clear of the CTR flag into the sub */
CTR_LP();
#ifdef CTR_CALLBACK
CTR_Callback();
#endif
}
#endif
如果有数据传输就会调用CTR_LP(),进入CTR_LP(),
void CTR_LP(void)
{
__IO uint16_t wEPVal = 0;
while (((wIstr = _GetISTR()) & ISTR_CTR) != 0)
{
EPindex = (uint8_t)(wIstr & ISTR_EP_ID);
if (EPindex == 0)
{
SaveRState = _GetENDPOINT(ENDP0);
SaveTState = SaveRState & EPTX_STAT;
SaveRState &= EPRX_STAT;
_SetEPRxTxStatus(ENDP0,EP_RX_NAK,EP_TX_NAK);
if ((wIstr & ISTR_DIR) == 0)
{
_ClearEP_CTR_TX(ENDP0);
In0_Process();
_SetEPRxTxStatus(ENDP0,SaveRState,SaveTState);
return;
}
else
{
wEPVal = _GetENDPOINT(ENDP0);
if ((wEPVal &EP_SETUP) != 0)
{
_ClearEP_CTR_RX(ENDP0);
Setup0_Process();
_SetEPRxTxStatus(ENDP0,SaveRState,SaveTState);
return;
}
else if ((wEPVal & EP_CTR_RX) != 0)
{
_ClearEP_CTR_RX(ENDP0);
Out0_Process();
_SetEPRxTxStatus(ENDP0,SaveRState,SaveTState);
return;
}
}
}
else
{
wEPVal = _GetENDPOINT(EPindex);
if ((wEPVal & EP_CTR_RX) != 0)
{
_ClearEP_CTR_RX(EPindex);
(*pEpInt_OUT[EPindex-1])();
}
if ((wEPVal & EP_CTR_TX) != 0)
{
_ClearEP_CTR_TX(EPindex);
(*pEpInt_IN[EPindex-1])();
}
}
}
}
ISTR_EP_ID又是怎样识别的? |