简体   繁体   English

此代码是什么意思?

[英]what does this code mean ?

I'm reading a project , and I found this code, which I don't unterstand. 我正在阅读一个项目,并且找到了这段代码,我对此并不陌生。

#define OUT_PINS            {X2_PIN, PIOC, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT}, \
                    {Y2_PIN, PIOC, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT}, \
                    {Z2_PIN, PIOC, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT}

the program is running on SAM3S a cortex M3 from Atmel . 该程序在来自Atmel的cortex M3的SAM3S上运行。

X2_Pin , Y2_Pin and Z2_Pin are defined . 定义了X2_Pin,Y2_Pin和Z2_Pin。

can anyone explain o me what OUT_PINS now is ? 谁能解释我现在的OUT_PINS是什么?

OUT_PINS is a macro defined with some 2D array values. OUT_PINS是使用某些2D数组值定义的宏。 check the following example for better understanding. 检查以下示例,以更好地理解。

eg: int *OP[] = {OUT_PINS } is similar to 例如: int *OP[] = {OUT_PINS }

int *OP[] = {{X2_PIN, PIOC, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT}, \
                    {Y2_PIN, PIOC, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT}, \
                    {Z2_PIN, PIOC, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT}}

Well, in this case you dont really need this macro. 好吧,在这种情况下,您实际上不需要此宏。 But it brings your code a better overview. 但这为您的代码带来了更好的概览。 If u work with macros/defines and you need changes in your code you only have to change your macros/defines. 如果您使用宏/定义,并且您需要在代码中进行更改,则只需更改宏/定义。

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

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