This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

C5505 USB with CSL library

Hello,

do you have some experiences with USB communication with C5505?

I am trying to implement USB CDC Class. I have downloaded CSL library 1.00 and I am trying to modify the example code (csl_usb_intc_example.c). I have modified Configuration Descriptor. If the size of Configuration Descriptor is less than 64 B, Windows successfully recognizes the device and wants to install the driver. But If the size of Configuration Descriptor is 67 B, Windows cannot recognize the device. Am I doing something wrong or is there bug in CSL library?

Control endpoint initialization:

    status = USB_initEndptObj(CSL_USB0, hEpObjArray[1], CSL_USB_IN_EP0, CSL_USB_CTRL, CSL_USB_EP0_PACKET_SIZE, CSL_USB_EVENT_EOT, NULL);

Configuration Descriptor Transfer:

    status = USB_postTransaction(hEpObjArray[1], 67, cfgDescPtr, CSL_USB_IN_TRANSFER);

Configuration Descriptor Definition (it should be correct because I have compared it with another project):

Uint16 cfgDesc[34] =
{
    //~ Configuration Descriptor ~//
    0x0209,   // Size of this descriptor in bytes, CONFIGURATION descriptor type
    0x0043,   // Total length of data for this cfg (word)
    0x0102,   // Number of interfaces in this cfg, Index value of this configuration
    0xA000,   // Configuration string index, Attributes
    0x0900,   // Max power consumption (2X mA), Size of next descriptor in bytes
    //~ Interface Descriptor ~//
    0x0004,   // INTERFACE descriptor type, Interface Number
    0x0100,   // Alternate Setting Number, Number of endpoints in this intf
    0x0202,   // Class: Communication Interface, Subclass: abstract control model
    0x0002,   // Protocol: V.25ter (AT commands), Interface string index
    //~ CDC Class-Specific Descriptors ~//
    0x2405,   // Delka dalsiho deskriptoru, Typ: interface
    0x0100,   // Podtyp: Header, Hodnota LSB
    0x0410,   // Hodnota MSB (verze BCD - 1.10), Delka dalsiho deskriptoru
    0x0224,   // Typ: interface, Podtyp: ACM = Abstract Control Management
    0x0502,   // Hodnota (supported commands for the Abstract Control Model interface), Delka dalsiho deskriptoru
    0x0624,   // Typ: interface, Podtyp: Union Functional Descriptor
    0x0100,   // Hodnota CDC_COMM_INTF_ID, Hodnota CDC_DATA_INTF_ID
    0x2405,   // Delka dalsiho deskriptoru, Typ: interface
    0x0001,   // Podtyp: Call Management Functional Descriptor, Hodnota (volby)
    0x0701,   // Hodnota CDC_DATA_INTF_ID, Delka dalsiho deskriptoru
    //~ Endpoint Descriptor ~//
    0x8205,   // Typ: endpoint, EP02_IN
    0x0803,   // Interrupt Transfer, Velikost paketu (LSB)
    0xFF00,   // Velikost paketu (MSB), Polling Interval
    //~ Interface Descriptor ~//
    0x0409,   // Size of next descriptor in bytes, INTERFACE descriptor type
    0x0001,   // Interface Number, Alternate Setting Number
    0x0A02,   // Number of endpoints in this intf, Class: Data Interface
    0x0000,   // Subclass: 0, Protocol: No class specific protocol required
    0x0700,   // Interface string index, Delka dalsiho deskriptoru
    //~ Endpoint Descriptors ~//
    0x0405,   // Typ: endpoint, EP04_OUT
    0x4002,   // Bulk Transfer, Velikost paketu (LSB)
    0x0000,   // Velikost paketu (MSB), Polling Interval
    0x0507,   // Delka dalsiho deskriptoru, Typ: endpoint
    0x0283,   // EP03_IN, Bulk Transfer
    0x0040,   // Velikost paketu (word)
    0x0000    // Polling Interval, 0  */
};

 

  • Hi Jiri,

    There is limitation on the packet size on EP0. It is 64Byte. If your configuration descriptor is bigger than 64B, it will be transmitted in two or more packets. You can look at the function USB_processEP0In() in csl_usbAux.h for details.

    Most likely is the USB host did not understand your descriptor which has been transmitted in two packets.

    Best regards,

    Ming

  • Thank you for your answer.

    The USB host is PC with Windows OS. I use the standard driver usbser.sys. So I do not suppose that the error is in USB host.

    What function is responsible to send all data? Because the function USB_processEP0In() in csl_usbAux.h sends the first 64 B only and not the rest.


    Best regards,

    Jiri Babka

     

  • Hi Jiri,

    I'm not familiar with the USB CSL, but as I understand, you are trying to submit the entire configuration descriptor regardless on the number of bytes requested by the host. Please note the USB standard section 9.3.5 (USB Device Framework -> USB Device Requests -> wLength):

    "On an input request, a device must never return more data than is indicated by the wLength value; it may return less."

    In other words you should call the USB_postTransaction() using size "min(setup->wLength,67)", instead of just "67".

    The Windows drivers usually read the configuration descriptor twice: first just the header (length 9) to determine the total length, then the entire descriptor.

    Regards,

    Todor

  • Hi Todor,

    you are right, Windows driver wants 9 B of configuration descriptor first. I send 9 B - it is ok. Then it wants entire descriptor (wLength = 255).  I call the USB_postTransaction() using size 67, but there is a problem that 64 B is sent only.

    I have just found that the function USB_postTransaction() does not transmit data alone but it calls the callback function usbConfig.startTrasferCallback. I am modifying CSL USB example2 and there is this peace of code in the callback function:

                    status = USB_processEP0In(pContext);

    But the function USB_processEP0In() transmits 64 B only. I don't know if it is error or if I have to do it by another way. I have tried this:

            while (!pTransfer->fComplete)
            {
                    status = USB_processEP0In(pContext);
            }

    When I debugged it the function USB_processEP0In() is called two times. First it copies 64 B to buffer then 3 B. It seems well, but Windows still could not recognize the device (it starts to request device descriptor again).

    How can I send 67 B correctly?

    Best regards,

    Jiri

  • hello,

    i have similar problem, i get some data  from sensor and stored  in DSP C5505, and i want output these data throught usb to PC, and usb  as a virtual com port, i modify only the device descriptor and configuration descriptor, Pc can recognise the usb in a right way, but can not treat as a com port. the code below is the changed descriptor from TI CSL .

    i want to ask that do i need a data interface inside this configuration descriptor, and i tried a lot of place inside and also change the cooperate endpoint  and correspond transaction code in CSL, but the PC can not recognise it anymore. so i wana know that which things i need to set and program for the purpose of communicating with PC through usb as a virtual com port .

    Thanks

    Uint16    deviceDesc[9] = {0x0112, 0x0200, 0x0002, 0x4000, 0x0451,
                                0x9010, 0x0000, 0x0201, 0x0103}; 

      cfgDesc[60] = {0x09,0x02,0x3C,0x00,0x01,0x01,0x00,0xA0,0x00,      configuration descriptor                                  
                             0x09,0x04,0x00,0x00,0x06,0x02,0x02,0x00,0x00,           interface descriptor
                             0x07,0x05,0x81,0x02,0x40,0x00,0x00,                              endpoint descritpor number 1  in     
                             0x07,0x05,0x01,0x02,0x40,0x00,0x00,                              endpoint descritpor number 1  out   
                             0x07,0x05,0x82,0x02,0x40,0x00,0x00,                               endpoint descritpor number 2  in   
                             0x07,0x05,0x02,0x02,0x40,0x00,0x00                                endpoint descritpor number 2  out

                            0x07,0x05,0x83,0x02,0x40,0x00,0x00,                                  endpoint descritpor number 3  in   
                            0x07,0x05,0x03,0x02,0x40,0x00,0x00,};                                endpoint descritpor number 3  out 

  • Hi Renhao,

    You are trying to implement the USB CDC device by modifying a CSL USB endpoint example. As far as I know, the CDC driver is the higher level driver based on the USB core driver. Implement a CDC driver on USB core driver involve more than just change the configuration descriptors. At this point, our CSL only support two USB classes: USB MSC and USB auido class. The next to add will be CDC and HID. Before we add them into the CSL, you will have to implement it by yourself. Please get a USB CDC spec from usb.org. You can implement the CDC driver based on the USB core driver (the CSL API document has the detail info on the USB core driver) csl_usb.c and csl_usb.h. You can use csl_usb_msc.c and csl_usb_msc.h (MSC driver) or csl_usb_ac.c and csl_usb_ac.h (AC driver) as your references.

    Best regards,

    Ming  

  • hey Ming

    Thanks a lot for your answer

    Best regards

    renhao

     

  • Hello Ming,

    when do you suppose you will have the USB CDC class implemented?

    Best regards,

    Jiri