USB Bulk Transfer

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

USB Bulk Transfer

1,170 Views
ryanlush
Contributor IV

I have some USB firmware that started out as a Freescale Virtual COM port but was modified to just use bulk transfers over 2 endpoints. My understanding is the interrupt (control) endpoint was removed because its not needed. So the device enumerates not as a com port but as a custom device. These are what I believe to be the relevant descriptors from the working project.

/*****************************************************************************
 * Constant and Macro's
 *****************************************************************************/
/* structure containing details of all the endpoints used by this device */
USB_DESC_CONST USB_ENDPOINTS usb_desc_ep =
{
    BULK_DESC_ENDPOINT_COUNT,
    {
        {
            BULK_IN_ENDPOINT,
            USB_BULK_PIPE,
            USB_SEND,
            BULK_IN_ENDP_PACKET_SIZE
        },
        {
            BULK_OUT_ENDPOINT,
            USB_BULK_PIPE,
            USB_RECV,
            BULK_OUT_ENDP_PACKET_SIZE
        }    
    }
};

uint_8 USB_DESC_CONST g_device_descriptor[DEVICE_DESCRIPTOR_SIZE] =
{
   DEVICE_DESCRIPTOR_SIZE,               /*  Device Dexcriptor Size         */
   USB_DEVICE_DESCRIPTOR,                /*  Device Type of descriptor      */
   0x00, 0x02,                           /*  BCD USB version                */
   0x00,                                   /*  Device Class is indicated in
                                             the interface descriptors      */
   0x00,                                 /*  Device Subclass is indicated
                                             in the interface descriptors   */
   0x00,                                 /*  Device Protocol                */
   CONTROL_MAX_PACKET_SIZE,              /*  Max Packet size                */
   0xE3,0x22,                            /*  Vendor ID                      */
   LSB(PRODUCT_ID), MSB(PRODUCT_ID),     /*  9500IX 2                       */
   0x00,0x02,                            /*  BCD Device version             */
   0x01,                                 /*  Manufacturer string index      */
   0x02,                                 /*  Product string index           */
   0x03,                                 /*  Serial number string index     */
   0x01                                  /*  Number of configurations       */
};

uint_8 USB_DESC_CONST g_config_descriptor[CONFIG_DESC_SIZE] =
{
    CONFIG_ONLY_DESC_SIZE,          /*  Configuration Descriptor Size */                        // 0x09
    USB_CONFIG_DESCRIPTOR,          /* "Configuration" type of descriptor */                    // 0x02
    CONFIG_DESC_SIZE, 0x00,         /*  Total length of the Configuration descriptor */            // 0x09 + 0x09 + 0x07*2 , 0x00
    0x01,                           /*NumInterfaces*/
    0x01,                           /*  Configuration Value */
    0x00,                           /*  Configuration Description String Index*/
    BUS_POWERED|SELF_POWERED|(REMOTE_WAKEUP_SUPPORT<<REMOTE_WAKEUP_SHIFT),
              /*  Attributes.support RemoteWakeup and self power*/
    0x32,                   /*  Current draw from bus -- 100mA*/

    /* INTERFACE DESCRIPTOR */
    IFACE_ONLY_DESC_SIZE,                                                                        // 0x09
    USB_IFACE_DESCRIPTOR,                                                                        // 0x04
    0x00,                           /* bInterfaceNumber */
    0x00,                           /* bAlternateSetting */
    BULK_DESC_ENDPOINT_COUNT,       
    BULK_CLASS_CODE,                     
    BULK_SUBCLASS_CODE,
    BULK_PROTOCOL_CODE,
    0x00, /* Interface Description String Index*/

    /*Endpoint descriptor */
    ENDP_ONLY_DESC_SIZE,                                                                        // 0x07
    USB_ENDPOINT_DESCRIPTOR,
    BULK_IN_ENDPOINT | (USB_SEND << 7),
    USB_BULK_PIPE,
    BULK_IN_ENDP_PACKET_SIZE, 0x00,
    0x00,                           /* This value is ignored for bulk */

    /*Endpoint descriptor */
    ENDP_ONLY_DESC_SIZE,
    USB_ENDPOINT_DESCRIPTOR,
    BULK_OUT_ENDPOINT|(USB_RECV << 7),
    USB_BULK_PIPE,
    BULK_OUT_ENDP_PACKET_SIZE, 0x00,
    0x00                            /* This value is ignored for bulk */
};

So my goal here is to duplicate this scheme but using the latest KSDK. There is a fairly decent document on how to do this with the Freescale USB stack but I'm a little lost when it comes to doing it with KSDK.

0 Kudos
Reply
1 Reply

821 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi Ryan,

which mcu do you use? Do you mean you want to use endpoint0 as bulk transfer? There is no such statement this is forbidden. But it is not recommanded. You'd better keep endpoint0 and use other endpoint.

Regards

Jing

0 Kudos
Reply