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

📄 chap_9.c

📁 瑞星微公司RK27XX系列芯片的SDK开发包
💻 C
📖 第 1 页 / 共 3 页
字号:
    3,     /* Number of end points              */
#elif END_POINTER_NUM == 16
    15,     /* Number of end points              */
#else
#error "****** END_POINTER_NUM is not well defined!"
#endif
#ifdef USE_USBPRINT_SYS
    0x07,          /* Interface class: printer            */
    0x01,          /* Interface sub class: printer        */
    0x02,          /* Interface protocol: bidirectional   */
#else   /* USE BULKUSB.SYS */
    0x08,//0xff,          /* Interface class: printer            */
    0x06,//0x00,          /* Interface sub class: printer        */
    0x50,//0x00,          /* Interface protocol: bidirectional   */
#endif

    0,     /* Interface descriptor string index   */
#if END_POINTER_NUM == 4
    /* Endpoint Descriptor */
    7,     /* Descriptor length                    */
    EDP_DSCR_TYPE,  /* Descriptor type                   */
#ifdef CHIPIDEA
    BLKOUT_ENDP_NUM_SET5,
#else
    BLKOUT_ENDP_NUM_SET5,
#endif
    //BLKOUT_ENDP_NUM_SET5,     /* Endpoint number, and direction : OUT */
    2,     /* Endpoint type                   */
    FS_BULK_PKT_LSB,    /* Maximum packet size (LSB)          */
    FS_BULK_PKT_MSB, /* Max packet size (MSB)              */
    0x00,    /* Polling interval                     */

    /* Endpoint Descriptor */
    7,     /* Descriptor length                    */
    EDP_DSCR_TYPE,  /* Descriptor type                */
#ifdef CHIPIDEA
    BLKIN_ENDP_NUM_SET5,
#else
    BLKIN_ENDP_NUM_SET5,
#endif
    //BLKIN_ENDP_NUM_SET5,      /* Endpoint number, and direction : IN */
    2,     /* Endpoint type                */
    FS_BULK_PKT_LSB,    /* Maximum packet size (LSB)       */
    FS_BULK_PKT_MSB, /* Max packet size (MSB)           */
    0x00,    /* Polling interval                     */

    /* Endpoint Descriptor */
    7,     /* Descriptor length                    */
    EDP_DSCR_TYPE,  /* Descriptor type                */
#ifdef CHIPIDEA
    INTRIN_ENDP_NUM_SET5,
#else
    INTRIN_ENDP_NUM_SET5,
#endif
    //INTRIN_ENDP_NUM_SET5,     /* Endpoint number, and direction : IN */
    3,     /* Endpoint type                */
    INTRIN_PKT_LSB,  /* Maximum packet size (LSB)       */
    INTRIN_PKT_MSB,  /* Max packet size (MSB)           */
    0x0b,    /* Polling interval                     */

#elif END_POINTER_NUM == 16
    /* Endpoint Descriptor */
    7,     /* Descriptor length                    */
    EDP_DSCR_TYPE,  /* Descriptor type                   */
    BLKOUT_ENDP_NUM_SET1,     /* Endpoint number, and direction : OUT */
    2,     /* Endpoint type                   */
    FS_BULK_PKT_LSB,    /* Maximum packet size (LSB)          */
    FS_BULK_PKT_MSB, /* Max packet size (MSB)              */
    0x00,    /* Polling interval                     */

    /* Endpoint Descriptor */
    7,     /* Descriptor length                    */
    EDP_DSCR_TYPE,  /* Descriptor type                */
    BLKIN_ENDP_NUM_SET1,      /* Endpoint number, and direction : IN */
    2,     /* Endpoint type                */
    FS_BULK_PKT_LSB,    /* Maximum packet size (LSB)       */
    FS_BULK_PKT_MSB, /* Max packet size (MSB)           */
    0x00,    /* Polling interval                     */

    /* Endpoint Descriptor */
    7,     /* Descriptor length                    */
    EDP_DSCR_TYPE,  /* Descriptor type                */
    INTRIN_ENDP_NUM_SET1,     /* Endpoint number, and direction : IN */
    3,     /* Endpoint type                */
    INTRIN_PKT_LSB,  /* Maximum packet size (LSB)       */
    INTRIN_PKT_MSB,  /* Max packet size (MSB)           */
    0x0b,    /* Polling interval                     */

    /* Endpoint Descriptor */
    7,     /* Descriptor length                    */
    EDP_DSCR_TYPE,  /* Descriptor type                   */
    BLKOUT_ENDP_NUM_SET2,     /* Endpoint number, and direction : OUT */
    2,     /* Endpoint type                   */
    FS_BULK_PKT_LSB,    /* Maximum packet size (LSB)          */
    FS_BULK_PKT_MSB, /* Max packet size (MSB)              */
    0x00,    /* Polling interval                     */

    /* Endpoint Descriptor */
    7,     /* Descriptor length                    */
    EDP_DSCR_TYPE,  /* Descriptor type                */
    BLKIN_ENDP_NUM_SET2,      /* Endpoint number, and direction : IN */
    2,     /* Endpoint type                */
    FS_BULK_PKT_LSB,    /* Maximum packet size (LSB)       */
    FS_BULK_PKT_MSB, /* Max packet size (MSB)           */
    0x00,    /* Polling interval                     */

    /* Endpoint Descriptor */
    7,     /* Descriptor length                    */
    EDP_DSCR_TYPE,  /* Descriptor type                */
    INTRIN_ENDP_NUM_SET2,     /* Endpoint number, and direction : IN */
    3,     /* Endpoint type                */
    INTRIN_PKT_LSB,  /* Maximum packet size (LSB)       */
    INTRIN_PKT_MSB,  /* Max packet size (MSB)           */
    0x0b,    /* Polling interval                     */

    /* Endpoint Descriptor */
    7,     /* Descriptor length                    */
    EDP_DSCR_TYPE,  /* Descriptor type                   */
    BLKOUT_ENDP_NUM_SET3,     /* Endpoint number, and direction : OUT */
    2,     /* Endpoint type                   */
    FS_BULK_PKT_LSB, /* Maximum packet size (LSB)          */
    FS_BULK_PKT_MSB, /* Max packet size (MSB)              */
    0x00,    /* Polling interval                     */

    /* Endpoint Descriptor */
    7,     /* Descriptor length                    */
    EDP_DSCR_TYPE,  /* Descriptor type                */
    BLKIN_ENDP_NUM_SET3,      /* Endpoint number, and direction : IN */
    2,     /* Endpoint type                */
    FS_BULK_PKT_LSB, /* Maximum packet size (LSB)       */
    FS_BULK_PKT_MSB, /* Max packet size (MSB)           */
    0x00,    /* Polling interval                     */

    /* Endpoint Descriptor */
    7,     /* Descriptor length                    */
    EDP_DSCR_TYPE,  /* Descriptor type                */
    INTRIN_ENDP_NUM_SET3,     /* Endpoint number, and direction : IN */
    3,     /* Endpoint type                */
    INTRIN_PKT_LSB,  /* Maximum packet size (LSB)       */
    INTRIN_PKT_MSB,  /* Max packet size (MSB)           */
    0x0b,    /* Polling interval                     */

    /* Endpoint Descriptor */
    7,     /* Descriptor length                    */
    EDP_DSCR_TYPE,  /* Descriptor type                   */
    BLKOUT_ENDP_NUM_SET4,     /* Endpoint number, and direction : OUT */
    2,     /* Endpoint type                   */
    FS_BULK_PKT_LSB, /* Maximum packet size (LSB)          */
    FS_BULK_PKT_MSB, /* Max packet size (MSB)              */
    0x00,    /* Polling interval                     */

    /* Endpoint Descriptor */
    7,     /* Descriptor length                    */
    EDP_DSCR_TYPE,  /* Descriptor type                */
    BLKIN_ENDP_NUM_SET4,      /* Endpoint number, and direction : IN */
    2,     /* Endpoint type                */
    FS_BULK_PKT_LSB, /* Maximum packet size (LSB)       */
    FS_BULK_PKT_MSB, /* Max packet size (MSB)           */
    0x00,    /* Polling interval                     */

    /* Endpoint Descriptor */
    7,     /* Descriptor length                    */
    EDP_DSCR_TYPE,  /* Descriptor type                */
    INTRIN_ENDP_NUM_SET4,     /* Endpoint number, and direction : IN */
    3,     /* Endpoint type                */
    INTRIN_PKT_LSB,  /* Maximum packet size (LSB)       */
    INTRIN_PKT_MSB,  /* Max packet size (MSB)           */
    0x0b,    /* Polling interval                     */

    /* Endpoint Descriptor */
    7,     /* Descriptor length                    */
    EDP_DSCR_TYPE,  /* Descriptor type                   */
    BLKOUT_ENDP_NUM_SET5,     /* Endpoint number, and direction : OUT */
    2,     /* Endpoint type                   */
    FS_BULK_PKT_LSB, /* Maximum packet size (LSB)          */
    FS_BULK_PKT_MSB, /* Max packet size (MSB)              */
    0x00,    /* Polling interval                     */

    /* Endpoint Descriptor */
    7,     /* Descriptor length                    */
    EDP_DSCR_TYPE,  /* Descriptor type                */
    BLKIN_ENDP_NUM_SET5,      /* Endpoint number, and direction : IN */
    2,     /* Endpoint type                */
    FS_BULK_PKT_LSB, /* Maximum packet size (LSB)       */
    FS_BULK_PKT_MSB, /* Max packet size (MSB)           */
    0x00,    /* Polling interval                     */

    /* Endpoint Descriptor */
    7,     /* Descriptor length                    */
    EDP_DSCR_TYPE,  /* Descriptor type                */
    INTRIN_ENDP_NUM_SET5,     /* Endpoint number, and direction : IN */
    3,     /* Endpoint type                */
    INTRIN_PKT_LSB,  /* Maximum packet size (LSB)       */
    INTRIN_PKT_MSB,  /* Max packet size (MSB)           */
    0x0b,    /* Polling interval                     */
#else
#error "****** END_POINTER_NUM is not well defined!"
#endif

    /* StringDscr0 */
    4,     /* String descriptor length   */
    STR_DSCR_TYPE,  /* String Descriptor          */
    0x09, 0x04,

    /* StringDscr1 Manufacture */
    18,
    STR_DSCR_TYPE,
    'R', 0x00,
    'o', 0x00,
    'c', 0x00,
    'k', 0x00,
    'C', 0x00,
    'h', 0x00,
    'i', 0x00,
    'p', 0x00,

    /* StringDscr2 Product*/
    18,
    STR_DSCR_TYPE,
    'R', 0x00,
    'O', 0x00,
    'C', 0x00,
    'K', 0x00,
    ' ', 0x00,
    'M', 0x00,
    'P', 0x00,
    '3', 0x00,

    /* StringDscr3 SerialNum*/
    18,
    STR_DSCR_TYPE,
    'U', 0x00,
    'S', 0x00,
    'B', 0x00,
    'V', 0x00,
    '1', 0x00,
    '.', 0x00,
    '0', 0x00,
    '0', 0x00
};

/**************************************************************************
获取设备状态
***************************************************************************/
#if 0
void GetStatus(void)
{
    UINT8 endp, txdat[2];
    UINT8 bRecipient = ControlData.DeviceRequest.bmRequestType & USB_RECIPIENT;
    UINT8 c;

    if (bRecipient == USB_RECIPIENT_DEVICE)
    {
        if (bEPPflags.bits.remote_wakeup == 1) //获取远程唤醒状态
            txdat[0] = 3;
        else
            txdat[0] = 1;
        txdat[1] = 0;
        single_transmit(txdat, 2);
    }
    else if (bRecipient == USB_RECIPIENT_INTERFACE) //获取接口状态
    {
        txdat[0] = 0;
        txdat[1] = 0;
        single_transmit(txdat, 2);
    }
    else if (bRecipient == USB_RECIPIENT_ENDPOINT) //获取端点状态
    {
        endp = (UINT8)(ControlData.DeviceRequest.wIndex & MAX_ENDPOINTS);
        if (ControlData.DeviceRequest.wIndex & (UINT8)USB_ENDPOINT_DIRECTION_MASK)
            c = MUSBHSFC_SelectEndpoint(endp * 2 + 1); // Control-in
        else
            c = MUSBHSFC_SelectEndpoint(endp * 2); // Control-out
        if (c != 0)
            txdat[0] = 1;
        else
            txdat[0] = 0;
        txdat[1] = 0;
        single_transmit(txdat, 2);
    }
    else
        stall_ep0();
}


/**************************************************************************
特性清除
***************************************************************************/
void ClearFeature(void)
{
    UINT8 endp;
    UINT8 bRecipient = ControlData.DeviceRequest.bmRequestType & USB_RECIPIENT;

    if (bRecipient == USB_RECIPIENT_DEVICE    //清除远程唤醒功能
            && ControlData.DeviceRequest.wValue == USB_FEATURE_REMOTE_WAKEUP)
    {
        bEPPflags.bits.remote_wakeup = 0;
        ep0in_ack();
    }
    else if (bRecipient == USB_RECIPIENT_ENDPOINT  //清除端点stall
             && ControlData.DeviceRequest.wValue == USB_FEATURE_ENDPOINT_STALL)
    {
        endp = (UINT8)(ControlData.DeviceRequest.wIndex & MAX_ENDPOINTS);
        if (ControlData.DeviceRequest.wIndex & (UINT8)USB_ENDPOINT_DIRECTION_MASK)
            endp = endp * 2 + 1;
        else
            endp = endp * 2;
        MUSBHSFC_SetEndpointStatus(endp, 0);  // clear RX/TX stall for OUT/IN on EPn.
        ep0in_ack();
        if (endp >= 2)
        {
            if (endp == 2)
            {
                write_XDATA(USB_CSR_OUT, CSR_OUT_CDT  | CSR_OUT_FLUSH_FIFO);
                G_ucBulkPhase = K_CommandPhase;
            }
            else
            {
                write_XDATA(USB_CSR_IN, CSR_IN_CDT | CSR_IN_FLUSH_FIFO);   //bulk or interrupt
            }
            SendCSW();
            G_ucBulkStausPhase = K_CommandPhase; //add by lxs
        }
    }
    else
        stall_ep0();
}

⌨️ 快捷键说明

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