0

我正在编程一个 Arduino mega 2560。我买了一个 tft LCD,为此我想使用 SD 卡,这样我就可以把我的照片放在上面。

我下载了这个库,但它给了我错误。

C:\Arduino\libraries\pff\pff.cpp: 在函数'FRESULT pf_read(void*, short unsigned int, short unsigned int*)'中:
C:\Arduino\libraries\pff\pff.cpp:585:错误:从 'void*' 到 'unsigned char*' 的无效转换

问题是这里的imo:

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:在函数“open_root_dir()”中:
C:\AppData\Local\Temp\build7310099894910129341.tmp/tft_menu.cpp:594: 未定义对 `pf_opendir(_DIR_*, char const*)' 的引用
tft_menu.cpp.o:在函数“mount_sd()”中:
C:\AppData\Local\Temp\build7310099894910129341.tmp/tft_menu.cpp:583:未定义对“disk_initialize()”的引用
C:\AppData\Local\Temp\build7310099894910129341.tmp/tft_menu.cpp:585:未定义对“pf_mount(_FATFS_*)”的引用
tft_menu.cpp.o:在函数 `bitmap_show(char*)' 中:
C:\AppData\Local\Temp\build7310099894910129341.tmp/tft_menu.cpp:472: 未定义对 `pf_open(char const*)' 的引用
C:\AppData\Local\Temp\build7310099894910129341.tmp/tft_menu.cpp:476: 未定义对 `pf_read(void*, unsigned short, unsigned short*)' 的引用
C:\AppData\Local\Temp\build7310099894910129341.tmp/tft_menu.cpp:518: 未定义对 `pf_read(void*, unsigned short, unsigned short*)' 的引用
tft_menu.cpp.o:在函数“show_bitmap()”中:
C:\AppData\Local\Temp\build7310099894910129341.tmp/tft_menu.cpp:603: 未定义对 `pf_readdir(_DIR_*, _FILINFO_*)' 的引用

所以我认为它应该编译为cpp。

编辑:

我发现我必须保存为 cpp 并且在程序中我必须写下 icktoofay 的状态

之后我得到了一些错误,所以我去了585行,如上所述并改变了

字节 *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 ,但仍然没有运气

4

1 回答 1

1

将其编译为 C 文件,但在使用它的文件中,包含pff.h如下内容:

extern "C" {
#include <pff.h>
}
于 2012-01-02T03:03:40.387 回答