Select one of the symbols to view example projects that use it.
 
Outline
Includes
#include "app_filex.h"
Private includes
#include "ux_api.h"
Private typedef
Private define
Private macro
Private variables
Read_buffer
Write_buffer
Private function prototypes
MX_FileX_Init(void *)
App_File_Write(FX_MEDIA *)
App_File_Read(FX_MEDIA *)
App_File_Create(FX_MEDIA *)
Files
loading...
CodeScopeSTM32 Libraries and SamplesUx_Host_MSCFileX/App/app_filex.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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/* USER CODE BEGIN Header */ /** ****************************************************************************** * @file app_filex.c * @author MCD Application Team * @brief FileX applicative file ****************************************************************************** * @attention * * Copyright (c) 2021 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. * ****************************************************************************** *//* ... */ /* USER CODE END Header */ /* Includes ------------------------------------------------------------------*/ #include "app_filex.h" Includes /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ #include "ux_api.h" /* USER CODE END Includes */ Private includes /* Private typedef -----------------------------------------------------------*/ /* USER CODE BEGIN PTD */ /* USER CODE END PTD */ Private typedef /* Private define ------------------------------------------------------------*/ /* USER CODE BEGIN PD */ /* USER CODE END PD */ Private define /* Private macro -------------------------------------------------------------*/ /* USER CODE BEGIN PM */ /* USER CODE END PM */ Private macro /* Private variables ---------------------------------------------------------*/ /* USER CODE BEGIN PV */ UCHAR Read_buffer[100]; UCHAR Write_buffer[] = "USBX_STM32_Host_Mass_Storage"; /* USER CODE END PV */ Private variables /* Private function prototypes -----------------------------------------------*/ /* USER CODE BEGIN PFP */ /* USER CODE END PFP */ /** * @brief Application FileX Initialization. * @param memory_ptr: memory pointer * @retval int *//* ... */ UINT MX_FileX_Init(VOID *memory_ptr) { UINT ret = FX_SUCCESS; TX_BYTE_POOL *byte_pool = (TX_BYTE_POOL*)memory_ptr; /* USER CODE BEGIN MX_FileX_MEM_POOL */ (void)byte_pool; /* USER CODE END MX_FileX_MEM_POOL */ /* USER CODE BEGIN MX_FileX_Init */ /* Initialize FileX. */ fx_system_initialize(); /* USER CODE END MX_FileX_Init */ return ret; }{ ... } /* USER CODE BEGIN 1 */ /** * @brief Application Write File process. * @param none * @retval UINT status *//* ... */ UINT App_File_Write(FX_MEDIA *fx_media) { FX_FILE my_file; UINT status; /* Open "TEST.TXT" file. */ status = fx_file_open(fx_media, &my_file, "TEST.TXT", FX_OPEN_FOR_WRITE); /* Check the file open status. */ if (status != FX_SUCCESS) { /* Error opening file, break the loop. */ status = FX_IO_ERROR; }if (status != FX_SUCCESS) { ... } /* Seek the start of File*/ fx_file_seek(&my_file, 0); /* Write a string to "TEST.TXT" file. */ status = fx_file_write(&my_file, Write_buffer, sizeof(Write_buffer)); /* Check the file write status. */ if (status != FX_SUCCESS) { /* Error writing to a file. */ status = FX_IO_ERROR; }if (status != FX_SUCCESS) { ... } /* Close File after Finish writing */ status = fx_file_close(&my_file); /* Check the file close status. */ if (status != FX_SUCCESS) { /* Error writing to a file. */ status = FX_IO_ERROR; }if (status != FX_SUCCESS) { ... } /* Flush media. */ status = fx_media_flush(fx_media); /* Check the file close status. */ if (status != FX_SUCCESS) { /* Error writing to a file. */ status = FX_IO_ERROR; }if (status != FX_SUCCESS) { ... } return status ; }{ ... } /** * @brief Application Read File process. * @param none * @retval UINT status *//* ... */ UINT App_File_Read(FX_MEDIA *fx_media) { FX_FILE my_file; ULONG requested_length; UINT file_attribute; UINT status; /* Reset file attributes. */ file_attribute = 0; /* Try to read the file attributes. */ status = fx_file_attributes_read(fx_media, "TEST.TXT", &file_attribute); /* If this is a directory, pass. */ if (!(file_attribute & 0x18) && (status == FX_SUCCESS)) { /* Try to open the file. */ status = fx_file_open(fx_media, &my_file, "TEST.TXT", FX_OPEN_FOR_READ); /* Read the entire file. */ if (status == FX_SUCCESS) { /* Seek start of File */ fx_file_seek(&my_file, 0); /* Read the file in blocks */ status = fx_file_read(&my_file, Read_buffer, sizeof(Read_buffer), &requested_length); /* Check if status OK. */ if (status == FX_SUCCESS) { if (requested_length != sizeof(Write_buffer)) { status = FX_IO_ERROR; }if (requested_length != sizeof(Write_buffer)) { ... } else { /* Compare Written buffer and read buffer.*/ status = (_ux_utility_memory_compare(Write_buffer, Read_buffer, sizeof(Write_buffer))); }else { ... } }if (status == FX_SUCCESS) { ... } else { /* Read operation error */ status = FX_IO_ERROR; }else { ... } /* Closing File after reading it. */ fx_file_close(&my_file); }if (status == FX_SUCCESS) { ... } }if (!(file_attribute & 0x18) && (status == FX_SUCCESS)) { ... } return status; }{ ... } /** * @brief Application Create File process. * @param none * @retval UINT status *//* ... */ UINT App_File_Create( FX_MEDIA *fx_media) { UINT status; /* Create a file called TEST.TXT in the root directory. */ status = fx_file_create(fx_media, "TEST.TXT"); /* Check the create status. */ if ((status == FX_SUCCESS) || (status == FX_ALREADY_CREATED)) { /* File Creation success. */ status = FX_SUCCESS; }if ((status == FX_SUCCESS) || (status == FX_ALREADY_CREATED)) { ... } else { /* File Creation Fail. */ status = FX_INVALID_STATE; }else { ... } return status; }{ ... } Private function prototypes/* USER CODE END 1 */