I did not the understand how to get file names in SD card using FATFS. I am able to read and write .txt
files with this code below:
if (f_mount(&fatfs, SDPath, 1) == FR_OK) {
/* Write Test */
res = f_open(&file, (const TCHAR*)"TESTTEST.TXT", FA_WRITE | FA_CREATE_ALWAYS);
res = f_write(&file, txtWriteBuf, strlen((const char*)txtWriteBuf), &bytesW);
res = f_close(&file);
/* Read Test */
res = f_open(&file, (const TCHAR*)"TESTTEST.TXT", FA_READ);
res = f_read(&file, txtReadBuf, f_size(&file), &bytesR);
res = f_close(&file);
/* File Listing Code */
???
/* LCD Display Code */
...
/* My LCD Codes Here */
}
After that I want to list these file names on my LCD screen. I am stuck at getting files names in root directory. I want these files to be listed on my LCD. And I have no idea about how to use f_opendir(...)
, f_readdir(...)
etc. How to do it in correct way?