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.

CC2538 usb_cdc library issue

Other Parts Discussed in Thread: CC2538, CC2530

Hello,

I am going to design my own circuit board using CC2538 micro-controller, and I will use USB to communicate between my sensor and CC2538. 

Although I find the usb_cdc library from website, I cannot find the specification for this library.

Is there usb_cdc library specification available?

or is there code available for usb_cdc?

Thanks,

  • USB communication between CC2538 and sensor? As I know, the USB driver of CC2538 only act as USB CDC client. May I know which sensor you use?
  • Hi,
    implementation of the CDC-ACM (serial over USB) class on CC2538 is available in source code from here: www.ti.com/.../cc2538-sw
    The CDC class specification can be retrieved from here: www.usb.org/.../CDC1.2_WMC1.1_012011.zip
    Thanks,
    TheDarkSide
  • Hello HeDarkSide,

    Thank you for your information.
    I want to display "spi" to terminal, but I should press a key to get it.
    How should I change the code to display the "spi" to terminal without pressing the key?
    The code from the following website: e2e.ti.com/.../404305

    #include "bsp.h"
    #include "string.h"
    #include "usb_firmware_library_headers.h"
    #include "usb_cdc.h"
    #include "usb_in_buffer.h"
    #include "usb_out_buffer.h"
    
    
    
    //*****************************************************************************
    //
    // Local variablse
    //
    //*****************************************************************************
    USB_EPIN_RINGBUFFER_DATA usbCdcInBufferData;
    USB_EPOUT_RINGBUFFER_DATA usbCdcOutBufferData;
    static uint8_t pInBuffer[128];
    static uint8_t pOutBuffer[128];
    static uint8_t pAppBuffer[128];
    
    
    //*****************************************************************************
    //
    // Implementations of function that are required by usb framework.
    //
    //*****************************************************************************
    void usbsuspHookEnteringSuspend(bool remoteWakeupAllowed) 
    {
    if (remoteWakeupAllowed) 
    {
    }
    }
    
    
    void usbsuspHookExitingSuspend(void) {
    }
    
    
    //
    // Application entry point
    //
    int main(void)
    {
    
    //
    // Initialize board and system clock
    //
    bspInit(SYS_CTRL_32MHZ);
    
    //
    // Initialize buffers
    //
    memset(&usbCdcInBufferData, 0x00, sizeof(USB_EPIN_RINGBUFFER_DATA));
    usbCdcInBufferData.pBuffer = pInBuffer;
    usbCdcInBufferData.size = sizeof(pInBuffer);
    usbCdcInBufferData.endpointReg = USB_F4;
    usbCdcInBufferData.endpointIndex = 4;
    usbCdcInBufferData.endpointSize = 64;
    memset(&usbCdcOutBufferData, 0x00, sizeof(USB_EPOUT_RINGBUFFER_DATA));
    usbCdcOutBufferData.pBuffer = pOutBuffer;
    usbCdcOutBufferData.size = sizeof(pOutBuffer);
    usbCdcOutBufferData.endpointReg = USB_F4;
    usbCdcOutBufferData.endpointIndex = 4;
    
    
    uint8_t spi[] = {'s','p','i','\n','\r'};
    uint16_t spiLength = 5;
    
    //
    // Enable the USB interface
    //
    usbCdcInit(115200); //void usbCdcInit(uint32_t baudrate);
    
    //
    // Main loop
    //
    bool stopflag = true;
    while (stopflag) {
    
    //
    // Process USB events
    //
    usbCdcProcessEvents();
    
    //
    // Implement COM-port loopback
    //
    uint16_t count = usbibufGetMaxPushCount(&usbCdcInBufferData);
    uint16_t maxPopCount = usbobufGetMaxPopCount(&usbCdcOutBufferData);
    
    if (count > maxPopCount)
    {
    count = maxPopCount;
    }
    if (count)
    {
    usbobufPop(&usbCdcOutBufferData, pAppBuffer, count);
    //
    // send the string "spi" to console 
    //
    usbibufPush(&usbCdcInBufferData, spi, spiLength);
    }
    stopflag = true;
    }
    }

  • Hello YiKai,

    I use MEMS inertial sensor which uses to measure the attitude of the object. The communication protocol between MEMS sensor and CC2538 is SPI, and I want to collect sensor data by CC2538 and then send the received data to PC through USB interface.
    Do you have any idea for the data communication?

    Thanks ,

    Tao
  • Let me clarify something first. So, you want to connect CC2530 to MEMS inertial sensor with SPI interface and get data. Then, CC2538 just send the data to PC through USB interface. There is no RF invloved, isn't it?

  • Hello YiKai,

    Yes, there is no RF involved in my design. An example code available (e2e.ti.com/.../404305), however, I should press a key to get the data from my USB interface.