1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
21
22
23
24
28
31
32
33
39
66
67
72
73
74
75
76
77
78
79
80
109
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
134
135
140
144
145
151
152
153
154
155
156
162
163
164
165
166
171
/* ... */
#include "main.h"
Includes
MTP_ObjectHandlesTypedef WavHandles;
uint32_t NumObs = 0;
Private variables
static uint8_t MTP_GetWavObjectHandles(void);
Private function prototypes
/* ... */
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)
{
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;
}{ ... }
/* ... */
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");
if ((NumObs = MTP_GetWavObjectNumber()) > 0)
{
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;
}{ ... }
/* ... */
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;
}{ ... }
/* ... */
uint16_t MTP_GetWavObjectNumber(void)
{
return NumObs;
}{ ... }
/* ... */
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;
}{ ... }
/* ... */
static uint8_t MTP_GetWavObjectHandles(void)
{
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;
}{ ... }