Porting MBed OS 6 to Adafruit nrf52840 Feather...redirect default printf() to USBSerial

Hello Mark,

You can try to define a custom console as advised here. For example:

#include "mbed.h"
#include "USBSerial.h"

DigitalOut  led1(LED_RED);

FileHandle* mbed::mbed_override_console(int)
{
    static USBSerial  usbSerialConsole;
    return &usbSerialConsole;
}

int main()
{
    while (true) {
        printf("hello\r\n");
        led1 = !led1;
        wait_us(1000 * 1000);
    }
}

If it works you can try to move:

#include "USBSerial.h"

FileHandle* mbed::mbed_override_console(int)
{
    static USBSerial  usbSerialConsole;
    return &usbSerialConsole;
}

to the PinNames.h (or other proper file) of your Adafruit Feather nrf52840 custom board.

Best regards, Zoltan

2 Likes