Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5369

SDK • Re: USB Data with interrupts

$
0
0
What's going on behind the scenes when you just use the SDK's pico_enable_stdio_usb() is that the SDK configures TinyUSB with a single CDC interface, calls tud_init(), arranges to have tud_task() called regularly, and then provides a busy-waiting set of function calls to access that CDC interface.

If you do all that yourself instead of using the stdio_usb, you can access the CDC with tud_cdc_n_read(), tud_cdc_n_write_available(), tud_cdc_n_write() etc and if you want you can have callbacks when the device is connected, when data are available, when tx is complete etc.

Furthermore, if you do that and provide two CDC interfaces, you can enable the stdio_usb as well - it will notice that you've done all the hard work and will use one of your CDCs for the console (useful for debugging/control) while leaving the second one for you to work with.

Unfortunately, this is one of those things where once you've done it you'll realise it's all straightforward and easy, but actually getting to that point is quite hard because TinyUSB is almost entirely devoid of documentation. I don't have a simple example to point you at, but I think you can find them out there if you go looking.

Statistics: Posted by arg001 — Fri Jan 19, 2024 1:49 pm



Viewing all articles
Browse latest Browse all 5369

Trending Articles