我正在编程Arduino mega 2560。 我买了一台tft液晶显示器,为此我想使用SD卡,这样我就可以把它放在上面了。
我下载了这个库,但它给了我错误。
C:\Arduino\libraries\pff\pff.cpp: In function 'FRESULT pf_read(void*, short unsigned int, short unsigned int*)': C:\Arduino\libraries\pff\pff.cpp:585: error: invalid conversion from 'void*' to 'unsigned char*'
问题在于:
pff.cpp:
FRESULT pf_read (
void* buff, /* Pointer to the read buffer (NULL:Forward data to the stream)*/
WORD btr, /* Number of bytes to read */
WORD* br /* Pointer to number of bytes read */
)
pff.h:
FRESULT pf_read (void*, WORD, WORD*); /* Read data from the open file */
当我把它变成.c文件时,它会给我更多错误,比如这个错误:
tft_menu.cpp.o: In function `open_root_dir()': C:\AppData\Local\Temp\build7310099894910129341.tmp/tft_menu.cpp:594: undefined reference to `pf_opendir(_DIR_*, char const*)' tft_menu.cpp.o: In function `mount_sd()': C:\AppData\Local\Temp\build7310099894910129341.tmp/tft_menu.cpp:583: undefined reference to `disk_initialize()' C:\AppData\Local\Temp\build7310099894910129341.tmp/tft_menu.cpp:585: undefined reference to `pf_mount(_FATFS_*)' tft_menu.cpp.o: In function `bitmap_show(char*)': C:\AppData\Local\Temp\build7310099894910129341.tmp/tft_menu.cpp:472: undefined reference to `pf_open(char const*)' C:\AppData\Local\Temp\build7310099894910129341.tmp/tft_menu.cpp:476: undefined reference to `pf_read(void*, unsigned short, unsigned short*)' C:\AppData\Local\Temp\build7310099894910129341.tmp/tft_menu.cpp:518: undefined reference to `pf_read(void*, unsigned short, unsigned short*)' tft_menu.cpp.o: In function `show_bitmap()': C:\AppData\Local\Temp\build7310099894910129341.tmp/tft_menu.cpp:603: undefined reference to `pf_readdir(_DIR_*, _FILINFO_*)'
所以我认为它应该编译为cpp。
编辑:
我发现我必须保存为cpp,在程序中我必须写出icktoofay状态
之后我遇到了一些错误,所以我按照上面的说明进入了第585行并更改了
BYTE * rbuff = buff;
进入
BYTE rbuff =(unsigned char )buff;
我发现我必须添加mcc.h来摆脱“无法找到资源”的错误。
现在我得到了这些错误:
C:\libraries\mmc/mmc.h: In function 'void init_spi()':
C:\libraries\mmc/mmc.h:21: error: 'PORTL' was not declared in this scope
C:\libraries\mmc/mmc.h:21: error: 'PORTL0' was not declared in this scope
C:\libraries\mmc/mmc.h:22: error: 'PORTB' was not declared in this scope
C:\libraries\mmc/mmc.h:22: error: 'PORTB2' was not declared in this scope
C:\libraries\mmc/mmc.h:22: error: 'PORTB1' was not declared in this scope
C:\libraries\mmc/mmc.h:23: error: 'DDRB' was not declared in this scope
C:\libraries\mmc/mmc.h:23: error: 'PORTB0' was not declared in this scope
C:\libraries\mmc/mmc.h:25: error: 'DDRL' was not declared in this scope
C:\libraries\mmc/mmc.h:27: error: 'SPCR' was not declared in this scope
C:\libraries\mmc/mmc.h:27: error: 'SPE' was not declared in this scope
C:\libraries\mmc/mmc.h:27: error: 'MSTR' was not declared in this scope
C:\libraries\mmc/mmc.h:28: error: 'SPSR' was not declared in this scope
C:\libraries\mmc/mmc.h:28: error: 'SPI2X' was not declared in this scope
我试过在mcc.h上添加#include TFT_ARDUINO_MEGA.h并且仍然没有运气
答案 0 :(得分:1)
将其编译为C文件,但在使用它的文件中,包括pff.h
,如下所示:
extern "C" {
#include <pff.h>
}