Describes predefine macros for mbed online compiler (armcc)

main.cpp

Committer:
MACRUM
Date:
2017-01-12
Revision:
4:2b25b7a2c5fd
Parent:
3:b802baa84f98
Child:
6:40e873bbc5f7

File content as of revision 4:2b25b7a2c5fd:

#include "mbed.h"

#define xstr(s) str(s)
#define str(s) #s

#if defined(TARGET_SAMD21J18A)
Serial pc(PB22, PB23); // tx, rx
DigitalOut myled(PA17, 0);
#elif defined(TARGET_LPC1768)
#define LED1 P0_22
Serial pc(USBTX, USBRX); // tx, rx
DigitalOut myled(P0_22, 1);
#else
Serial pc(USBTX, USBRX); // tx, rx
DigitalOut myled(LED1, 0);
#endif

int main() {
    pc.printf("\n");
    pc.printf("System Clock = %d\n", SystemCoreClock);
#ifdef MBED_USERNAME
    pc.printf("mbed username: %s\n", xstr(MBED_USERNAME));
#endif
    pc.printf("mbed library version: %d\n", MBED_LIBRARY_VERSION);
#ifdef __CC_ARM
#ifdef __MICROLIB
    pc.printf("Built with ARM compiler and micro library (uARM)\n");
#else
    pc.printf("Built with ARM compiler and standard library (ARM)\n");
#endif
    pc.printf("ARM Compiler version : %d\n", __ARMCC_VERSION);

#ifdef __ARM_NEON__
    pc.printf("NEON is available\n");
#else
    pc.printf("NEON is not available\n");
#endif

#ifdef __APCS_INTERWORK
    pc.printf("ARM/Thumb Interworking is used\n");
#endif

#ifdef __APCS_ROPI
    pc.printf("--apcs /ropi is used\n");
#endif

#ifdef __APCS_RWPI
    pc.printf("--apcs /rwpi is used\n");
#endif

#ifdef __APCS_FPIC
    pc.printf("--apcs /fpic is used\n");
#endif

#ifdef __BIG_ENDIAN
    pc.printf("Target is big endian\n");
#else
    pc.printf("Target is little endian\n");
#endif

#ifdef __CHAR_UNSIGNED__
    pc.printf("char type is unsigned\n");
#else
    pc.printf("char type is signed\n");
#endif
    pc.printf("EDG front-end version : %d\n", __EDG_VERSION__);

    pc.printf("Emulated GNU version : %d.%d\n", __GNUC__, __GNUC_MINOR__);
    pc.printf("Current emulated GNU version : %s\n", __VERSION__);

    pc.printf("Optimize level : %d\n", __OPTIMISE_LEVEL);

#ifdef __OPTIMISE_SPACE
    pc.printf("Optimized by size\n");
#endif

#ifdef __OPTIMISE_TIME
    pc.printf("Optimized by speed\n");
#endif

    pc.printf("Target ARM architecture : %d\n", __TARGET_ARCH_ARM);
    pc.printf("Target Thumb architecture : %d\n", __TARGET_ARCH_THUMB);
#else
    pc.printf("Not build with ARM compiler\n");
#endif

    while(1) {
        myled = !myled;
        wait(0.4);
    }
}