简体   繁体   English

Cortex-M0 +的预定义cpu目标宏

[英]Predefined cpu target macro for Cortex-M0+

I am currently using predefined cpu target macros to make software run on multiple cpu targets. 我目前正在使用预定义的cpu目标宏来使软件在多个cpu目标上运行。

#ifdef __TARGET_CPU_CORTEX_M0
    [do something here]
#elif __TARGET_CPU_CORTEX_M3
    [do something here]
#else
    #error Unsupported compiler platform
#endif

Example: 例:

This works for Cortex-M0 and Cortex-M3, but I can't figure out what macro to use for Cortex-M0+. 这适用于Cortex-M0和Cortex-M3,但我不知道要为Cortex-M0 +使用哪个宏。 Does anyone know which macro I can use? 有谁知道我可以使用哪个宏? I use the armcc compiler. 我使用armcc编译器。

This is documented , albeit rather obliquely. 这是有据可查的 ,尽管相当倾斜。 The relevant macro name is derived from the command-line option, thus --cpu=Cortex-M0plus defines __TARGET_CPU_CORTEX_M0PLUS . 相关的宏名称是从命令行选项派生的,因此--cpu=Cortex-M0plus定义了__TARGET_CPU_CORTEX_M0PLUS

Annoyingly, whilst it doesn't show up in the --cpu=list output, the compiler (I tried armcc version 5.04) does also recognise the option --cpu=Cortex-M0+ , for which it defines the macro __TARGET_CPU_CORTEX_M0_ 令人讨厌的是,尽管它未显示在--cpu=list输出中,但编译器(我尝试使用armcc 5.04版) 可以识别选项--cpu=Cortex-M0+ ,它为宏定义了__TARGET_CPU_CORTEX_M0_

In general, invoking armcc --cpu=xx --list_macros /dev/null will show what macros are defined for cpu option xx (or an error if it isn't supported). 通常,调用armcc --cpu=xx --list_macros /dev/null将显示为cpu选项xx定义了哪些宏(如果不支持,则显示错误)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM