Describes predefine macros for mbed online compiler (armcc)

main.cpp

Committer:
MACRUM
Date:
2017-03-16
Revision:
6:40e873bbc5f7
Parent:
4:2b25b7a2c5fd
Child:
7:31420b1e1298

File content as of revision 6:40e873bbc5f7:

/**
 ******************************************************************************
 * @file    main.cpp
 * @author  Toyomasa Watarai
 * @version V1.0.0
 * @date    16 March 2017
 * @brief   armcc pre-defined macro check progmra
 ******************************************************************************
 * @attention
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
 #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(LED2, 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);
    }
}