我看usb_dev_bulk例程,没用发现在何处处理bulk接口IN中断,下面是我的理解
首先,在启动代码startup_ewarm.c中定义了USB中断函数
__root const uVectorEntry __vector_table[] @ ".intvec" =
{
{ .ulPtr = (unsigned long)pulStack + sizeof(pulStack) },
// The initial stack pointer
ResetISR, // The reset handler
NmiSR, // The NMI handler
FaultISR, // The hard fault handler
.......
USB0DeviceIntHandler, // USB0
.......
};
USB0DeviceIntHandler函数在usblib/device/usbdhandler.c文件中定义
void USB0DeviceIntHandler(void)
{
unsigned long ulStatus;
//
// Get the controller interrupt status.
//
ulStatus = MAP_USBIntStatusControl(USB0_BASE);
//
// Call the internal handler.
//
USBDeviceIntHandlerInternal(0, ulStatus);
}
其实际处理usb中断的函数USBDeviceIntHandlerInternal在usblib/device/usbdenum.c 中定义,以下是这个函数的代码,可是我怎么也找不到何处是处理bulk IN
或bulk out的代码,就是说没有地方反映主机发来一个针对BULK端点的IN或OUT令牌。哪位知道,给指点指点,多谢!
USBDeviceIntHandlerInternal(unsigned long ulIndex, unsigned long ulStatus)
{
static unsigned long ulSOFDivide = 0;
tDeviceInfo *psInfo;
void *pvInstance;
//
// If device initialization has not been performed then just disconnect
// from the USB bus and return from the handler.
//
if(g_psUSBDevice[0].psInfo == 0)
{
MAP_USBDevDisconnect(USB0_BASE);
return;
}
psInfo = g_psUSBDevice[0].psInfo;
pvInstance = g_psUSBDevice[0].pvInstance;
//
// Received a reset from the host.
//
if(ulStatus & USB_INTCTRL_RESET)
{
USBDeviceEnumResetHandler(&g_psUSBDevice[0]);
}
//
// Suspend was signaled on the bus.
//
if(ulStatus & USB_INTCTRL_SUSPEND)
{
//
// Call the SuspendHandler() if it was specified.
//
if(psInfo->sCallbacks.pfnSuspendHandler)
{
psInfo->sCallbacks.pfnSuspendHandler(pvInstance);
}
}
//
// Resume was signaled on the bus.
//
if(ulStatus & USB_INTCTRL_RESUME)
{
//
// Call the ResumeHandler() if it was specified.
//
if(psInfo->sCallbacks.pfnResumeHandler)
{
psInfo->sCallbacks.pfnResumeHandler(pvInstance);
}
}
//
// USB device was disconnected.
//
if(ulStatus & USB_INTCTRL_DISCONNECT)
{
//
// Call the DisconnectHandler() if it was specified.
//
if(psInfo->sCallbacks.pfnDisconnectHandler)
{
psInfo->sCallbacks.pfnDisconnectHandler(pvInstance);
}
}
//
// Start of Frame was received.
//
if(ulStatus & USB_INTCTRL_SOF)
{
//
// Increment the global Start of Frame counter.
//
g_ulUSBSOFCount++;
//
// Increment our SOF divider.
//
ulSOFDivide++;
//
// Handle resume signaling if required.
//
USBDeviceResumeTickHandler(&g_psUSBDevice[0]);
//
// Have we counted enough SOFs to allow us to call the tick function?
//
if(ulSOFDivide == USB_SOF_TICK_DIVIDE)
{
//
// Yes - reset the divider and call the SOF tick handler.
//
ulSOFDivide = 0;
InternalUSBStartOfFrameTick(USB_SOF_TICK_DIVIDE);
}
}
//
// Get the controller interrupt status.
//
ulStatus = MAP_USBIntStatusEndpoint(USB0_BASE);
//
// Handle end point 0 interrupts.
//
if(ulStatus & USB_INTEP_0)
{
USBDeviceEnumHandler(&g_psUSBDevice[0]);
}
//
// Because there is no way to detect if a uDMA interrupt has occurred,
// check for an endpoint callback and call it if it is available.
//
if(psInfo->sCallbacks.pfnEndpointHandler)
{
psInfo->sCallbacks.pfnEndpointHandler(pvInstance, ulStatus);
}
} |