【发布时间】:2012-10-26 23:09:59
【问题描述】:
我有一个 Arduino Uno 和一个 Linux 环境。尽管 Arduino IDE 非常棒,但是如果出现问题,它并没有给我太多的输入。而且它还会变得非常缓慢,有时会停止与芯片的通信。
另一种方法是使用 AVR-GCC/g++ 和 AVRDude 工具链对我的 Arduino Uno 进行编码。但是,我非常希望能够在使用简单的文本编辑器和命令行工具进行编程时访问与 Arduino 中相同的功能(如Serial、digitalWrite 等)。
所以我试图在/usr/share/arduino/hardware/arduino/cores/arduino中找到包含所有定义的函数的头文件,即“Arduino.h”。
我用这个来编译(使用makefile来做这个)
avr-gcc -mmcu=atmega328p -I. -gdwarf-2 -DF_CPU=16000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=testarduino.o -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard -std=gnu99 -MMD -MP -MF .dep/testarduino.elf.d testarduino.o --output testarduino.elf -Wl,-Map=testarduino.map,--cref -lm
编译这段代码:
#include "Arduino.h"
int main(void)
{
init();
pinMode(13,OUTPUT);
while(1){
digitalWrite(13,HIGH);
delay(1000);
digitalWrite(13,LOW);
delay(1000);
}
return 0;
}
但是,当我尝试编译时,似乎没有一个函数被识别出来(比如未定义的对 'xxxxxxxxx' 的引用)。那么需要包含哪些确切的头文件以确保我可以使用相同的功能呢?还是我错过了什么?
【问题讨论】: