0
votes

Im programming an Arduino mega 2560. And I bought an tft LCD and for that I want to use a SD card so I can put my pictures on it.

I downloaded this library but its giving me errors.

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*'

The problem is imo here:

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 */

When I make it a .c file, it gives me more errors, like this one:

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_*)'

so I think it should be compiled as a cpp.

EDIT:

I found out that I have to save is as cpp and in the program I have to write what icktoofay states

After that I got some errors, so I went to the line 585, as stated above and changed

BYTE *rbuff = buff;

into

BYTE rbuff = (unsigned char) buff;

And I found out that I had to add mcc.h to get rid of the errors of the "couldnt find resources".

And now Im getting these errors:

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

Ive tried to add #include TFT_ARDUINO_MEGA.h on top of the mcc.h and still no luck

1

1 Answers

1
votes

Compile it as a C file, but in the file that uses it, include pff.h like this:

extern "C" {
#include <pff.h>
}