aboutsummaryrefslogtreecommitdiff
path: root/stmhal/usbhost/Class/MTP/Inc/usbh_mtp.h
blob: 704a410fdf31c005fb73d0c92a32fa634bd545cd (plain)
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
/**
  ******************************************************************************
  * @file    usbh_mtp.h
  * @author  MCD Application Team
  * @version V3.0.0
  * @date    18-February-2014
  * @brief   This file contains all the prototypes for the usbh_mtp.c
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
  *
  * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  * You may not use this file except in compliance with the License.
  * You may obtain a copy of the License at:
  *
  *        http://www.st.com/software_license_agreement_liberty_v2
  *
  * Unless required by applicable law or agreed to in writing, software 
  * distributed under the License is distributed on an "AS IS" BASIS, 
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  *
  ******************************************************************************
  */ 

/* Define to prevent recursive  ----------------------------------------------*/
#ifndef __USBH_MTP_CORE_H
#define __USBH_MTP_CORE_H

/* Includes ------------------------------------------------------------------*/
#include "usbh_mtp_ptp.h"
#include "usbh_core.h"


/** @addtogroup USBH_LIB
* @{
*/

/** @addtogroup USBH_CLASS
* @{
*/

/** @addtogroup USBH_MTP_CLASS
* @{
*/

/** @defgroup USBH_MTP_CORE
* @brief This file is the Header file for USBH_MTP_CORE.c
* @{
*/ 




/*Communication Class codes*/
#define USB_MTP_CLASS                                           0x06 /* Still Image Class)*/
#define MTP_MAX_STORAGE_UNITS_NBR                               PTP_MAX_STORAGE_UNITS_NBR

/**
  * @}
  */ 

/** @defgroup USBH_MTP_CORE_Exported_Types
* @{
*/ 
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;

/* Structure for MTP process */
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
/**
* @}
*/ 

/** @defgroup USBH_MTP_CORE_Exported_Defines
* @{
*/ 

/**
* @}
*/ 

/** @defgroup USBH_MTP_CORE_Exported_Macros
* @{
*/ 
/**
* @}
*/ 

/** @defgroup USBH_MTP_CORE_Exported_Variables
* @{
*/ 
extern USBH_ClassTypeDef  MTP_Class;
#define USBH_MTP_CLASS    &MTP_Class

/**
* @}
*/ 

/** @defgroup USBH_MTP_CORE_Exported_FunctionsPrototype
* @{
*/ 
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_id, 
                                           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_id, 
                                           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);
/**
* @}
*/ 


#endif /* __USBH_MTP_CORE_H */

/**
* @}
*/ 

/**
* @}
*/ 

/**
* @}
*/ 

/**
* @}
*/ 
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/