Select one of the symbols to view example projects that use it.
 
Outline
Includes
#include "main.h"
Private variables
SD_FatFs
SD_Path
FileList
SD_StorageInit()
SD_StorageParse()
Files
loading...
CodeScopeSTM32 Libraries and SamplesCDC_StandaloneSrc/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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/** ****************************************************************************** * @file USB_Host/CDC_Standalone/Src/explorer.c * @author MCD Application Team * @brief This file provides uSD Card 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 define ------------------------------------------------------------ */ /* Private typedef ----------------------------------------------------------- */ /* Private macro ------------------------------------------------------------- */ /* Private variables --------------------------------------------------------- */ FATFS SD_FatFs; char SD_Path[4]; FILELIST_FileTypeDef FileList; Private variables /* Private function prototypes ----------------------------------------------- */ /* Private functions --------------------------------------------------------- */ /** * @brief Initializes the SD Storage. * @param None * @retval Status *//* ... */ uint8_t SD_StorageInit(void) { /* Initializes the SD card device */ BSP_SD_Init(); /* Check if the SD card is plugged in the slot */ if (BSP_SD_IsDetected() == SD_PRESENT) { /* Link the SD Card disk I/O driver */ if (FATFS_LinkDriver(&SD_Driver, SD_Path) == 0) { if ((f_mount(&SD_FatFs, (TCHAR const *)SD_Path, 0) != FR_OK)) { /* FatFs Initialization Error */ 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; }{ ... } /** * @brief Copies disk content in the explorer list. * @param None * @retval Operation result *//* ... */ 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; }{ ... }