打印

LM3S9B96的例程usb_dev_bulk中断问题

[复制链接]
2718|3
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
sdman001|  楼主 | 2012-4-2 12:39 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
我看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);
    }
}

相关帖子

沙发
gaga1| | 2012-4-2 20:15 | 只看该作者
不是很清楚 帮楼主顶下了

使用特权

评论回复
板凳
gaga1| | 2012-4-2 20:16 | 只看该作者
希望有专家帮你解答

使用特权

评论回复
地板
iEye| | 2012-4-6 18:52 | 只看该作者
在usbdbulk.c里面有,这部分实际上被USB驱动库封装起来了,例程里采用回调函数进行数据发送和接受滴。

//*****************************************************************************
//
// This function is called to handle the interrupts on the Bulk endpoints for
// the mass storage class.
//
//*****************************************************************************
static void
HandleEndpoints(unsigned long ulIndex, unsigned long ulStatus)

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

3

主题

5

帖子

0

粉丝