1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
21
27
28
29
30
31
32
33
38
53
54
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
79
83
84
85
86
98
99
100
101
102
103
104
105
106
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
137
138
139
140
141
142
143
144
145
146
147
148
149
150
154
155
156
161
/* ... */
#include "main.h"
Includes
extern FATFS USBH_FatFs;
char USBKey_Path[4] = "0:/";
FILELIST_FileTypeDef FileList;
uint16_t NumObs = 0;
Private typedef
/* ... */
uint8_t AUDIO_StorageInit(void)
{
if(( f_mount(&USBH_FatFs, (TCHAR const*)USBKey_Path, 0) != FR_OK))
{
LCD_ErrLog("Cannot Initialize FatFs! \n");
return 1;
}if (( f_mount(&USBH_FatFs, (TCHAR const*)USBKey_Path, 0) != FR_OK)) { ... }
else
{
LCD_DbgLog ("INFO : FatFs Initialized! \n");
return 0;
}else { ... }
}{ ... }
/* ... */
FRESULT AUDIO_StorageParse(void)
{
FRESULT res = FR_OK;
FILINFO fno;
DIR dir;
char *fn;
res = f_opendir(&dir, USBKey_Path);
FileList.ptr = 0;
if(res == FR_OK)
{
while(USBH_MSC_IsReady(&hUSBHost))
{
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)
{
if((strstr(fn, "wav")) || (strstr(fn, "WAV")))
{
strncpy((char *)FileList.file[FileList.ptr].name, (char *)fn, FILEMGR_FILE_NAME_SIZE);
FileList.file[FileList.ptr].type = FILETYPE_FILE;
FileList.ptr++;
}if ((strstr(fn, "wav")) || (strstr(fn, "WAV"))) { ... }
}if ((fno.fattrib & AM_DIR) == 0) { ... }
}if (FileList.ptr < FILEMGR_LIST_DEPDTH) { ... }
}while (USBH_MSC_IsReady(&hUSBHost)) { ... }
}if (res == FR_OK) { ... }
NumObs = FileList.ptr;
f_closedir(&dir);
return res;
}{ ... }
/* ... */
uint8_t AUDIO_ShowWavFiles(void)
{
uint8_t i = 0;
uint8_t line_idx = 0;
if(AUDIO_StorageInit() == FR_OK)
{
if(AUDIO_StorageParse() == FR_OK)
{
if(FileList.ptr > 0)
{
BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
LCD_UsrLog("audio file(s) [ROOT]:\n\n");
for(i = 0; i < FileList.ptr; i++)
{
line_idx++;
if(line_idx > 9)
{
line_idx = 0;
LCD_UsrLog("> Press [Key] To Continue.\n");
while(BSP_PB_GetState(BUTTON_KEY) != RESET)
{
}while (BSP_PB_GetState(BUTTON_KEY) != RESET) { ... }
}if (line_idx > 9) { ... }
LCD_DbgLog(" |__");
LCD_DbgLog((char *)FileList.file[i].name);
LCD_DbgLog("\n");
}for (i = 0; i < FileList.ptr; i++) { ... }
BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
LCD_UsrLog("\nEnd of files list.\n");
return 0;
}if (FileList.ptr > 0) { ... }
return 1;
}if (AUDIO_StorageParse() == FR_OK) { ... }
return 2;
}if (AUDIO_StorageInit() == FR_OK) { ... }
else
{
return 3;
}else { ... }
}{ ... }
/* ... */
uint16_t AUDIO_GetWavObjectNumber(void)
{
return NumObs;
}{ ... }