我有一个Arduino Uno和一个Linux环境.尽管Arduino IDE非常棒,但是如果出现问题,它并没有给我太多的帮助.它也变得极其缓慢并且有时会停止与芯片通信.
另一种方法是使用AVR-GCC/g ++和AVRDude工具链对我的Arduino Uno进行编码.但是,在使用简单的文本编辑器和命令行工具进行编程时,我非常希望能够访问与Arduino相同的功能(如Serial,digitalWrite等).
所以我试图找到头文件,其中定义了所有函数,即"Arduino.h" /usr/share/arduino/hardware/arduino/cores/arduino.
我用它来编译(使用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
Run Code Online (Sandbox Code Playgroud)
编译这段代码:
#include "Arduino.h"
int main(void)
{
init();
pinMode(13,OUTPUT);
while(1){
digitalWrite(13,HIGH);
delay(1000);
digitalWrite(13,LOW);
delay(1000);
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
但是当我尝试编译时(似乎未定义引用'xxxxxxxxx')似乎没有识别出任何函数.那么需要包含哪些确切的头文件以确保我可以使用相同的功能?还是我错过了别的什么?