Atmel Studio 7如何编译调试Arduino代码?
How Atmel Studio 7 compile and debug Arduino code?
Atmel 在他们的网站上声明:
Atmel Studio 7 features seamless one-click import of projects created in the Arduino development environment. Your sketch, including any libraries it references, will be imported into Studio 7 as a C++ project. Once imported, you can leverage the full capabilities of Studio 7 to fine-tune and debug your design. Atmel Studio 7 fully supports the powerful embedded debugger on the Arduino Zero board. For other Arduino boards, shield-adapters that expose debug connectors are available, or switch to one of the many available Xplained-Mini/PRO boards to fully leverage the Atmel HW eco-system. Regardless of what you choose, you will surely make something amazing.
我想知道它是如何工作的?它只是一个插件(visual-micro)意味着我们仍然必须安装Arduino软件吗?还是他们有自己的编译器和调试器?
Arduino 代码只是普通的 C++ 代码(包括一些 C++ 库)。
不同之处在于,在 Arduino IDE 中,您看不到所有代码。例如,main()
是 隐藏的 并在幕后编译。
在 Arduino sketch 中,只有 setup()
和 loop()
是可见的,但它们是从隐藏的 main()
调用的(重复调用 loop()
)。
因此,Atmel C++ 编译器编译在 Arduino IDE 中创建的草图应该没有问题,因为它已经是一个完整的 C++ 项目。
完成Danny_ds回答:
Arduino(和 8 位 AVR)的 "standard" Atmel 编译器现已 avr-gcc
,GCC 代表 GNU Compiler Collection(因此,一个免费软件工具)。
ArduinoIDE以及Atmel Studio使用的工具链。请注意,Atmel Studio 是可配置的,它可以使用另一个 toolchains/compilers(有人告诉我它至少存在 8 个 AVR 编译器)。
要了解如何在 Atmel Studio 中导入 Arduino 草图,最好先了解什么是 arduino:
- A "breadboard" 由 Atmega328 芯片供电
- 一个库(API 在
#include <Arduino.h>
以前 Program.h IIRC 时导入)
- 一个 IDE,完成所有编辑和 "makefile" 工作
让我们弹出堆栈:
首先,您可以使用自己的编辑器和 makefile 来清除 Arduino IDE。请参阅 Arduino Makefile on github 以轻松切换到此。
这样做,您可能必须在您的草图中添加 Arduino.h 包含。但是您可以完全控制源代码树处理。那是我的动机,当我早早退出 Arduino IDE 时,因为到那时不可能在同一个草图中使用 2 个库,Arduino-Makefile 允许的。
其次,如果您不打算使用 Serial
class(驱动 UART/USB 接口与 Duino[=51 进行控制台文本通信=]), 它带来了删除依赖项的诱惑......我试过了,我得出的结论是重写 setMode()
、digitalRead()
和 write 等函数......只是 显而易见:只需打开与您的代码并排的 PDF 数据表并相应地设置位。
ADC 转换、timer/counter 管理、eeprom read/write 甚至 UART 连接驱动,都比较棘手,因为它们意味着直接驱动 AVR I/O 寄存器,并了解子系统你正在与...互动,但并非不可能!
此外,除了 Arduino 之外,很可能还有(免费)库来推动这些工作。
在这一步之后,您的源代码树可以在 Studio 中按原样导入,并且(假设您的编译器仍然设置在 GCC 上,并且 Atmel Studio 知道您的依赖项),它将无缝编译。
所以 Atmel Studio 只需在项目中导入 Arduino 库(并且可能添加一些头文件包含,因为我们必须手动完成)以将其编译为本机项目。
注意 插入一些现有文件,特别是整个现有目录是 pain-in-the-ass 与 Studio。
Atmel 在他们的网站上声明:
Atmel Studio 7 features seamless one-click import of projects created in the Arduino development environment. Your sketch, including any libraries it references, will be imported into Studio 7 as a C++ project. Once imported, you can leverage the full capabilities of Studio 7 to fine-tune and debug your design. Atmel Studio 7 fully supports the powerful embedded debugger on the Arduino Zero board. For other Arduino boards, shield-adapters that expose debug connectors are available, or switch to one of the many available Xplained-Mini/PRO boards to fully leverage the Atmel HW eco-system. Regardless of what you choose, you will surely make something amazing.
我想知道它是如何工作的?它只是一个插件(visual-micro)意味着我们仍然必须安装Arduino软件吗?还是他们有自己的编译器和调试器?
Arduino 代码只是普通的 C++ 代码(包括一些 C++ 库)。
不同之处在于,在 Arduino IDE 中,您看不到所有代码。例如,main()
是 隐藏的 并在幕后编译。
在 Arduino sketch 中,只有 setup()
和 loop()
是可见的,但它们是从隐藏的 main()
调用的(重复调用 loop()
)。
因此,Atmel C++ 编译器编译在 Arduino IDE 中创建的草图应该没有问题,因为它已经是一个完整的 C++ 项目。
完成Danny_ds回答:
Arduino(和 8 位 AVR)的 "standard" Atmel 编译器现已 avr-gcc
,GCC 代表 GNU Compiler Collection(因此,一个免费软件工具)。
ArduinoIDE以及Atmel Studio使用的工具链。请注意,Atmel Studio 是可配置的,它可以使用另一个 toolchains/compilers(有人告诉我它至少存在 8 个 AVR 编译器)。
要了解如何在 Atmel Studio 中导入 Arduino 草图,最好先了解什么是 arduino:
- A "breadboard" 由 Atmega328 芯片供电
- 一个库(API 在
#include <Arduino.h>
以前 Program.h IIRC 时导入) - 一个 IDE,完成所有编辑和 "makefile" 工作
让我们弹出堆栈:
首先,您可以使用自己的编辑器和 makefile 来清除 Arduino IDE。请参阅 Arduino Makefile on github 以轻松切换到此。 这样做,您可能必须在您的草图中添加 Arduino.h 包含。但是您可以完全控制源代码树处理。那是我的动机,当我早早退出 Arduino IDE 时,因为到那时不可能在同一个草图中使用 2 个库,Arduino-Makefile 允许的。
其次,如果您不打算使用 Serial
class(驱动 UART/USB 接口与 Duino[=51 进行控制台文本通信=]), 它带来了删除依赖项的诱惑......我试过了,我得出的结论是重写 setMode()
、digitalRead()
和 write 等函数......只是 显而易见:只需打开与您的代码并排的 PDF 数据表并相应地设置位。
ADC 转换、timer/counter 管理、eeprom read/write 甚至 UART 连接驱动,都比较棘手,因为它们意味着直接驱动 AVR I/O 寄存器,并了解子系统你正在与...互动,但并非不可能!
此外,除了 Arduino 之外,很可能还有(免费)库来推动这些工作。
在这一步之后,您的源代码树可以在 Studio 中按原样导入,并且(假设您的编译器仍然设置在 GCC 上,并且 Atmel Studio 知道您的依赖项),它将无缝编译。
所以 Atmel Studio 只需在项目中导入 Arduino 库(并且可能添加一些头文件包含,因为我们必须手动完成)以将其编译为本机项目。
注意 插入一些现有文件,特别是整个现有目录是 pain-in-the-ass 与 Studio。