1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
21
22
23
24
29
30
31
32
37
38
39
40
41
42
43
60
65
66
67
68
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
94
98
99
100
101
110
111
112
113
114
/* ... */
#include "main.h"
Includes
FATFS SD_FatFs;
char SD_Path[4];
FILELIST_FileTypeDef FileList;
Private variables
/* ... */
uint8_t SD_StorageInit(void)
{
BSP_SD_Init();
if(BSP_SD_IsDetected() == SD_PRESENT )
{
if(FATFS_LinkDriver(&SD_Driver, SD_Path) == 0)
{
if((f_mount(&SD_FatFs, (TCHAR const*)SD_Path, 0) != FR_OK))
{
LCD_ErrLog("Cannot Initialize FatFs! \n");
return 1;
}if ((f_mount(&SD_FatFs, (TCHAR const*)SD_Path, 0) != FR_OK)) { ... }
else
{
LCD_DbgLog ("INFO : FatFs Initialized! \n");
}else { ... }
}if (FATFS_LinkDriver(&SD_Driver, SD_Path) == 0) { ... }
}if (BSP_SD_IsDetected() == SD_PRESENT) { ... }
else
{
LCD_ErrLog("SD card NOT plugged \n");
return 1;
}else { ... }
return 0;
}{ ... }
/* ... */
FRESULT SD_StorageParse(void)
{
FRESULT res;
FILINFO fno;
DIR dir;
char *fn;
res = f_opendir(&dir, SD_Path);
FileList.ptr = 0;
if(res == FR_OK)
{
while (1)
{
res = f_readdir(&dir, &fno);
if(res != FR_OK || fno.fname[0] == 0)
{
break;
}if (res != FR_OK || fno.fname[0] == 0) { ... }
if(fno.fname[0] == '.')
{
continue;
}if (fno.fname[0] == '.') { ... }
fn = fno.fname;
if(FileList.ptr < FILEMGR_LIST_DEPDTH)
{
if((fno.fattrib & AM_DIR) == 0)
{
strncpy((char *)FileList.file[FileList.ptr].name, (char *)fn, FILEMGR_FILE_NAME_SIZE);
FileList.file[FileList.ptr].type = FILETYPE_FILE;
FileList.ptr++;
}if ((fno.fattrib & AM_DIR) == 0) { ... }
}if (FileList.ptr < FILEMGR_LIST_DEPDTH) { ... }
}while (1) { ... }
}if (res == FR_OK) { ... }
f_closedir(&dir);
return res;
}{ ... }