Is the target name available as a macro?

I’m having trouble setting the printf baudrate to anything other than 9600 baud on the NUCLEO-L476RG. I’d like to see if my test is using the right target and print out the target.

I know there are specific defines for specific targets (like in
#if defined(TARGET_DISCO_F051R8) || defined(TARGET_NUCLEO_F030R8) || defined(TARGET_NUCLEO_F031K6) || defined(TARGET_NUCLEO_F042K6)
) but I want a generic piece of code that will print out the current target.

Also, a list of all macro’s defined in the online compiler would be great.

Kind regards,
Ivo

    printf("Target: %s\n", MBED_STRINGIFY(TARGET_NAME));
    printf("Mbed OS version: %d.%d.%d\n\n", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION); 

The MBED_STRINGIFY is neccessary for the compiler, the MBED version makes it compatible with the supported toolchains.
There are more Macros from the configuration system, you can list them by “mbed compile --config” when you work with mbed-cli.

2 Likes