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
35
36
39
40
43
44
48
49
50
51
52
53
54
55
56
59
60
63
64
72
73
74
75
76
80
81
82
83
84
90
91
92
93
101
102
103
104
105
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
144
145
148
149
152
153
156
159
160
163
164
165
166
169
170
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
238
239
240
241
242
243
244
245
248
249
252
253
256
257
260
/* ... */
#ifndef __USBH_MTP_H
#define __USBH_MTP_H
#ifdef __cplusplus
extern "C" {
#endif
#include "usbh_mtp_ptp.h"
#include "usbh_core.h"
/* ... */
/* ... */
/* ... */
/* ... */
#define USB_MTP_CLASS 0x06U
#define MTP_MAX_STORAGE_UNITS_NBR PTP_MAX_STORAGE_UNITS_NBR
/* ... */
/* ... */
typedef enum
{
MTP_IDLE = 0,
MTP_GETDEVICEINFO,
MTP_OPENSESSION,
MTP_CLOSESESSION,
MTP_GETSTORAGEIDS,
MTP_GETSTORAGEINFO,
...}
MTP_StateTypeDef;
typedef enum
{
MTP_EVENTS_INIT = 0,
MTP_EVENTS_GETDATA,
...}
MTP_EventsStateTypeDef;
typedef struct
{
MTP_EventsStateTypeDef state;
uint32_t timer;
uint16_t poll;
PTP_EventContainerTypedef container;
...}
MTP_EventHandleTypedef;
typedef struct
{
uint32_t CurrentStorageId;
uint32_t ObjectFormatCode;
uint32_t CurrentObjectHandler;
uint8_t ObjectHandlerNbr;
uint32_t Objdepth;
...}
MTP_ParamsTypedef;
typedef struct
{
PTP_DeviceInfoTypedef devinfo;
PTP_StorageIDsTypedef storids;
PTP_StorageInfoTypedef storinfo[MTP_MAX_STORAGE_UNITS_NBR];
PTP_ObjectHandlesTypedef Handles;
...}
MTP_InfoTypedef;
typedef struct _MTP_Process
{
MTP_InfoTypedef info;
MTP_ParamsTypedef params;
uint8_t DataInPipe;
uint8_t DataOutPipe;
uint8_t NotificationPipe;
uint8_t DataOutEp;
uint8_t DataInEp;
uint8_t NotificationEp;
uint16_t DataOutEpSize;
uint16_t DataInEpSize;
uint16_t NotificationEpSize;
MTP_StateTypeDef state;
MTP_EventHandleTypedef events;
PTP_HandleTypeDef ptp;
uint32_t current_storage_unit;
uint32_t is_ready;
...}
MTP_HandleTypeDef;
#define MTP_StorageInfoTypedef PTP_StorageInfoTypedef
#define MTP_ObjectHandlesTypedef PTP_ObjectHandlesTypedef
#define MTP_ObjectInfoTypedef PTP_ObjectInfoTypedef
/* ... */
/* ... */
/* ... */
/* ... */
/* ... */
/* ... */
extern USBH_ClassTypeDef MTP_Class;
#define USBH_MTP_CLASS &MTP_Class
/* ... */
/* ... */
uint8_t USBH_MTP_IsReady(USBH_HandleTypeDef *phost);
USBH_StatusTypeDef USBH_MTP_SelectStorage(USBH_HandleTypeDef *phost, uint8_t storage_idx);
USBH_StatusTypeDef USBH_MTP_GetNumStorage(USBH_HandleTypeDef *phost, uint8_t *storage_num);
USBH_StatusTypeDef USBH_MTP_GetNumObjects(USBH_HandleTypeDef *phost,
uint32_t storage_idx,
uint32_t objectformatcode,
uint32_t associationOH,
uint32_t *numobs);
USBH_StatusTypeDef USBH_MTP_GetStorageInfo(USBH_HandleTypeDef *phost,
uint8_t storage_idx,
MTP_StorageInfoTypedef *info);
USBH_StatusTypeDef USBH_MTP_GetObjectHandles(USBH_HandleTypeDef *phost,
uint32_t storage_idx,
uint32_t objectformatcode,
uint32_t associationOH,
PTP_ObjectHandlesTypedef *objecthandles);
USBH_StatusTypeDef USBH_MTP_GetObjectInfo(USBH_HandleTypeDef *phost,
uint32_t handle,
PTP_ObjectInfoTypedef *objectinfo);
USBH_StatusTypeDef USBH_MTP_DeleteObject(USBH_HandleTypeDef *phost,
uint32_t handle,
uint32_t objectformatcode);
USBH_StatusTypeDef USBH_MTP_GetObject(USBH_HandleTypeDef *phost,
uint32_t handle,
uint8_t *object);
USBH_StatusTypeDef USBH_MTP_GetPartialObject(USBH_HandleTypeDef *phost,
uint32_t handle,
uint32_t offset,
uint32_t maxbytes,
uint8_t *object,
uint32_t *len);
USBH_StatusTypeDef USBH_MTP_GetObjectPropsSupported(USBH_HandleTypeDef *phost,
uint16_t ofc,
uint32_t *propnum,
uint16_t *props);
USBH_StatusTypeDef USBH_MTP_GetObjectPropDesc(USBH_HandleTypeDef *phost,
uint16_t opc,
uint16_t ofc,
PTP_ObjectPropDescTypeDef *opd);
USBH_StatusTypeDef USBH_MTP_GetObjectPropList(USBH_HandleTypeDef *phost,
uint32_t handle,
MTP_PropertiesTypedef *pprops,
uint32_t *nrofprops);
USBH_StatusTypeDef USBH_MTP_SendObject(USBH_HandleTypeDef *phost,
uint32_t handle,
uint8_t *object,
uint32_t size);
USBH_StatusTypeDef USBH_MTP_GetDevicePropDesc(USBH_HandleTypeDef *phost,
uint16_t propcode,
PTP_DevicePropDescTypdef *devicepropertydesc);
void USBH_MTP_EventsCallback(USBH_HandleTypeDef *phost, uint32_t event, uint32_t param);
/* ... */
#ifdef __cplusplus
}extern "C" { ... }
#endif
/* ... */
#endif
/* ... */
/* ... */
/* ... */
/* ... */