The objective was to read bitmap files from a SD card and display them on a ILI9341 TFT display.
You can read more about SPI interfacing of a microcontroller to a ILI9341 TFT display here: ILI9341 TFT display and about FAT filesystem implementation on SD card here: FAT filesystem on SD card
First of all, we need to study bitmap (.bmp) files to know how to correctly interpret the data contained in them.
I found a nice article about bitmap files here: http://paulbourke.net/dataformats/bmp/
Here is how the functions were called from main:
File object
FIL filbmpimg; /* File object for reading from bitmap image */
Call from main
/* Display bmp file on screen */
res = f_open(&filbmpimg, "bgimg1.bmp", FA_READ);
if(res)
{
FileExplorer_Screen_NewLine();
FileExplorer_Screen_AddText("Error opening bmimg1.bmp");
}
else
{
Bitmapfile_Display(&filbmpimg, 0, 0);
}
You can download below the code which I used to successfully display some BMP files from the SD card on the ILI9341 TFT display.