Select one of the symbols to view example projects that use it.
 
Outline
Includes
#include "main.h"
Private typedef
USBKey_Path
FileList
NumObs
AUDIO_StorageInit()
AUDIO_StorageParse()
AUDIO_ShowWavFiles()
AUDIO_GetWavObjectNumber()
Files
loading...
CodeScopeSTM32 Libraries and SamplesAudio_playback_and_recordSrc/explorer.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/** ****************************************************************************** * @file Audio/Audio_playback_and_record/Src/explorer.c * @author MCD Application Team * @brief This file provides USB Key drive configuration ****************************************************************************** * @attention * * Copyright (c) 2017 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** *//* ... */ /* Includes ------------------------------------------------------------------*/ #include "main.h" Includes /* Private typedef -----------------------------------------------------------*/ extern FATFS USBH_FatFs; char USBKey_Path[4] = "0:/"; FILELIST_FileTypeDef FileList; uint16_t NumObs = 0; Private typedef /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /** * @brief Initializes the USB KEY Storage. * @param None * @retval Status *//* ... */ uint8_t AUDIO_StorageInit(void) { /* Link the USB Key disk I/O driver */ if(( f_mount(&USBH_FatFs, (TCHAR const*)USBKey_Path, 0) != FR_OK)) { /* FatFs Initialization Error */ 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 { ... } }{ ... } /** * @brief Copies disk content in the explorer list. * @param None * @retval Operation result *//* ... */ 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; }{ ... } /** * @brief Shows audio file (*.wav) on the root * @param None * @retval None *//* ... */ 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"); /* KEY Button in polling */ while(BSP_PB_GetState(BUTTON_KEY) != RESET) { /* Wait for User Input */ }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 { ... } }{ ... } /** * @brief Gets Wav Object Number. * @param None * @retval None *//* ... */ uint16_t AUDIO_GetWavObjectNumber(void) { return NumObs; }{ ... }