Describes predefine macros for mbed online compiler (armcc)

Committer:
MACRUM
Date:
Wed Mar 11 06:26:11 2020 +0000
Revision:
10:9a8be9fef9e7
Parent:
9:cf8652c08e46
Child:
11:d7b5a74747b2
Add Arm compiler 6 and GCC support

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MACRUM 6:40e873bbc5f7 1 /**
MACRUM 6:40e873bbc5f7 2 ******************************************************************************
MACRUM 6:40e873bbc5f7 3 * @file main.cpp
MACRUM 6:40e873bbc5f7 4 * @author Toyomasa Watarai
MACRUM 6:40e873bbc5f7 5 * @version V1.0.0
MACRUM 6:40e873bbc5f7 6 * @date 16 March 2017
MACRUM 6:40e873bbc5f7 7 * @brief armcc pre-defined macro check progmra
MACRUM 6:40e873bbc5f7 8 ******************************************************************************
MACRUM 6:40e873bbc5f7 9 * @attention
MACRUM 6:40e873bbc5f7 10 *
MACRUM 6:40e873bbc5f7 11 * Licensed under the Apache License, Version 2.0 (the "License");
MACRUM 6:40e873bbc5f7 12 * you may not use this file except in compliance with the License.
MACRUM 6:40e873bbc5f7 13 * You may obtain a copy of the License at
MACRUM 6:40e873bbc5f7 14 *
MACRUM 6:40e873bbc5f7 15 * http://www.apache.org/licenses/LICENSE-2.0
MACRUM 6:40e873bbc5f7 16 *
MACRUM 6:40e873bbc5f7 17 * Unless required by applicable law or agreed to in writing, software
MACRUM 6:40e873bbc5f7 18 * distributed under the License is distributed on an "AS IS" BASIS,
MACRUM 6:40e873bbc5f7 19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
MACRUM 6:40e873bbc5f7 20 * See the License for the specific language governing permissions and
MACRUM 6:40e873bbc5f7 21 * limitations under the License.
MACRUM 6:40e873bbc5f7 22 */
MACRUM 8:09f55ce7afee 23 #include "mbed.h"
MACRUM 0:99f7e7890e03 24
MACRUM 4:2b25b7a2c5fd 25 #define xstr(s) str(s)
MACRUM 4:2b25b7a2c5fd 26 #define str(s) #s
MACRUM 4:2b25b7a2c5fd 27
MACRUM 10:9a8be9fef9e7 28 DigitalOut myled(LED1);
MACRUM 0:99f7e7890e03 29
MACRUM 0:99f7e7890e03 30 int main() {
MACRUM 10:9a8be9fef9e7 31 printf("\n");
MACRUM 10:9a8be9fef9e7 32 printf("System Clock = %ld\n", SystemCoreClock);
MACRUM 1:5d5b5bd67e5b 33 #ifdef MBED_USERNAME
MACRUM 10:9a8be9fef9e7 34 printf("mbed username: %s\n", xstr(MBED_USERNAME));
MACRUM 1:5d5b5bd67e5b 35 #endif
MACRUM 9:cf8652c08e46 36 #ifdef MBED_LIBRARY_VERSION
MACRUM 10:9a8be9fef9e7 37 printf("mbed library version: %d\n", MBED_LIBRARY_VERSION);
MACRUM 9:cf8652c08e46 38 #endif
MACRUM 8:09f55ce7afee 39 #ifdef MBED_CONF_RTOS_PRESENT
MACRUM 10:9a8be9fef9e7 40 printf("Mbed OS %d.%d.%d\n", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION);
MACRUM 8:09f55ce7afee 41 #endif
MACRUM 8:09f55ce7afee 42
MACRUM 2:fe7a36257939 43 #ifdef __CC_ARM
MACRUM 4:2b25b7a2c5fd 44 #ifdef __MICROLIB
MACRUM 10:9a8be9fef9e7 45 printf("Built with ARM compiler and micro library (uARM)\n");
MACRUM 4:2b25b7a2c5fd 46 #else
MACRUM 10:9a8be9fef9e7 47 printf("Built with ARM compiler and standard library (ARM)\n");
MACRUM 4:2b25b7a2c5fd 48 #endif
MACRUM 10:9a8be9fef9e7 49 printf("ARM Compiler version : %d\n", __ARMCC_VERSION);
MACRUM 0:99f7e7890e03 50
MACRUM 0:99f7e7890e03 51 #ifdef __ARM_NEON__
MACRUM 10:9a8be9fef9e7 52 printf("NEON is available\n");
MACRUM 0:99f7e7890e03 53 #else
MACRUM 10:9a8be9fef9e7 54 printf("NEON is not available\n");
MACRUM 0:99f7e7890e03 55 #endif
MACRUM 0:99f7e7890e03 56
MACRUM 0:99f7e7890e03 57 #ifdef __APCS_INTERWORK
MACRUM 10:9a8be9fef9e7 58 printf("ARM/Thumb Interworking is used\n");
MACRUM 0:99f7e7890e03 59 #endif
MACRUM 0:99f7e7890e03 60
MACRUM 0:99f7e7890e03 61 #ifdef __APCS_ROPI
MACRUM 10:9a8be9fef9e7 62 printf("--apcs /ropi is used\n");
MACRUM 0:99f7e7890e03 63 #endif
MACRUM 0:99f7e7890e03 64
MACRUM 0:99f7e7890e03 65 #ifdef __APCS_RWPI
MACRUM 10:9a8be9fef9e7 66 printf("--apcs /rwpi is used\n");
MACRUM 0:99f7e7890e03 67 #endif
MACRUM 0:99f7e7890e03 68
MACRUM 0:99f7e7890e03 69 #ifdef __APCS_FPIC
MACRUM 10:9a8be9fef9e7 70 printf("--apcs /fpic is used\n");
MACRUM 0:99f7e7890e03 71 #endif
MACRUM 0:99f7e7890e03 72
MACRUM 0:99f7e7890e03 73 #ifdef __BIG_ENDIAN
MACRUM 10:9a8be9fef9e7 74 printf("Target is big endian\n");
MACRUM 4:2b25b7a2c5fd 75 #else
MACRUM 10:9a8be9fef9e7 76 printf("Target is little endian\n");
MACRUM 0:99f7e7890e03 77 #endif
MACRUM 0:99f7e7890e03 78
MACRUM 0:99f7e7890e03 79 #ifdef __CHAR_UNSIGNED__
MACRUM 10:9a8be9fef9e7 80 printf("char type is unsigned\n");
MACRUM 0:99f7e7890e03 81 #else
MACRUM 10:9a8be9fef9e7 82 printf("char type is signed\n");
MACRUM 0:99f7e7890e03 83 #endif
MACRUM 10:9a8be9fef9e7 84 printf("EDG front-end version : %d\n", __EDG_VERSION__);
MACRUM 0:99f7e7890e03 85
MACRUM 10:9a8be9fef9e7 86 printf("Emulated GNU version : %d.%d\n", __GNUC__, __GNUC_MINOR__);
MACRUM 10:9a8be9fef9e7 87 printf("Current emulated GNU version : %s\n", __VERSION__);
MACRUM 0:99f7e7890e03 88
MACRUM 10:9a8be9fef9e7 89 printf("Optimize level : %d\n", __OPTIMISE_LEVEL);
MACRUM 0:99f7e7890e03 90
MACRUM 0:99f7e7890e03 91 #ifdef __OPTIMISE_SPACE
MACRUM 10:9a8be9fef9e7 92 printf("Optimized by size\n");
MACRUM 0:99f7e7890e03 93 #endif
MACRUM 0:99f7e7890e03 94
MACRUM 0:99f7e7890e03 95 #ifdef __OPTIMISE_TIME
MACRUM 10:9a8be9fef9e7 96 printf("Optimized by speed\n");
MACRUM 0:99f7e7890e03 97 #endif
MACRUM 0:99f7e7890e03 98
MACRUM 10:9a8be9fef9e7 99 printf("Target ARM architecture : %d\n", __TARGET_ARCH_ARM);
MACRUM 10:9a8be9fef9e7 100 printf("Target Thumb architecture : %d\n", __TARGET_ARCH_THUMB);
MACRUM 10:9a8be9fef9e7 101
MACRUM 10:9a8be9fef9e7 102 #elif defined (__GNUC__)
MACRUM 10:9a8be9fef9e7 103 #if defined (__ARMCC_VERSION)
MACRUM 10:9a8be9fef9e7 104 printf("Built with ARM compiler 6\n");
MACRUM 10:9a8be9fef9e7 105 printf("Arm compiler version %d\n", __ARMCC_VERSION);
MACRUM 0:99f7e7890e03 106 #else
MACRUM 10:9a8be9fef9e7 107 printf("Built with GNU compiler\n");
MACRUM 0:99f7e7890e03 108 #endif
MACRUM 10:9a8be9fef9e7 109 printf("Compatible GCC version %d.%d, clang version %s\n", __GNUC__, __GNUC_MINOR__, __VERSION__);
MACRUM 10:9a8be9fef9e7 110 printf("Target ARM architecture : %d-%c\n", __ARM_ARCH, __ARM_ARCH_PROFILE);
MACRUM 10:9a8be9fef9e7 111 #else
MACRUM 10:9a8be9fef9e7 112 printf("Not build with ARM compiler\n");
MACRUM 10:9a8be9fef9e7 113 #endif
MACRUM 10:9a8be9fef9e7 114
MACRUM 10:9a8be9fef9e7 115 printf("Compile date : %s\n", __DATE__);
MACRUM 10:9a8be9fef9e7 116 printf("Compile time : %s\n", __TIME__);
MACRUM 10:9a8be9fef9e7 117
MACRUM 4:2b25b7a2c5fd 118
MACRUM 4:2b25b7a2c5fd 119 while(1) {
MACRUM 4:2b25b7a2c5fd 120 myled = !myled;
MACRUM 10:9a8be9fef9e7 121 #if (MBED_MAJOR_VERSION >= 5) && (MBED_MINOR_VERSION >= 15)
MACRUM 10:9a8be9fef9e7 122 thread_sleep_for(400);
MACRUM 10:9a8be9fef9e7 123 #else
MACRUM 4:2b25b7a2c5fd 124 wait(0.4);
MACRUM 10:9a8be9fef9e7 125 #endif
MACRUM 4:2b25b7a2c5fd 126 }
MACRUM 0:99f7e7890e03 127 }