Replies: 4 comments 7 replies
-
Thank you for your willingness. Yes, there is lots of place that need documentation improvement, since I tend to like to write more code than docs in my little spare time. The getting started along with all other (little) documentation is a generic instructions and does not refer to any specific port since tinyusb support lots of MCUs. It will assume you are already familiar with your own mcu sdk in this case rp2040, and the mcu sdk provide their own documentation if it integrates tinyusb. It will also assume you are familiar with most of USB terminology and how it work (enumeration, protocol, driver etc ...) For host and device example, you could check out the https://github.com/hathach/tinyusb/tree/master/examples . With current state of (lacking) docs, if there is anything not clear, please check out the source code and example for how to use it. It is advisable to try out the stock example and get familiar with API. If you could, please continue to submit PR for documentation or any improvement in general, I will be happy to review them. |
Beta Was this translation helpful? Give feedback.
-
I'm in the same boat. I have LPC55, LP546, EFM32GG and SAME70 boards. (I also have TI MSP432 and TM4C hardware.) I have a design in process that will use LPC546 but I need USB support and NXP's idea of a library is awful. Hence, tinyusb. But where to start? The distribution includes various examples but they don't build. The line is "include tinyusb in your project." If anyone has a full-up project for any of these boards that builds right out of the box, please send it along. Once I understand the process I can write a good "getting started" document. |
Beta Was this translation helpful? Give feedback.
-
I just want to chime in that I'm starting down this route of implementing tusb on a supported board but to integrate it with the rest of the application codebase I need to pull tusb into the vendor's IDE. Because we're using a supported board I'm hopeful that we need to change as little as possible, aside from the compiler aspects, to get things working. I have followed the getting started and previously successfully built and tested an appropriate example but knowing which callbacks need implementing and how to connect them within the existing codebase is quite hard to work out. I will post more specific questions as I go (@a-h's approach of being specific and detailed is the way to go on these things where you're unsure and need help) and if I find answers, I will share them here, or wherever we end up putting such information ( like a more in-depth appendix to the getting started page). |
Beta Was this translation helpful? Give feedback.
-
This is because TinyUSB is easier to incorporate to a project than some other USB stack. It's a bit of a marketing formula, but for me it's true! When I understood that it was enough to recover only:
Then:
Nothing very complicated. It becomes a little more vague when using an unsupported RTOS: understand that you have to fill in tusb_os_custom.h and not an osal_xxx.h file (like osal_custom.h). And then know whether to create a dedicated TinyUSB task or call tud_task() from the interrupt. There seems to be a line that says so, but a small paragraph on what to do and what not to do when you have an RTOS would be welcome. Here is my experience after a few days with TinyUSB on various STM32, and the details that I would have liked to find in the doc. But frankly I didn't have any particular difficulty using TinyUSB in CDC in my project. Then you have to have USB skills to write descriptors and use callbacks. I think it's not the resort of the Tiny USB doc for the moment. But some links to informative sites would be helpful. |
Beta Was this translation helpful? Give feedback.
-
I've just spent a few hours getting the Raspberry Pi Pico to work as a USB host.
I found the examples a bit confusing, so I took the approach of stripping it all back to get keyboard and mouse input for the Pico:
https://github.com/a-h/pico_usb_kbd_mouse
I have no idea whether it's a sufficiently robust example, or if it has glaring holes that make it completely unacceptable. Some feedback would be useful. Maybe it could make a good example for the repo?
To get started, I tried to start from the documentation, but I struggled to understand it. I'm not expert enough in the project to safely write new documentation, but I can share my experience, and suggest some ways to improve it, or work with someone else to write it up.
To put my experience into context, it's my first time using the project, I have been a software engineer for 20 years using Go, JavaScript, C#, Python etc. day to day. Over the last 5 years I've been making things with ESP8266 boards and the like, writing C (which I last touched 15 years before that, when CMake hadn't been invented yet, so I don't know anything about that). This library seems great, but despite my experience, I didn't find it easy to get started using the project.
My thoughts on "Getting started"
At the time of writing, the getting started guide of TinyUSB says to:
For the Raspberry Pi Pico, none of these steps are required, since TinyUSB is included in the Raspberry Pi Pico SDK. I also don't know how to add things to an include path. I assume that's something to do with CMakeLists.txt?
It also says to:
I have no idea how to "properly define" the macros, and which ones are "required", and which "few more" I need to add, but I just assumed the Raspberry Pi Pico SDK was taking care of it all. In my example, I was able to take the
tusb_config.h
and strip it right back.Next, it says:
If you're trying to achieve a goal, like receiving USB input, then I guess you're using the USB host. If you're trying to allow a PC to read from your device over USB, then I guess you're using the device stack?
I have no idea how to find out I'm using the device stack, and how I'd create/modify USB descriptors. And I don't know how I'd "implement all tud descriptor callbacks". I just skipped this and it worked, presumably because I'm using the USB host?
No problem here,
tusb_init()
is present in the example.I didn't need to do this at all. I assume the Raspberry Pi Pico SDK is doing this for me? I didn't see anything like this in the examples.
This one confused me. How am I supposed to know what I've enabled, and what the callbacks are?
After a bit of messing around, I realised that the
tusb_config.h
file containsCFG_TUH_HID
etc., and that these are enabling classes of USB behaviours.So, if I enable
CFG_TUH_HID
, I need to look at the source code in https://github.com/hathach/tinyusb/blob/master/src/class/hid/hid_host.h and read through theCallbacks
section to see what the required functions are.This was OK for me, because
tuh_task
is present in the example.board_init()
is present, it doesn't seem to be mentioned in the getting started guide.Next steps
If anyone's up for updating the getting started guide, I'd be happy to test out how easy it is to follow, edit the copy, or pair program with someone that's experienced with the project to start up a new project while taking notes, then write it up.
Beta Was this translation helpful? Give feedback.
All reactions