11 years, 3 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, 3 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, 3 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 Samuel Mokrani 11 Jan 2013

Thanks 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 Martin Smith 11 Jan 2013

Hi 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 Martin Smith 12 Jan 2013

Hi, I will try to post an Hello World example for a USB composite device at the beginning of next week.

posted by Samuel Mokrani 12 Jan 2013

Can 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 Adrian Watter 14 Mar 2013
9 years, 5 months 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.