⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 s3c2510usb.c

📁 VxWorks BSP for S3C2510A
💻 C
📖 第 1 页 / 共 3 页
字号:
            s3c2510UsbGetConfig();
            break;

        case USB_REQUEST_SET_CONFIGURATION:
#ifdef  DEBUG_TRACE
            printf("USB_REQUEST_SET_CONFIGURATION\n");
#endif  /* DEBUG_TRACE */
            s3c2510UsbSetConfig();
            break;

        default:
            printf("s3c2510Usb Error: Unknown request, 0x%02X\n", usbSetup.bRequest);
            *S3C2510_USBCSR(0) |= S3C2510_USBEP0CSR_USBSVORDY | S3C2510_USBEP0CSR_USBDEND;
            break;
        }
        break;

    case USB_RT_INTERFACE:
#ifdef  DEBUG_TRACE
        printf("USB_RT_INTERFACE\n");
#endif  /* DEBUG_TRACE */
        switch (usbSetup.bRequest)
        {
        case USB_REQUEST_GET_INTERFACE:
#ifdef  DEBUG_TRACE
            printf("USB_REQUEST_GET_INTERFACE\n");
#endif  /* DEBUG_TRACE */
            s3c2510UsbGetInterface();
            break;

        case USB_REQUEST_SET_INTERFACE:
#ifdef  DEBUG_TRACE
            printf("USB_REQUEST_SET_INTERFACE\n");
#endif  /* DEBUG_TRACE */
            s3c2510UsbSetInterface();
            break;

        default:
            printf("s3c2510Usb Error: Unknown request, 0x%02X\n", usbSetup.bRequest);
            *S3C2510_USBCSR(0) |= S3C2510_USBEP0CSR_USBSVORDY | S3C2510_USBEP0CSR_USBDEND;
            break;
        }
        break;

    case USB_RT_ENDPOINT:
#ifdef  DEBUG_TRACE
        printf("USB_RT_ENDPOINT\n");
#endif  /* DEBUG_TRACE */
        switch (usbSetup.bRequest)
        {
        case USB_REQUEST_GET_STATUS:
#ifdef  DEBUG_TRACE
            printf("USB_REQUEST_GET_STATUS\n");
#endif  /* DEBUG_TRACE */
            s3c2510UsbGetStatus();
            break;

        case USB_REQUEST_CLEAR_FEATURE:
#ifdef  DEBUG_TRACE
            printf("USB_REQUEST_CLEAR_FEATURE\n");
#endif  /* DEBUG_TRACE */
            s3c2510UsbClearFeature();
            break;

        case USB_REQUEST_SET_FEATURE:
#ifdef  DEBUG_TRACE
            printf("USB_REQUEST_SET_FEATURE\n");
#endif  /* DEBUG_TRACE */
            s3c2510UsbSetFeature();
            break;

        case USB_REQUEST_GET_DESCRIPTOR:
#ifdef  DEBUG_TRACE
            printf("USB_REQUEST_GET_DESCRIPTOR\n");
#endif  /* DEBUG_TRACE */
            s3c2510UsbGetDescriptor();
            break;

        case USB_REQUEST_SYNC_FRAME:
#ifdef  DEBUG_TRACE
            printf("USB_REQUEST_SYNC_FRAME\n");
#endif  /* DEBUG_TRACE */
            s3c2510UsbSyncFrame();
            break;

        default:
            printf("s3c2510Usb Error: Unknown request, 0x%02X\n", usbSetup.bRequest);
            *S3C2510_USBCSR(0) |= S3C2510_USBEP0CSR_USBSVORDY | S3C2510_USBEP0CSR_USBDEND;
            break;
        }
        break;

    case USB_RT_OTHER:
#ifdef  DEBUG_TRACE
        printf("USB_RT_OTHER\n");
#endif  /* DEBUG_TRACE */
        *S3C2510_USBCSR(0) |= S3C2510_USBEP0CSR_USBSVORDY | S3C2510_USBEP0CSR_USBDEND;
        break;

    default:
        printf("s3c2510Usb Error: Unknown recipient, 0x%02X\n", recipient);
        *S3C2510_USBCSR(0) |= S3C2510_USBEP0CSR_USBSVORDY | S3C2510_USBEP0CSR_USBDEND;
        break;
    }
}

/*******************************************************************************
*
* s3c2510UsbDeviceRequestClass - handle Standard Class Request.
*
* RETURNS : N/A
*/

void s3c2510UsbDeviceRequestClass(void)
{
}

/*******************************************************************************
*
* s3c2510UsbDeviceRequestVendor - handle Standard Vendor Request.
*
* RETURNS : N/A
*/

void s3c2510UsbDeviceRequestVendor(void)
{
}

/*******************************************************************************
*
* s3c2510UsbInt - interrupt service routine.
*
* RETURNS : N/A
*/

void s3c2510UsbInt(void)
{
    UINT32 status;
    UINT32 stateInt;
    UINT32 enabledInt;

    /* Read and clear interrupt status. */
    status = *S3C2510_USBINTR;
    *S3C2510_USBINTR = status;

    stateInt = status & (S3C2510_USBINTR_RESET | S3C2510_USBINTR_RESUME | S3C2510_USBINTR_SUSPEND);

    /* Get enabled interrupt. */
    enabledInt = *S3C2510_USBINTRE & (S3C2510_USBINTRE_EP4 |
                                      S3C2510_USBINTRE_EP3 |
                                      S3C2510_USBINTRE_EP2 |
                                      S3C2510_USBINTRE_EP1 |
                                      S3C2510_USBINTRE_EP0);

    if (stateInt == S3C2510_USBINTR_SUSPEND)
    {
        *S3C2510_USBINTRE = (enabledInt | S3C2510_USBINTRE_RESET);
    }
    else if (stateInt == S3C2510_USBINTR_RESUME)
    {
        *S3C2510_USBINTRE = (enabledInt | S3C2510_USBINTRE_RESET | S3C2510_USBINTRE_SUSPEND);
    }
    else if (stateInt == (S3C2510_USBINTR_RESUME | S3C2510_USBINTR_SUSPEND))
    {
        *S3C2510_USBINTRE = (enabledInt | S3C2510_USBINTRE_RESET | S3C2510_USBINTRE_SUSPEND);
    }
    else if (stateInt == S3C2510_USBINTR_RESET)
    {
        s3c2510UsbReset();
    }

    /* Endpoint 0 Interrupt */
    if (status & S3C2510_USBINTR_EP0)
    {
        netJobAdd(
                (FUNCPTR)s3c2510UsbEP0Handler,
                0,
                0,
                0,
                0,
                0
                );
    }

    /* Endpoint 1 Interrupt */
    if (status & S3C2510_USBINTR_EP1)
    {
        netJobAdd(
                (FUNCPTR)s3c2510UsbEP1Handler,
                0,
                0,
                0,
                0,
                0
                );
    }

    /* Endpoint 2 Interrupt */
    if (status & S3C2510_USBINTR_EP2)
    {
        netJobAdd(
                (FUNCPTR)s3c2510UsbEP2Handler,
                0,
                0,
                0,
                0,
                0
                );
    }

    /* Endpoint 3 Interrupt */
    if (status & S3C2510_USBINTR_EP3)
    {
        netJobAdd(
                (FUNCPTR)s3c2510UsbEP3Handler,
                0,
                0,
                0,
                0,
                0
                );
    }

    /* Endpoint 4 Interrupt */
    if (status & S3C2510_USBINTR_EP4)
    {
        netJobAdd(
                (FUNCPTR)s3c2510UsbEP4Handler,
                0,
                0,
                0,
                0,
                0
                );
    }
}

/*******************************************************************************
*
* s3c2510UsbEP0Handler - Endpoint 0 interrupt handler.
*
* RETURNS : N/A
*/

void s3c2510UsbEP0Handler(void)
{
    UINT32 status;

    /* Read Endpoint 0 Common Status Register. */
    status = *S3C2510_USBCSR(0);

#ifdef  DEBUG_TRACE
    printf("s3c2510Usb EP0Handler, 0x%08X\n", status);
#endif  /* DEBUG_TRACE */

    if (status & S3C2510_USBEP0CSR_USBSTSTALL)
    {
#ifdef  DEBUG_TRACE
        printf("S3C2510_USBEP0CSR_USBSTSTALL\n");
#endif  /* DEBUG_TRACE */

        /* Clear status. */
        *S3C2510_USBCSR(0) |= S3C2510_USBEP0CSR_USBSTSTALL;

        /* Endpoint 0 state is idle. */
        ep0State = EP0_STATE_IDLE;
    }
    else if (status & S3C2510_USBEP0CSR_USBSETEND)
    {
#ifdef  DEBUG_TRACE
        printf("S3C2510_USBEP0CSR_USBSETEND\n");
#endif  /* DEBUG_TRACE */

        /* Endpoint 0 state is idle. */
        ep0State = EP0_STATE_IDLE;
    }
    else if (!status)
    {
        printf("s3c2510Usb Error: Invalid status\n");
    }

    switch (ep0State)
    {
    case EP0_STATE_IDLE:
#ifdef  DEBUG_TRACE
        printf("EP0_STATE_IDLE\n");
#endif  /* DEBUG_TRACE */
        if (status & S3C2510_USBEP0CSR_USBORDY)
        {
            UINT32 count = (*S3C2510_USBWCEP(0) & S3C2510_USBWCEP_WRTCNT_MASK) >> S3C2510_USBWCEP_WRTCNT_SHIFT;

            if (count != USB_SETUP_LEN)
            {
                printf("s3c2510Usb Error: Invalid length, %d\n", (int)count);
            }

            ((UINT32 *)(&usbSetup))[0] = *S3C2510_USBFIFO(0);
            ((UINT32 *)(&usbSetup))[1] = *S3C2510_USBFIFO(0);

            switch (usbSetup.bmRequestType & USB_RT_CATEGORY_MASK)
            {
            case USB_RT_STANDARD:
#ifdef  DEBUG_TRACE
                printf("USB_RT_STANDARD\n");
#endif  /* DEBUG_TRACE */
                s3c2510UsbDeviceRequestStandard();
                break;

            case USB_RT_CLASS:
#ifdef  DEBUG_TRACE
                printf("USB_RT_CLASS\n");
#endif  /* DEBUG_TRACE */
                s3c2510UsbDeviceRequestClass();
                break;

            case USB_RT_VENDOR:
#ifdef  DEBUG_TRACE
                printf("USB_RT_VENDOR\n");
#endif  /* DEBUG_TRACE */
                s3c2510UsbDeviceRequestVendor();
                break;

            default:
                printf("s3c2510Usb Error: Unknown category, 0x%02X\n", usbSetup.bmRequestType & USB_RT_CATEGORY_MASK);
                break;
            }
        }
        break;

    case EP0_STATE_TRANSMIT:
#ifdef  DEBUG_TRACE
        printf("EP0_STATE_TRANSMIT\n");
#endif  /* DEBUG_TRACE */
        s3c2510UsbEp0Out();
        break;

    case EP0_STATE_RECEIVE:
#ifdef  DEBUG_TRACE
        printf("EP0_STATE_RECEIVE\n");
#endif  /* DEBUG_TRACE */
        s3c2510UsbEp0In();
        break;
    }
}

/*******************************************************************************
*
* s3c2510UsbEP1Handler - Endpoint 1 interrupt handler.
*
* RETURNS : N/A
*/

void s3c2510UsbEP1Handler(void)
{
    UINT32 status;

    /* Read Endpoint 0 Common Status Register. */
    status = *S3C2510_USBCSR(1);

#ifdef  DEBUG_TRACE
    printf("s3c2510Usb EP1Handler, 0x%08X\n", status);
#endif  /* DEBUG_TRACE */

}

/*******************************************************************************
*
* s3c2510UsbEP2Handler - Endpoint 2 interrupt handler.
*
* RETURNS : N/A
*/

void s3c2510UsbEP2Handler(void)
{
    UINT32 status;

    /* Read Endpoint 0 Common Status Register. */
    status = *S3C2510_USBCSR(2);

#ifdef  DEBUG_TRACE
    printf("s3c2510Usb EP2Handler, 0x%08X\n", status);
#endif  /* DEBUG_TRACE */

}

/*******************************************************************************
*
* s3c2510UsbEP3Handler - Endpoint 3 interrupt handler.
*
* RETURNS : N/A
*/

void s3c2510UsbEP3Handler(void)
{
    UINT32 status;

    /* Read Endpoint 0 Common Status Register. */
    status = *S3C2510_USBCSR(3);

#ifdef  DEBUG_TRACE
    printf("s3c2510Usb EP3Handler, 0x%08X\n", status);
#endif  /* DEBUG_TRACE */

}

/*******************************************************************************
*
* s3c2510UsbEP4Handler - Endpoint 4 interrupt handler.
*
* RETURNS : N/A
*/

void s3c2510UsbEP4Handler(void)
{
    UINT32 status;

    /* Read Endpoint 0 Common Status Register. */
    status = *S3C2510_USBCSR(4);

#ifdef  DEBUG_TRACE
    printf("s3c2510Usb EP4Handler, 0x%08X\n", status);
#endif  /* DEBUG_TRACE */

}

#ifdef  DEBUG_TRACE
/*******************************************************************************
*
* s3c2510UsbDump - dump buffer.
*
* RETURNS : N/A
*/

void s3c2510UsbDump(UCHAR *p, ULONG l)
{
    ULONG i;

    while (l)
    {
        printf("%08X:  ", (UINT32)p);
        for (i=0; i<16; i++)
        {
            printf("%02X ", *p++);

            if (--l == 0)
            {
                break;
            }
        }
        printf("\n");
    }
}
#endif  /* DEBUG_TRACE */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -