Arm Mbed OS support forum

Multiple USB components

Hello.

Is it possible to have multiple USB components at the same time? If yes, what do I need to change in the following program to make it work?

I attempted to create a USBMSD device first, it works, and that the Linux host to which the device (a MakerDiary dev board) sees the MSD. Then I add USBSerial to the program, and neither work even when I just instantiate the USBSerial.

The error I see on the serial console is:
++ MbedOS Error Info ++

  • Error Status: 0x80FF0144 Code: 324 Module: 255*
  • Error Message: Assertion failed: ret == NRF_SUCCESS*
  • Location: 0x8911*
  • File: ./mbed-os/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/USBPhy_Nordic.cpp+88*
  • Error Value: 0x0*
  • Current Thread: main Id: 0x20001260 Entry: 0x9B21 StackSize: 0x1000 StackMem: 0x20002A60 SP: 0x2000397C *
  • For more info, visit: https://mbed.com/s/error?error=0x80FF0144&tgt=MAKERDIARY_NRF52840_MDK*
  • – MbedOS Error Info --*

The example / test program is:
#include “mbed.h”
#include “USBMSD.h”
#include “HeapBlockDevice.h”
#include “FATFileSystem.h”
#include “USBSerial.h”

BlockDevice *bd = new HeapBlockDevice(64 * 1024, 1, 1, 512);
USBMSD usb(bd, 0x0703, 0x0104, 0x0001);
FATFileSystem fs("myfs");

USBSerial pc;

int main()
{
    int err = fs.reformat(bd);
    printf("%s\n", (err ? "Fail :(" : "OK"));
    if (err) { error("error: %s (%d)\n", strerror(-err), err); }

    fs.mount(bd);

    FILE *f = fopen("/myfs/myreadme.txt", "w+");
    if (!f) { error("error: %s (%d)\n", strerror(errno), -errno); }

    err = fprintf(f, "This is an example line\n");
    if (err < 0) { error("error: %s (%d)\n", strerror(errno), -errno); }

    err = fclose(f);
    if (err < 0) { error("error: %s (%d)\n", strerror(errno), -errno); }

    while(true) { usb.process(); }
}

Anyone?