c++mcurp2040

No tinyusb CDC's callback is called


I'm making my own simple number pad. it's gift for my older sister. but, I faced critical problem on USB-CDC communication part. I wrote USB descriptor that has two configurations. one is HID(Human Interface Device) and other one is CDC (Communication Device Class). and CDC will be for configuring the hardware and getting User Defined Function works that an external software is installed on the user computer.

I'm using tinyusb library to initialize RP2040's USB device interface. and I implemented that HID and CDC TX works. but CDC RX is never working.

Full schematic and its firmware source code can be found in my repository.

Video in GIF.

I'm trying to debug my hardware, like this:

extern "C" void tud_cdc_rx_cb(uint8_t itf) {
    char temp[3] = {0, };
    tft_print("DATA RECV: ");  // --> never,... never... NEVER.... :!!!!!!!!
    temp[0] = 'a' + itf;
    temp[1] =  '\n';
    tft_print(temp);

    uint8_t buf[64] = {0, };
    uint32_t len = tud_cdc_n_read(itf, buf, sizeof(buf));

    if (len) {
        msg_frame_receive(buf, len);
    }
}

but, it never be called. :( how can i make this work?


Solution

  • This question is solved today. It was solved by updating pico-sdk's tinyusb library to recent branch. and the callback is called perfectly. And the callback is promised to be called when the VCP data received at RP2040. of course, the sender of data is PC.

    I don't know actual reason why this problem could be solved by updating tinyusb library. but i just updated it and, it solved.

    See issue page on github for details: https://github.com/hathach/tinyusb/issues/2537