Select one of the symbols to view example projects that use it.
 
Outline
Includes
#include "main.h"
Private variables
WavHandles
NumObs
Private function prototypes
MTP_Init()
MTP_ExploreWavFile()
MTP_GetData(uint32_t, uint32_t, uint32_t, uint8_t *, uint32_t *)
MTP_GetWavObjectNumber()
MTP_GetWavObjectName(uint16_t, uint8_t *)
MTP_GetWavObjectHandles()
Files
loading...
CodeScopeSTM32 Libraries and SamplesMTP_StandaloneSrc/mtp.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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/** ****************************************************************************** * @file USB_Host/MTP_Standalone/Src/mtp.c * @author MCD Application Team * @brief This file provides APIs to explore MTP Storage Objects ****************************************************************************** * @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 macro ------------------------------------------------------------- */ /* Private typedef ----------------------------------------------------------- */ /* Private variables --------------------------------------------------------- */ MTP_ObjectHandlesTypedef WavHandles; uint32_t NumObs = 0; Private variables /* Private function prototypes ----------------------------------------------- */ static uint8_t MTP_GetWavObjectHandles(void); Private function prototypes /* Private functions --------------------------------------------------------- */ /** * @brief AUDIO_Start * Start Audio streaming * @param None * @retval None *//* ... */ uint8_t MTP_Init(void) { static uint8_t is_initialized = 0; uint8_t ret = 1; if (is_initialized == 0) { if (USBH_MTP_IsReady(&hUSBHost) > 0) { if (USBH_MTP_GetNumObjects (&hUSBHost, 0, PTP_OFC_WAV, 0xFFFFFFFF, &NumObs) == USBH_OK) { /* Get objects handlers */ if (MTP_GetWavObjectHandles() == 0) { is_initialized = 1; ret = 0; }if (MTP_GetWavObjectHandles() == 0) { ... } }if (USBH_MTP_GetNumObjects (&hUSBHost, 0, PTP_OFC_WAV, 0xFFFFFFFF, &NumObs) == USBH_OK) { ... } }if (USBH_MTP_IsReady(&hUSBHost) > 0) { ... } }if (is_initialized == 0) { ... } else { ret = 0; }else { ... } return ret; }{ ... } /** * @brief Explores Wav Files. * @param None * @retval Returns 0 if OK, otherwise 1. *//* ... */ uint8_t MTP_ExploreWavFile(void) { uint8_t ret = 1; uint32_t index; MTP_ObjectInfoTypedef objectinfo; MTP_Init(); if (USBH_MTP_IsReady(&hUSBHost) > 0) { LCD_UsrLog("\nAvailable wav files:\n"); /* Get Available WAV files number */ if ((NumObs = MTP_GetWavObjectNumber()) > 0) { /* Get objects handlers */ if (MTP_GetWavObjectHandles() == 0) { ret = 0; for (index = 0; index < NumObs; index++) { if (USBH_MTP_GetObjectInfo(&hUSBHost, WavHandles.Handler[index], &objectinfo) == USBH_OK) { LCD_DbgLog(" %lu- %s\n", index, objectinfo.Filename); }if (USBH_MTP_GetObjectInfo(&hUSBHost, WavHandles.Handler[index], &objectinfo) == USBH_OK) { ... } else { ret = 1; }else { ... } }for (index = 0; index < NumObs; index++) { ... } }if (MTP_GetWavObjectHandles() == 0) { ... } }if ((NumObs = MTP_GetWavObjectNumber()) > 0) { ... } }if (USBH_MTP_IsReady(&hUSBHost) > 0) { ... } else { LCD_ErrLog("MTP Device Not yet ready...\n"); }else { ... } return ret; }{ ... } /** * @brief Gets Data from MTP Device. * @param file_idx: File index * @param offset: Offset * @param maxbytes: Max bytes * @param object: Pointer to the file object * @param len: Pointer to the file length * @retval Returns Status 0 if OK, otherwise 1. *//* ... */ uint8_t MTP_GetData(uint32_t file_idx, uint32_t offset, uint32_t maxbytes, uint8_t * object, uint32_t * len) { USBH_MTP_GetPartialObject(&hUSBHost, WavHandles.Handler[file_idx], offset, maxbytes, object, len); return 0; }{ ... } /** * @brief Gets Wav Object Number. * @param None * @retval Number of Wav object files *//* ... */ uint16_t MTP_GetWavObjectNumber(void) { return NumObs; }{ ... } /** * @brief Gets Wav Object Names. * @param object_index: Object index * @param filename: Pointer to the file name * @retval Returns Status 0 if OK, otherwise 1. *//* ... */ uint8_t MTP_GetWavObjectName(uint16_t object_index, uint8_t * filename) { uint8_t ret = 1; MTP_ObjectInfoTypedef objectinfo; if (USBH_MTP_GetObjectInfo (&hUSBHost, WavHandles.Handler[object_index], &objectinfo) == USBH_OK) { strcpy((char *)filename, (char *)objectinfo.Filename); ret = 0; }if (USBH_MTP_GetObjectInfo (&hUSBHost, WavHandles.Handler[object_index], &objectinfo) == USBH_OK) { ... } return ret; }{ ... } /** * @brief Gets Wav Object Handles. * @param None * @retval Returns Status 0 if OK, otherwise 1. *//* ... */ static uint8_t MTP_GetWavObjectHandles(void) { /* Get objects handlers */ if (USBH_MTP_GetObjectHandles (&hUSBHost, 0, PTP_OFC_WAV, 0xFFFFFFFF, &WavHandles) == USBH_OK) { return 0; }if (USBH_MTP_GetObjectHandles (&hUSBHost, 0, PTP_OFC_WAV, 0xFFFFFFFF, &WavHandles) == USBH_OK) { ... } return 1; }{ ... }