自定义库的 Arduino Due 条件编译常量

标签 arduino arduino-ide

我正在编写一个自定义库,它在 Arduino Uno 上正常工作。然而,我现在已经掌握了 Arduino Due,我需要定义一些特定于板的引脚常量。

我知道对于大多数板,您可以通过 #ifdef 指令使用 \\arduino-1.5.2\hardware\tools\avr\avr\include 中定义的 IO 常量来执行此操作\avr\io.h。例如:

#if defined (__AVR_ATmega128__)
    //do something specific
#endif

有谁知道用于 Due 的正确常量是什么?

最佳答案

_SAM3XA_ 可以工作,但包括许多其他 Atmel ARM 芯片(SAM3X8C、SAM3X8H 等)。

更准确的应该是

#if defined (__arm__) && defined (__SAM3X8E__) // Arduino Due compatible
// your Arduino Due compatible code here
#endif

(有关详细信息,请参阅文件 sam3.h。)

如果您只想针对 Arduino Due(省略兼容板),您可以使用

#if defined (_VARIANT_ARDUINO_DUE_X_)
// your Arduino Due code here
#endif

(这是在 Arduino Due 的 variant.h 文件中定义的。)

关于自定义库的 Arduino Due 条件编译常量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17723733/

相关文章:

C++ float 到 stringstream 的字符串转换失败

xcode - 在 Xcode 中使用 embedXcode 进行 Arduino 开发

c++ - 在 Arduino IDE 中使用正则表达式库时未定义对 `longjmp' 的引用

arduino-ide - 如何使用 NodeMCU 和 arduino ide 修复 "SerialTimeoutException: Write timeout"错误

c - 带有 F() 的 println 中的 Arduino sprintf

php - 使用 cURL 向 Arduino 发送 HTTP POST

c - Arduino uno无法上传

android - 如何将Arduino和Android连接到同一服务器?

ruby - 需要帮助改进 Ruby DSL 以控制 Arduino 控制的饮料分配器(bar monkey)

c++ - 从 char 到 const char* 的无效转换