我想在全局标头中将引脚定义声明为一条简单的行,例如:
#define STATUS_LED B,7
Run Code Online (Sandbox Code Playgroud)
然后,我想将此引脚定义传递给以上功能:
CMBset_out(STATUS_LED);
Run Code Online (Sandbox Code Playgroud)
我不知道该如何处理-MY_PIN格式正确,可以在预编译阶段替换。
#define CMBsbi(port, pin) (PORT##port) |= (1<<pin)
#define CMBset_out(port,pin) (DDR##port) |= (1<<pin)
// define pins
#define STATUS_LED B,7
Run Code Online (Sandbox Code Playgroud)
Then, I want to pass this pin definition to function above (hw_init_states() is declared in the same header file called from main C file):
// runtime initialization
void hw_init_states(){
#ifdef STATUS_LED
CMBset_out(STATUS_LED);
#endif
}
Run Code Online (Sandbox Code Playgroud)
But I get a compilation error:
Error 1 macro "CMBset_out" requires 2 arguments, but only 1 given GENET_HW_DEF.h 68 23 Compass …Run Code Online (Sandbox Code Playgroud)