我目前正在开发一个使用arduino库(VirtualWire)正确执行的项目,但是想要从Arduino转移回纯C / C ++。
我可以:
- rewrite the actual arduino functions
- rewrite the calls to arduino functions (change pinmode to DDRx, etc)
- use the arduino core source code in conjunction with the library.
我已经尝试了最后一点,将相关的arduino源代码移入虚拟线库,但是当我尝试编译时,我无法链接到VirtualWire库。
注意:VirtualWire库及其依赖项(希望如此)与我的源代码(作为测试)位于同一目录中。
使用以下编译命令,我会遇到以下错误:
avr-g++ -mmcu=atmega32u4 -Os -DF_CPU=8000000UL -IVirtualWire -LVirtualWire -lVirtualWire transmitter.cpp -o transmitter.o
c:/winavr-20100110/bin/../lib/gcc/avr/4.3.3/../../../../avr/bin/ld.exe: cannot find -lVirtualWire
或者,
avr-g++ -mmcu=atmega32u4 -Os -DF_CPU=8000000UL -IVirtualWire -LVirtualWire transmitter.cpp -o transmitter.o
C:\cygwin\tmp/cc8d5ab7.o: In function `setup':
transmitter.cpp:(.text+0xe): undefined reference to `vw_set_tx_pin'
transmitter.cpp:(.text+0x14): undefined reference to `vw_set_rx_pin'
transmitter.cpp:(.text+0x1a): undefined reference to `vw_set_ptt_pin'
transmitter.cpp:(.text+0x20): undefined reference to `vw_set_ptt_inverted'
transmitter.cpp:(.text+0x28): undefined reference to `vw_setup'
C:\cygwin\tmp/cc8d5ab7.o: In function `main':
transmitter.cpp:(.text+0x6e): undefined reference to `vw_send'
transmitter.cpp:(.text+0x72): undefined reference to `vw_wait_tx'
transmitter.cpp:(.text+0x80): undefined reference to `delay'
最后,
avr-g++ -mmcu=atmega32u4 -Os -DF_CPU=8000000UL transmitter.cpp -o transmitter.o
transmitter.cpp:1:25: error: VirtualWire.h: No such file or directory
transmitter.cpp: In function 'int main()':
transmitter.cpp:26: error: 'HIGH' was not declared in this scope
transmitter.cpp:26: error: 'digitalWrite' was not declared in this scope
transmitter.cpp:27: error: 'uint8_t' was not declared in this scope
transmitter.cpp:27: error: expected primary-expression before ')' token
transmitter.cpp:27: error: 'vw_send' was not declared in this scope
transmitter.cpp:28: error: 'vw_wait_tx' was not declared in this scope
transmitter.cpp:29: error: 'LOW' was not declared in this scope
transmitter.cpp:30: error: 'delay' was not declared in this scope
transmitter.cpp: In function 'void setup()':
transmitter.cpp:42: error: 'CLKPR' was not declared in this scope
transmitter.cpp:44: error: 'vw_set_tx_pin' was not declared in this scope
transmitter.cpp:45: error: 'vw_set_rx_pin' was not declared in this scope
transmitter.cpp:46: error: 'vw_set_ptt_pin' was not declared in this scope
transmitter.cpp:47: error: 'vw_set_ptt_inverted' was not declared in this scope
transmitter.cpp:48: error: 'vw_setup' was not declared in this scope
transmitter.cpp:49: error: 'OUTPUT' was not declared in this scope
transmitter.cpp:49: error: 'pinMode' was not declared in this scope
我熟悉C / C ++,但直到今天才发现有不同类型的库。
有没有明显的错误,或者将这个库从Arduino转移到纯C / C ++的简单方法?
提前致谢!