Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
11 years, 10 months ago.
best way to get multiple USBDevice objects
Hi, I have noticed that one cannot simply do:
#include "mbed.h" #include "USBMSD_SD.h" #include "USBSerial.h" USBMSD_SD sd(p5, p6, p7, p8); //CMD, D0, CLK, D3 USBSerial pc; int main() { int i = 0; while(1) { pc.printf("hi!!, i'm a serial counter: %d\r\n", i++); wait(0.1); } }
Since both classes inherit from USBDevice, I'm guessing that they override each other, because in practice the one constructed last is the one that works.
I've looked at the code for both, and am thinking of migrating USBSerial.h / cpp into the USBMSD files, but I am not sure how to go about it.
at first I thought I could simply add more endpoints, but I think that would mess up the Windows drivers because of methods like configurationDesc() which tells Windows if the *singular* device is a thumbdrive or com port or whatever. (can I tell it that it is a usb hub or something, and then check for that somehow?)
Am I misunderstanding this? And I welcome any feedback or reference links on the subject.
3 Answers
11 years, 10 months ago.
Hi Jason,
You are right, with the current USBDevice implementation, you cannot declare multiple USBDevice objects. To do a USB composite device (in your case MSD - CDC), the simplest way is to merge the code as you said.
There is a thread where this subject has been discussed: http://mbed.org/questions/6/USB-CDC-MSC-Composite-Device/.
Cheers, Sam
11 years, 10 months ago.
Is there a hello world program anywhere that shows a USB composite device (i.e. MSD - CDC) working?
take a look at this page: http://mbed.org/users/okini3939/notebook/USB_Device/.
posted by 11 Jan 2013Thanks I'll try it later on but wasn't sure if it would work as the the last commit on this program was over 1 year ago and this seems quite a recent topic?
posted by 11 Jan 2013Hi I have tried the code in this page (http://mbed.org/users/okini3939/notebook/USB_Device/) but it didn't compile on the LPC11U24. I also tried to merge the .h and .cpp files on the USBMSD_SD and USBSerial libraries but also got nowhere (lots of errors) - need some help here guys!
posted by 12 Jan 2013Hi, I will try to post an Hello World example for a USB composite device at the beginning of next week.
posted by 12 Jan 2013Can I bump this thread. I too am very interested in a USB composite devices, specifically CDC and MSD. I am struggling with http://mbed.org/users/okini3939/notebook/USB_Device/
cheers, Adrian.
posted by 14 Mar 201310 years ago.
Doubtful I'll get an answer, but bumping this thread because I'm interested in this as well and it seems in 2 years still no one has gotten this working.