Arduino 编程与标准 C 有何不同? [英] How is programming an Arduino different than standard C?
问题描述
我有嵌入式系统编程背景(TI MSP430、Atmel ATxmega).对 Arduino 进行编程与那些有什么不同?我可以掌握哪些 C 语言知识来编写 Arduino?
I have a background in programming embedded systems (TI MSP430, Atmel ATxmega). How is programming an Arduino different than those? What knowledge about C can I take in to programming the Arduino?
推荐答案
虽然我不了解 ATXMega,但在较新的 Arduino 上使用的 ATmega328 等 8 位 AVR 芯片使用 AVR-GCC 编译器.这允许将 C 甚至 C++ 编译为 AVR 芯片.AVR-GCC 上一层是 AVR Libc,这是一个 C 库,可以为AVR 是一个更高级别的任务(不再需要直接引用寄存器,等等).
While I don't know about the ATXMega, the 8-bit AVR chips like the ATmega328 used on the newer Arduinos use the AVR-GCC compiler. This allows for compiling C and even C++ to an AVR chip. One level above the AVR-GCC is the AVR Libc, a C library that makes programming for the AVR a higher level task (no longer have to refer to registers directly, and so on).
Arduino IDE 在后端使用 AVR-GCC 和 AVR libc 库.此外,Arduino IDE 使其他库可用,就像一个漂亮的串行接口.
The Arduino IDE uses AVR-GCC and AVR libc library in the backend. In addition, the Arduino IDE makes other libraries available, like a nice Serial interface.
最后,Arduino 带有在 AVR 芯片上烧录的引导加载程序.引导加载程序可以简单地使用串行连接(来自 USB)而不是系统内编程器或开发板对 AVR 进行编程.
Finally, the Arduino comes with a bootloader burned on the AVR chip. The bootloader simply makes it possible to program the AVR using a serial connection (from USB) instead of an In-Sytem Programmer or Development Board.
足够的背景故事来回答您的问题:Arduino 可以用 C 甚至 C++ 进行编程.可用的库是用 C 编写的,所有内容都将使用 AVR-GCC 编译.甚至不需要 Arduino IDE.
Enough backstory, to answer your question: The Arduino can be programmed in C and even C++. The libraries available are written in C and everything will compiled using AVR-GCC. The Arduino IDE isn't even required.
编辑
似乎对这个话题有相当多的兴趣.我写了一篇博文,试图提供 关于 AVR、Arduino 和 AVR-GCC 的更深入的细节.
There seems to be a decent amount of interest in this topic. I wrote a blog post to try and give more in-depth details on the AVR, Arduino, and AVR-GCC.
这篇关于Arduino 编程与标准 C 有何不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!