| 1 |
/** |
| 2 |
****************************************************************************** |
| 3 |
* @file usbh_mtp.c |
| 4 |
* @author MCD Application Team |
| 5 |
* @version V3.0.0 |
| 6 |
* @date 18-February-2014 |
| 7 |
* @brief This file is the MTP Layer Handlers for USB Host MTP class. |
| 8 |
* |
| 9 |
* @verbatim |
| 10 |
* |
| 11 |
* =================================================================== |
| 12 |
* MTP Class Description |
| 13 |
* =================================================================== |
| 14 |
* This module manages the MSC class V1.11 following the "Device Class Definition |
| 15 |
* for Human Interface Devices (MTP) Version 1.11 Jun 27, 2001". |
| 16 |
* This driver implements the following aspects of the specification: |
| 17 |
* - The Boot Interface Subclass |
| 18 |
* - The Mouse and Keyboard protocols |
| 19 |
* |
| 20 |
* @endverbatim |
| 21 |
* |
| 22 |
****************************************************************************** |
| 23 |
* @attention |
| 24 |
* |
| 25 |
* <h2><center>© COPYRIGHT 2014 STMicroelectronics</center></h2> |
| 26 |
* |
| 27 |
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); |
| 28 |
* You may not use this file except in compliance with the License. |
| 29 |
* You may obtain a copy of the License at: |
| 30 |
* |
| 31 |
* http://www.st.com/software_license_agreement_liberty_v2 |
| 32 |
* |
| 33 |
* Unless required by applicable law or agreed to in writing, software |
| 34 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 35 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 36 |
* See the License for the specific language governing permissions and |
| 37 |
* limitations under the License. |
| 38 |
* |
| 39 |
****************************************************************************** |
| 40 |
*/ |
| 41 |
|
| 42 |
/* Includes ------------------------------------------------------------------*/ |
| 43 |
#include "usbh_mtp.h" |
| 44 |
|
| 45 |
/** @addtogroup USBH_LIB |
| 46 |
* @{ |
| 47 |
*/ |
| 48 |
|
| 49 |
/** @addtogroup USBH_CLASS |
| 50 |
* @{ |
| 51 |
*/ |
| 52 |
|
| 53 |
/** @addtogroup USBH_MTP_CLASS |
| 54 |
* @{ |
| 55 |
*/ |
| 56 |
|
| 57 |
/** @defgroup USBH_MTP_CORE |
| 58 |
* @brief This file includes MTP Layer Handlers for USB Host MTP class. |
| 59 |
* @{ |
| 60 |
*/ |
| 61 |
|
| 62 |
/** @defgroup USBH_MTP_CORE_Private_TypesDefinitions |
| 63 |
* @{ |
| 64 |
*/ |
| 65 |
/** |
| 66 |
* @} |
| 67 |
*/ |
| 68 |
|
| 69 |
|
| 70 |
/** @defgroup USBH_MTP_CORE_Private_Defines |
| 71 |
* @{ |
| 72 |
*/ |
| 73 |
/** |
| 74 |
* @} |
| 75 |
*/ |
| 76 |
|
| 77 |
|
| 78 |
/** @defgroup USBH_MTP_CORE_Private_Macros |
| 79 |
* @{ |
| 80 |
*/ |
| 81 |
/** |
| 82 |
* @} |
| 83 |
*/ |
| 84 |
|
| 85 |
|
| 86 |
/** @defgroup USBH_MTP_CORE_Private_Variables |
| 87 |
* @{ |
| 88 |
*/ |
| 89 |
/** |
| 90 |
* @} |
| 91 |
*/ |
| 92 |
|
| 93 |
|
| 94 |
/** @defgroup USBH_MTP_CORE_Private_FunctionPrototypes |
| 95 |
* @{ |
| 96 |
*/ |
| 97 |
|
| 98 |
static USBH_StatusTypeDef USBH_MTP_InterfaceInit (USBH_HandleTypeDef *phost); |
| 99 |
|
| 100 |
static USBH_StatusTypeDef USBH_MTP_InterfaceDeInit (USBH_HandleTypeDef *phost); |
| 101 |
|
| 102 |
static USBH_StatusTypeDef USBH_MTP_Process(USBH_HandleTypeDef *phost); |
| 103 |
|
| 104 |
static USBH_StatusTypeDef USBH_MTP_ClassRequest (USBH_HandleTypeDef *phost); |
| 105 |
|
| 106 |
static uint8_t MTP_FindCtlEndpoint(USBH_HandleTypeDef *phost); |
| 107 |
|
| 108 |
static uint8_t MTP_FindDataOutEndpoint(USBH_HandleTypeDef *phost); |
| 109 |
|
| 110 |
static uint8_t MTP_FindDataInEndpoint(USBH_HandleTypeDef *phost); |
| 111 |
|
| 112 |
static USBH_StatusTypeDef USBH_MTP_SOFProcess (USBH_HandleTypeDef *phost); |
| 113 |
|
| 114 |
static USBH_StatusTypeDef USBH_MTP_Events (USBH_HandleTypeDef *phost); |
| 115 |
|
| 116 |
static void MTP_DecodeEvent (USBH_HandleTypeDef *phost) ; |
| 117 |
|
| 118 |
USBH_ClassTypeDef MTP_Class = |
| 119 |
{ |
| 120 |
"MTP", |
| 121 |
USB_MTP_CLASS, |
| 122 |
USBH_MTP_InterfaceInit, |
| 123 |
USBH_MTP_InterfaceDeInit, |
| 124 |
USBH_MTP_ClassRequest, |
| 125 |
USBH_MTP_Process, |
| 126 |
USBH_MTP_SOFProcess, |
| 127 |
NULL, |
| 128 |
}; |
| 129 |
/** |
| 130 |
* @} |
| 131 |
*/ |
| 132 |
|
| 133 |
|
| 134 |
/** @defgroup USBH_MTP_CORE_Private_Functions |
| 135 |
* @{ |
| 136 |
*/ |
| 137 |
|
| 138 |
/** |
| 139 |
* @brief USBH_MTP_InterfaceInit |
| 140 |
* The function init the MTP class. |
| 141 |
* @param phost: Host handle |
| 142 |
* @retval USBH Status |
| 143 |
*/ |
| 144 |
static USBH_StatusTypeDef USBH_MTP_InterfaceInit (USBH_HandleTypeDef *phost) |
| 145 |
{ |
| 146 |
USBH_StatusTypeDef status = USBH_OK ; |
| 147 |
uint8_t interface, endpoint; |
| 148 |
|
| 149 |
MTP_HandleTypeDef *MTP_Handle; |
| 150 |
|
| 151 |
interface = USBH_FindInterface(phost, |
| 152 |
USB_MTP_CLASS, |
| 153 |
1, |
| 154 |
1); |
| 155 |
|
| 156 |
if(interface == 0xFF) /* No Valid Interface */ |
| 157 |
{ |
| 158 |
status = USBH_FAIL; |
| 159 |
USBH_DbgLog ("Cannot Find the interface for Still Image Class."); |
| 160 |
} |
| 161 |
else |
| 162 |
{ |
| 163 |
USBH_SelectInterface (phost, interface); |
| 164 |
|
| 165 |
endpoint = MTP_FindCtlEndpoint(phost); |
| 166 |
|
| 167 |
phost->pActiveClass->pData = (MTP_HandleTypeDef *)USBH_malloc (sizeof(MTP_HandleTypeDef)); |
| 168 |
MTP_Handle = phost->pActiveClass->pData; |
| 169 |
|
| 170 |
if( MTP_Handle == NULL) |
| 171 |
{ |
| 172 |
status = USBH_FAIL; |
| 173 |
USBH_DbgLog ("Cannot allocate RAM for MTP Handle"); |
| 174 |
} |
| 175 |
|
| 176 |
/*Collect the control endpoint address and length*/ |
| 177 |
MTP_Handle->NotificationEp = phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[endpoint].bEndpointAddress; |
| 178 |
MTP_Handle->NotificationEpSize = phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[endpoint].wMaxPacketSize; |
| 179 |
MTP_Handle->NotificationPipe = USBH_AllocPipe(phost, MTP_Handle->NotificationEp); |
| 180 |
MTP_Handle->events.poll = phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[endpoint].bInterval; |
| 181 |
|
| 182 |
/* Open pipe for Notification endpoint */ |
| 183 |
USBH_OpenPipe (phost, |
| 184 |
MTP_Handle->NotificationPipe, |
| 185 |
MTP_Handle->NotificationEp, |
| 186 |
phost->device.address, |
| 187 |
phost->device.speed, |
| 188 |
USB_EP_TYPE_INTR, |
| 189 |
MTP_Handle->NotificationEpSize); |
| 190 |
|
| 191 |
USBH_LL_SetToggle (phost, MTP_Handle->NotificationPipe, 0); |
| 192 |
|
| 193 |
|
| 194 |
endpoint = MTP_FindDataInEndpoint(phost); |
| 195 |
|
| 196 |
/*Collect the control endpoint address and length*/ |
| 197 |
MTP_Handle->DataInEp = phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[endpoint].bEndpointAddress; |
| 198 |
MTP_Handle->DataInEpSize = phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[endpoint].wMaxPacketSize; |
| 199 |
MTP_Handle->DataInPipe = USBH_AllocPipe(phost, MTP_Handle->DataInEp); |
| 200 |
|
| 201 |
/* Open pipe for DATA IN endpoint */ |
| 202 |
USBH_OpenPipe (phost, |
| 203 |
MTP_Handle->DataInPipe, |
| 204 |
MTP_Handle->DataInEp, |
| 205 |
phost->device.address, |
| 206 |
phost->device.speed, |
| 207 |
USB_EP_TYPE_BULK, |
| 208 |
MTP_Handle->DataInEpSize); |
| 209 |
|
| 210 |
USBH_LL_SetToggle (phost, MTP_Handle->DataInPipe, 0); |
| 211 |
|
| 212 |
endpoint = MTP_FindDataOutEndpoint(phost); |
| 213 |
|
| 214 |
/*Collect the DATA OUT endpoint address and length*/ |
| 215 |
MTP_Handle->DataOutEp = phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[endpoint].bEndpointAddress; |
| 216 |
MTP_Handle->DataOutEpSize = phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[endpoint].wMaxPacketSize; |
| 217 |
MTP_Handle->DataOutPipe = USBH_AllocPipe(phost, MTP_Handle->DataOutEp); |
| 218 |
|
| 219 |
/* Open pipe for DATA OUT endpoint */ |
| 220 |
USBH_OpenPipe (phost, |
| 221 |
MTP_Handle->DataOutPipe, |
| 222 |
MTP_Handle->DataOutEp, |
| 223 |
phost->device.address, |
| 224 |
phost->device.speed, |
| 225 |
USB_EP_TYPE_BULK, |
| 226 |
MTP_Handle->DataOutEpSize); |
| 227 |
|
| 228 |
USBH_LL_SetToggle (phost, MTP_Handle->DataOutPipe, 0); |
| 229 |
|
| 230 |
|
| 231 |
MTP_Handle->state = MTP_OPENSESSION; |
| 232 |
MTP_Handle->is_ready = 0; |
| 233 |
MTP_Handle->events.state = MTP_EVENTS_INIT; |
| 234 |
return USBH_PTP_Init(phost); |
| 235 |
|
| 236 |
} |
| 237 |
return status; |
| 238 |
} |
| 239 |
|
| 240 |
/** |
| 241 |
* @brief Find MTP Ctl interface |
| 242 |
* @param phost: Host handle |
| 243 |
* @retval USBH Status |
| 244 |
*/ |
| 245 |
static uint8_t MTP_FindCtlEndpoint(USBH_HandleTypeDef *phost) |
| 246 |
{ |
| 247 |
uint8_t interface, endpoint; |
| 248 |
|
| 249 |
for (interface = 0; interface < USBH_MAX_NUM_INTERFACES ; interface ++ ) |
| 250 |
{ |
| 251 |
if(phost->device.CfgDesc.Itf_Desc[interface].bInterfaceClass == USB_MTP_CLASS) |
| 252 |
{ |
| 253 |
for (endpoint = 0; endpoint < USBH_MAX_NUM_ENDPOINTS ; endpoint ++ ) |
| 254 |
{ |
| 255 |
if((phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[endpoint].bEndpointAddress & 0x80)&& |
| 256 |
(phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[endpoint].wMaxPacketSize > 0)&& |
| 257 |
((phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[endpoint].bmAttributes & USBH_EP_INTERRUPT) == USBH_EP_INTERRUPT)) |
| 258 |
{ |
| 259 |
return endpoint; |
| 260 |
} |
| 261 |
} |
| 262 |
} |
| 263 |
} |
| 264 |
|
| 265 |
return 0xFF; /* Invalid Endpoint */ |
| 266 |
} |
| 267 |
|
| 268 |
|
| 269 |
/** |
| 270 |
* @brief Find MTP DATA OUT interface |
| 271 |
* @param phost: Host handle |
| 272 |
* @retval USBH Status |
| 273 |
*/ |
| 274 |
static uint8_t MTP_FindDataOutEndpoint(USBH_HandleTypeDef *phost) |
| 275 |
{ |
| 276 |
uint8_t interface, endpoint; |
| 277 |
|
| 278 |
for (interface = 0; interface < USBH_MAX_NUM_INTERFACES ; interface ++ ) |
| 279 |
{ |
| 280 |
if(phost->device.CfgDesc.Itf_Desc[interface].bInterfaceClass == USB_MTP_CLASS) |
| 281 |
{ |
| 282 |
for (endpoint = 0; endpoint < USBH_MAX_NUM_ENDPOINTS ; endpoint ++ ) |
| 283 |
{ |
| 284 |
|
| 285 |
if(((phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[endpoint].bEndpointAddress & 0x80) == 0)&& |
| 286 |
(phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[endpoint].wMaxPacketSize > 0)&& |
| 287 |
((phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[endpoint].bmAttributes & USBH_EP_BULK) == USBH_EP_BULK)) |
| 288 |
{ |
| 289 |
return endpoint; |
| 290 |
} |
| 291 |
} |
| 292 |
} |
| 293 |
} |
| 294 |
|
| 295 |
return 0xFF; /* Invalid Endpoint */ |
| 296 |
} |
| 297 |
|
| 298 |
/** |
| 299 |
* @brief Find MTP DATA IN interface |
| 300 |
* @param phost: Host handle |
| 301 |
* @retval USBH Status |
| 302 |
*/ |
| 303 |
static uint8_t MTP_FindDataInEndpoint(USBH_HandleTypeDef *phost) |
| 304 |
{ |
| 305 |
uint8_t interface, endpoint; |
| 306 |
|
| 307 |
for (interface = 0; interface < USBH_MAX_NUM_INTERFACES ; interface ++ ) |
| 308 |
{ |
| 309 |
if(phost->device.CfgDesc.Itf_Desc[interface].bInterfaceClass == USB_MTP_CLASS) |
| 310 |
{ |
| 311 |
for (endpoint = 0; endpoint < USBH_MAX_NUM_ENDPOINTS ; endpoint ++ ) |
| 312 |
{ |
| 313 |
|
| 314 |
if((phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[endpoint].bEndpointAddress & 0x80)&& |
| 315 |
(phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[endpoint].wMaxPacketSize > 0)&& |
| 316 |
((phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[endpoint].bmAttributes & USBH_EP_BULK) == USBH_EP_BULK)) |
| 317 |
{ |
| 318 |
return endpoint; |
| 319 |
} |
| 320 |
} |
| 321 |
} |
| 322 |
} |
| 323 |
|
| 324 |
return 0xFF; /* Invalid Endpoint */ |
| 325 |
} |
| 326 |
|
| 327 |
|
| 328 |
/** |
| 329 |
* @brief USBH_MTP_InterfaceDeInit |
| 330 |
* The function DeInit the Pipes used for the MTP class. |
| 331 |
* @param phost: Host handle |
| 332 |
* @retval USBH Status |
| 333 |
*/ |
| 334 |
USBH_StatusTypeDef USBH_MTP_InterfaceDeInit (USBH_HandleTypeDef *phost) |
| 335 |
{ |
| 336 |
MTP_HandleTypeDef *MTP_Handle = phost->pActiveClass->pData; |
| 337 |
|
| 338 |
if (MTP_Handle->DataOutPipe) |
| 339 |
{ |
| 340 |
USBH_ClosePipe(phost, MTP_Handle->DataOutPipe); |
| 341 |
USBH_FreePipe (phost, MTP_Handle->DataOutPipe); |
| 342 |
MTP_Handle->DataOutPipe = 0; /* Reset the Channel as Free */ |
| 343 |
} |
| 344 |
|
| 345 |
if (MTP_Handle->DataInPipe) |
| 346 |
{ |
| 347 |
USBH_ClosePipe(phost, MTP_Handle->DataInPipe); |
| 348 |
USBH_FreePipe (phost, MTP_Handle->DataInPipe); |
| 349 |
MTP_Handle->DataInPipe = 0; /* Reset the Channel as Free */ |
| 350 |
} |
| 351 |
|
| 352 |
if (MTP_Handle->NotificationPipe) |
| 353 |
{ |
| 354 |
USBH_ClosePipe(phost, MTP_Handle->NotificationPipe); |
| 355 |
USBH_FreePipe (phost, MTP_Handle->NotificationPipe); |
| 356 |
MTP_Handle->NotificationPipe = 0; /* Reset the Channel as Free */ |
| 357 |
} |
| 358 |
|
| 359 |
if(phost->pActiveClass->pData) |
| 360 |
{ |
| 361 |
USBH_free (phost->pActiveClass->pData); |
| 362 |
phost->pActiveClass->pData = 0; |
| 363 |
} |
| 364 |
return USBH_OK; |
| 365 |
} |
| 366 |
|
| 367 |
/** |
| 368 |
* @brief USBH_MTP_ClassRequest |
| 369 |
* The function is responsible for handling Standard requests |
| 370 |
* for MTP class. |
| 371 |
* @param phost: Host handle |
| 372 |
* @retval USBH Status |
| 373 |
*/ |
| 374 |
static USBH_StatusTypeDef USBH_MTP_ClassRequest (USBH_HandleTypeDef *phost) |
| 375 |
{ |
| 376 |
return USBH_OK;; |
| 377 |
} |
| 378 |
|
| 379 |
|
| 380 |
/** |
| 381 |
* @brief USBH_MTP_Process |
| 382 |
* The function is for managing state machine for MTP data transfers |
| 383 |
* @param phost: Host handle |
| 384 |
* @retval USBH Status |
| 385 |
*/ |
| 386 |
static USBH_StatusTypeDef USBH_MTP_Process (USBH_HandleTypeDef *phost) |
| 387 |
{ |
| 388 |
USBH_StatusTypeDef status = USBH_BUSY; |
| 389 |
MTP_HandleTypeDef *MTP_Handle = phost->pActiveClass->pData; |
| 390 |
uint32_t idx = 0; |
| 391 |
|
| 392 |
switch(MTP_Handle->state) |
| 393 |
{ |
| 394 |
case MTP_OPENSESSION: |
| 395 |
|
| 396 |
status = USBH_PTP_OpenSession (phost, 1); /* Session '0' is not valid */ |
| 397 |
|
| 398 |
if(status == USBH_OK) |
| 399 |
{ |
| 400 |
USBH_UsrLog("MTP Session #0 Opened"); |
| 401 |
MTP_Handle->state = MTP_GETDEVICEINFO; |
| 402 |
} |
| 403 |
break; |
| 404 |
|
| 405 |
case MTP_GETDEVICEINFO: |
| 406 |
status = USBH_PTP_GetDeviceInfo (phost, &(MTP_Handle->info.devinfo)); |
| 407 |
|
| 408 |
if(status == USBH_OK) |
| 409 |
{ |
| 410 |
USBH_DbgLog(">>>>> MTP Device Information"); |
| 411 |
USBH_DbgLog("Standard version : %x", MTP_Handle->info.devinfo.StandardVersion); |
| 412 |
USBH_DbgLog("Vendor ExtID : %s", (MTP_Handle->info.devinfo.VendorExtensionID == 6)?"MTP": "NOT SUPPORTED"); |
| 413 |
USBH_DbgLog("Functional mode : %s", (MTP_Handle->info.devinfo.FunctionalMode == 0) ? "Standard" : "Vendor"); |
| 414 |
USBH_DbgLog("Number of Supported Operation(s) : %d", MTP_Handle->info.devinfo.OperationsSupported_len); |
| 415 |
USBH_DbgLog("Number of Supported Events(s) : %d", MTP_Handle->info.devinfo.EventsSupported_len); |
| 416 |
USBH_DbgLog("Number of Supported Proprieties : %d", MTP_Handle->info.devinfo.DevicePropertiesSupported_len); |
| 417 |
USBH_DbgLog("Manufacturer : %s", MTP_Handle->info.devinfo.Manufacturer); |
| 418 |
USBH_DbgLog("Model : %s", MTP_Handle->info.devinfo.Model); |
| 419 |
USBH_DbgLog("Device version : %s", MTP_Handle->info.devinfo.DeviceVersion); |
| 420 |
USBH_DbgLog("Serial number : %s", MTP_Handle->info.devinfo.SerialNumber); |
| 421 |
|
| 422 |
MTP_Handle->state = MTP_GETSTORAGEIDS; |
| 423 |
} |
| 424 |
break; |
| 425 |
|
| 426 |
case MTP_GETSTORAGEIDS: |
| 427 |
status = USBH_PTP_GetStorageIds (phost, &(MTP_Handle->info.storids)); |
| 428 |
|
| 429 |
if(status == USBH_OK) |
| 430 |
{ |
| 431 |
USBH_DbgLog("Number of storage ID items : %d", MTP_Handle->info.storids.n); |
| 432 |
for (idx = 0; idx < MTP_Handle->info.storids.n; idx ++) |
| 433 |
{ |
| 434 |
USBH_DbgLog("storage#%d ID : %x", idx, MTP_Handle->info.storids.Storage[idx]); |
| 435 |
} |
| 436 |
|
| 437 |
MTP_Handle->current_storage_unit = 0; |
| 438 |
MTP_Handle->state = MTP_GETSTORAGEINFO; |
| 439 |
} |
| 440 |
break; |
| 441 |
|
| 442 |
case MTP_GETSTORAGEINFO: |
| 443 |
status = USBH_PTP_GetStorageInfo (phost, |
| 444 |
MTP_Handle->info.storids.Storage[MTP_Handle->current_storage_unit], |
| 445 |
&((MTP_Handle->info.storinfo)[MTP_Handle->current_storage_unit])); |
| 446 |
|
| 447 |
if(status == USBH_OK) |
| 448 |
{ |
| 449 |
USBH_UsrLog("Volume#%lu: %s [%s]", MTP_Handle->current_storage_unit, |
| 450 |
MTP_Handle->info.storinfo[MTP_Handle->current_storage_unit].StorageDescription, |
| 451 |
MTP_Handle->info.storinfo[MTP_Handle->current_storage_unit].VolumeLabel); |
| 452 |
if(++MTP_Handle->current_storage_unit >= MTP_Handle->info.storids.n) |
| 453 |
{ |
| 454 |
MTP_Handle->state = MTP_IDLE; |
| 455 |
MTP_Handle->is_ready = 1; |
| 456 |
MTP_Handle->current_storage_unit = 0; |
| 457 |
MTP_Handle->params.CurrentStorageId = MTP_Handle->info.storids.Storage[0]; |
| 458 |
|
| 459 |
USBH_UsrLog( "MTP Class initialized."); |
| 460 |
USBH_UsrLog("%s is default storage unit", MTP_Handle->info.storinfo[0].StorageDescription); |
| 461 |
phost->pUser(phost, HOST_USER_CLASS_ACTIVE); |
| 462 |
} |
| 463 |
} |
| 464 |
break; |
| 465 |
|
| 466 |
case MTP_IDLE: |
| 467 |
USBH_MTP_Events(phost); |
| 468 |
default: |
| 469 |
status = USBH_OK; |
| 470 |
break; |
| 471 |
} |
| 472 |
return status; |
| 473 |
} |
| 474 |
|
| 475 |
/** |
| 476 |
* @brief USBH_MTP_SOFProcess |
| 477 |
* The function is for managing SOF callback |
| 478 |
* @param phost: Host handle |
| 479 |
* @retval USBH Status |
| 480 |
*/ |
| 481 |
static USBH_StatusTypeDef USBH_MTP_SOFProcess (USBH_HandleTypeDef *phost) |
| 482 |
{ |
| 483 |
USBH_StatusTypeDef status = USBH_OK; |
| 484 |
|
| 485 |
return status; |
| 486 |
} |
| 487 |
|
| 488 |
/** |
| 489 |
* @brief USBH_MTP_IsReady |
| 490 |
* Select the storage Unit to be used |
| 491 |
* @param phost: Host handle |
| 492 |
* @retval USBH Status |
| 493 |
*/ |
| 494 |
uint8_t USBH_MTP_IsReady (USBH_HandleTypeDef *phost) |
| 495 |
{ |
| 496 |
MTP_HandleTypeDef *MTP_Handle = phost->pActiveClass->pData; |
| 497 |
|
| 498 |
return (MTP_Handle->is_ready); |
| 499 |
} |
| 500 |
|
| 501 |
/** |
| 502 |
* @brief USBH_MTP_GetNumStorage |
| 503 |
* Select the storage Unit to be used |
| 504 |
* @param phost: Host handle |
| 505 |
* @retval USBH Status |
| 506 |
*/ |
| 507 |
USBH_StatusTypeDef USBH_MTP_GetNumStorage (USBH_HandleTypeDef *phost, uint8_t *storage_num) |
| 508 |
{ |
| 509 |
USBH_StatusTypeDef status = USBH_FAIL; |
| 510 |
MTP_HandleTypeDef *MTP_Handle = phost->pActiveClass->pData; |
| 511 |
|
| 512 |
if(MTP_Handle->is_ready > 0) |
| 513 |
{ |
| 514 |
*storage_num = MTP_Handle->info.storids.n; |
| 515 |
status = USBH_OK; |
| 516 |
} |
| 517 |
|
| 518 |
return status; |
| 519 |
} |
| 520 |
|
| 521 |
/** |
| 522 |
* @brief USBH_MTP_SelectStorage |
| 523 |
* Select the storage Unit to be used |
| 524 |
* @param phost: Host handle |
| 525 |
* @retval USBH Status |
| 526 |
*/ |
| 527 |
USBH_StatusTypeDef USBH_MTP_SelectStorage (USBH_HandleTypeDef *phost, uint8_t storage_idx) |
| 528 |
{ |
| 529 |
USBH_StatusTypeDef status = USBH_FAIL; |
| 530 |
MTP_HandleTypeDef *MTP_Handle = phost->pActiveClass->pData; |
| 531 |
|
| 532 |
if((storage_idx < MTP_Handle->info.storids.n) && (MTP_Handle->is_ready)) |
| 533 |
{ |
| 534 |
MTP_Handle->params.CurrentStorageId = MTP_Handle->info.storids.Storage[storage_idx]; |
| 535 |
status = USBH_OK; |
| 536 |
} |
| 537 |
|
| 538 |
return status; |
| 539 |
} |
| 540 |
|
| 541 |
/** |
| 542 |
* @brief USBH_MTP_GetStorageInfo |
| 543 |
* Get the storage Unit info |
| 544 |
* @param phost: Host handle |
| 545 |
* @retval USBH Status |
| 546 |
*/ |
| 547 |
USBH_StatusTypeDef USBH_MTP_GetStorageInfo (USBH_HandleTypeDef *phost, uint8_t storage_idx, MTP_StorageInfoTypedef *info) |
| 548 |
{ |
| 549 |
USBH_StatusTypeDef status = USBH_FAIL; |
| 550 |
MTP_HandleTypeDef *MTP_Handle = phost->pActiveClass->pData; |
| 551 |
|
| 552 |
if((storage_idx < MTP_Handle->info.storids.n) && (MTP_Handle->is_ready)) |
| 553 |
{ |
| 554 |
*info = MTP_Handle->info.storinfo[storage_idx]; |
| 555 |
status = USBH_OK; |
| 556 |
} |
| 557 |
return status; |
| 558 |
} |
| 559 |
|
| 560 |
/** |
| 561 |
* @brief USBH_MTP_GetStorageInfo |
| 562 |
* Get the storage Unit info |
| 563 |
* @param phost: Host handle |
| 564 |
* @retval USBH Status |
| 565 |
*/ |
| 566 |
USBH_StatusTypeDef USBH_MTP_GetNumObjects (USBH_HandleTypeDef *phost, |
| 567 |
uint32_t storage_idx, |
| 568 |
uint32_t objectformatcode, |
| 569 |
uint32_t associationOH, |
| 570 |
uint32_t* numobs) |
| 571 |
{ |
| 572 |
USBH_StatusTypeDef status = USBH_FAIL; |
| 573 |
MTP_HandleTypeDef *MTP_Handle = phost->pActiveClass->pData; |
| 574 |
uint32_t timeout = phost->Timer + 5000; |
| 575 |
if((storage_idx < MTP_Handle->info.storids.n) && (MTP_Handle->is_ready)) |
| 576 |
{ |
| 577 |
while ((status = USBH_PTP_GetNumObjects (phost, |
| 578 |
MTP_Handle->info.storids.Storage[storage_idx], |
| 579 |
objectformatcode, |
| 580 |
associationOH, |
| 581 |
numobs)) == USBH_BUSY) |
| 582 |
{ |
| 583 |
if((phost->Timer > timeout) || (phost->device.is_connected == 0)) |
| 584 |
{ |
| 585 |
return USBH_FAIL; |
| 586 |
} |
| 587 |
} |
| 588 |
} |
| 589 |
return status; |
| 590 |
} |
| 591 |
|
| 592 |
|
| 593 |
/** |
| 594 |
* @brief USBH_MTP_GetStorageInfo |
| 595 |
* Get the storage Unit info |
| 596 |
* @param phost: Host handle |
| 597 |
* @retval USBH Status |
| 598 |
*/ |
| 599 |
USBH_StatusTypeDef USBH_MTP_GetObjectHandles (USBH_HandleTypeDef *phost, |
| 600 |
uint32_t storage_idx, |
| 601 |
uint32_t objectformatcode, |
| 602 |
uint32_t associationOH, |
| 603 |
PTP_ObjectHandlesTypedef* objecthandles) |
| 604 |
{ |
| 605 |
USBH_StatusTypeDef status = USBH_FAIL; |
| 606 |
MTP_HandleTypeDef *MTP_Handle = phost->pActiveClass->pData; |
| 607 |
uint32_t timeout = phost->Timer + 5000; |
| 608 |
|
| 609 |
if((storage_idx < MTP_Handle->info.storids.n) && (MTP_Handle->is_ready)) |
| 610 |
{ |
| 611 |
while ((status = USBH_PTP_GetObjectHandles (phost, |
| 612 |
MTP_Handle->info.storids.Storage[storage_idx], |
| 613 |
objectformatcode, |
| 614 |
associationOH, |
| 615 |
objecthandles)) == USBH_BUSY) |
| 616 |
{ |
| 617 |
if((phost->Timer > timeout) || (phost->device.is_connected == 0)) |
| 618 |
{ |
| 619 |
return USBH_FAIL; |
| 620 |
} |
| 621 |
} |
| 622 |
} |
| 623 |
return status; |
| 624 |
} |
| 625 |
|
| 626 |
/** |
| 627 |
* @brief USBH_PTP_GetObjectInfo |
| 628 |
* Gets objert info |
| 629 |
* @param phost: Host handle |
| 630 |
* @param dev_info: Device info structure |
| 631 |
* @retval USBH Status |
| 632 |
*/ |
| 633 |
USBH_StatusTypeDef USBH_MTP_GetObjectInfo (USBH_HandleTypeDef *phost, |
| 634 |
uint32_t handle, |
| 635 |
PTP_ObjectInfoTypedef* objectinfo) |
| 636 |
{ |
| 637 |
USBH_StatusTypeDef status = USBH_FAIL; |
| 638 |
MTP_HandleTypeDef *MTP_Handle = phost->pActiveClass->pData; |
| 639 |
uint32_t timeout = phost->Timer + 5000; |
| 640 |
|
| 641 |
if(MTP_Handle->is_ready) |
| 642 |
{ |
| 643 |
while ((status = USBH_PTP_GetObjectInfo (phost, handle, objectinfo)) == USBH_BUSY) |
| 644 |
{ |
| 645 |
if((phost->Timer > timeout) || (phost->device.is_connected == 0)) |
| 646 |
{ |
| 647 |
return USBH_FAIL; |
| 648 |
} |
| 649 |
} |
| 650 |
} |
| 651 |
return status; |
| 652 |
} |
| 653 |
/** |
| 654 |
* @brief USBH_MTP_DeleteObject |
| 655 |
* Delete an object. |
| 656 |
* @param phost: Host handle |
| 657 |
* @param handle : Object Handle |
| 658 |
* @retval USBH Status |
| 659 |
*/ |
| 660 |
USBH_StatusTypeDef USBH_MTP_DeleteObject (USBH_HandleTypeDef *phost, |
| 661 |
uint32_t handle, |
| 662 |
uint32_t objectformatcode) |
| 663 |
{ |
| 664 |
USBH_StatusTypeDef status = USBH_FAIL; |
| 665 |
MTP_HandleTypeDef *MTP_Handle = phost->pActiveClass->pData; |
| 666 |
uint32_t timeout = phost->Timer + 5000; |
| 667 |
|
| 668 |
if(MTP_Handle->is_ready) |
| 669 |
{ |
| 670 |
while ((status = USBH_PTP_DeleteObject (phost, handle, objectformatcode)) == USBH_BUSY) |
| 671 |
{ |
| 672 |
if((phost->Timer > timeout) || (phost->device.is_connected == 0)) |
| 673 |
{ |
| 674 |
return USBH_FAIL; |
| 675 |
} |
| 676 |
} |
| 677 |
} |
| 678 |
return status; |
| 679 |
} |
| 680 |
|
| 681 |
/** |
| 682 |
* @brief USBH_MTP_GetObject |
| 683 |
* Gets object |
| 684 |
* @param phost: Host handle |
| 685 |
* @param dev_info: Device info structure |
| 686 |
* @retval USBH Status |
| 687 |
*/ |
| 688 |
USBH_StatusTypeDef USBH_MTP_GetObject (USBH_HandleTypeDef *phost, |
| 689 |
uint32_t handle, |
| 690 |
uint8_t *object) |
| 691 |
{ |
| 692 |
USBH_StatusTypeDef status = USBH_FAIL; |
| 693 |
MTP_HandleTypeDef *MTP_Handle = phost->pActiveClass->pData; |
| 694 |
uint32_t timeout = phost->Timer + 5000; |
| 695 |
|
| 696 |
if(MTP_Handle->is_ready) |
| 697 |
{ |
| 698 |
while ((status = USBH_PTP_GetObject (phost, handle, object)) == USBH_BUSY) |
| 699 |
{ |
| 700 |
if((phost->Timer > timeout) || (phost->device.is_connected == 0)) |
| 701 |
{ |
| 702 |
return USBH_FAIL; |
| 703 |
} |
| 704 |
} |
| 705 |
} |
| 706 |
return status; |
| 707 |
} |
| 708 |
|
| 709 |
/** |
| 710 |
* @brief USBH_MTP_GetPartialObject |
| 711 |
* Gets object |
| 712 |
* @param phost: Host handle |
| 713 |
* @param dev_info: Device info structure |
| 714 |
* @retval USBH Status |
| 715 |
*/ |
| 716 |
USBH_StatusTypeDef USBH_MTP_GetPartialObject(USBH_HandleTypeDef *phost, |
| 717 |
uint32_t handle, |
| 718 |
uint32_t offset, |
| 719 |
uint32_t maxbytes, |
| 720 |
uint8_t *object, |
| 721 |
uint32_t *len) |
| 722 |
{ |
| 723 |
USBH_StatusTypeDef status = USBH_FAIL; |
| 724 |
MTP_HandleTypeDef *MTP_Handle = phost->pActiveClass->pData; |
| 725 |
uint32_t timeout = phost->Timer + 5000; |
| 726 |
|
| 727 |
if(MTP_Handle->is_ready) |
| 728 |
{ |
| 729 |
while ((status = USBH_PTP_GetPartialObject(phost, |
| 730 |
handle, |
| 731 |
offset, |
| 732 |
maxbytes, |
| 733 |
object, |
| 734 |
len)) == USBH_BUSY) |
| 735 |
{ |
| 736 |
if((phost->Timer > timeout) || (phost->device.is_connected == 0)) |
| 737 |
{ |
| 738 |
return USBH_FAIL; |
| 739 |
} |
| 740 |
} |
| 741 |
} |
| 742 |
return status; |
| 743 |
} |
| 744 |
|
| 745 |
/** |
| 746 |
* @brief USBH_MTP_GetObjectPropsSupported |
| 747 |
* Gets object partially |
| 748 |
* @param phost: Host handle |
| 749 |
* @param dev_info: Device info structure |
| 750 |
* @retval USBH Status |
| 751 |
*/ |
| 752 |
USBH_StatusTypeDef USBH_MTP_GetObjectPropsSupported (USBH_HandleTypeDef *phost, |
| 753 |
uint16_t ofc, |
| 754 |
uint32_t *propnum, |
| 755 |
uint16_t *props) |
| 756 |
{ |
| 757 |
USBH_StatusTypeDef status = USBH_FAIL; |
| 758 |
MTP_HandleTypeDef *MTP_Handle = phost->pActiveClass->pData; |
| 759 |
uint32_t timeout = phost->Timer + 5000; |
| 760 |
|
| 761 |
if(MTP_Handle->is_ready) |
| 762 |
{ |
| 763 |
while ((status = USBH_PTP_GetObjectPropsSupported (phost, |
| 764 |
ofc, |
| 765 |
propnum, |
| 766 |
props)) == USBH_BUSY) |
| 767 |
{ |
| 768 |
if((phost->Timer > timeout) || (phost->device.is_connected == 0)) |
| 769 |
{ |
| 770 |
return USBH_FAIL; |
| 771 |
} |
| 772 |
} |
| 773 |
} |
| 774 |
return status; |
| 775 |
} |
| 776 |
|
| 777 |
/** |
| 778 |
* @brief USBH_MTP_GetObjectPropDesc |
| 779 |
* Gets object partially |
| 780 |
* @param phost: Host handle |
| 781 |
* @param dev_info: Device info structure |
| 782 |
* @retval USBH Status |
| 783 |
*/ |
| 784 |
USBH_StatusTypeDef USBH_MTP_GetObjectPropDesc (USBH_HandleTypeDef *phost, |
| 785 |
uint16_t opc, |
| 786 |
uint16_t ofc, |
| 787 |
PTP_ObjectPropDescTypeDef *opd) |
| 788 |
{ |
| 789 |
USBH_StatusTypeDef status = USBH_FAIL; |
| 790 |
MTP_HandleTypeDef *MTP_Handle = phost->pActiveClass->pData; |
| 791 |
uint32_t timeout = phost->Timer + 5000; |
| 792 |
|
| 793 |
if(MTP_Handle->is_ready) |
| 794 |
{ |
| 795 |
while ((status = USBH_PTP_GetObjectPropDesc (phost, |
| 796 |
opc, |
| 797 |
ofc, |
| 798 |
opd)) == USBH_BUSY) |
| 799 |
{ |
| 800 |
if((phost->Timer > timeout) || (phost->device.is_connected == 0)) |
| 801 |
{ |
| 802 |
return USBH_FAIL; |
| 803 |
} |
| 804 |
} |
| 805 |
} |
| 806 |
return status; |
| 807 |
} |
| 808 |
|
| 809 |
/** |
| 810 |
* @brief USBH_MTP_GetObjectPropList |
| 811 |
* Gets object partially |
| 812 |
* @param phost: Host handle |
| 813 |
* @param dev_info: Device info structure |
| 814 |
* @retval USBH Status |
| 815 |
*/ |
| 816 |
USBH_StatusTypeDef USBH_MTP_GetObjectPropList (USBH_HandleTypeDef *phost, |
| 817 |
uint32_t handle, |
| 818 |
MTP_PropertiesTypedef *pprops, |
| 819 |
uint32_t *nrofprops) |
| 820 |
{ |
| 821 |
USBH_StatusTypeDef status = USBH_FAIL; |
| 822 |
MTP_HandleTypeDef *MTP_Handle = phost->pActiveClass->pData; |
| 823 |
uint32_t timeout = phost->Timer + 5000; |
| 824 |
|
| 825 |
if(MTP_Handle->is_ready) |
| 826 |
{ |
| 827 |
while ((status = USBH_PTP_GetObjectPropList (phost, |
| 828 |
handle, |
| 829 |
pprops, |
| 830 |
nrofprops)) == USBH_BUSY) |
| 831 |
{ |
| 832 |
if((phost->Timer > timeout) || (phost->device.is_connected == 0)) |
| 833 |
{ |
| 834 |
return USBH_FAIL; |
| 835 |
} |
| 836 |
} |
| 837 |
} |
| 838 |
return status; |
| 839 |
} |
| 840 |
|
| 841 |
/** |
| 842 |
* @brief USBH_MTP_SendObject |
| 843 |
* Send an object |
| 844 |
* @param phost: Host handle |
| 845 |
* @param dev_info: Device info structure |
| 846 |
* @retval USBH Status |
| 847 |
*/ |
| 848 |
USBH_StatusTypeDef USBH_MTP_SendObject (USBH_HandleTypeDef *phost, |
| 849 |
uint32_t handle, |
| 850 |
uint8_t *object, |
| 851 |
uint32_t size) |
| 852 |
{ |
| 853 |
USBH_StatusTypeDef status = USBH_FAIL; |
| 854 |
MTP_HandleTypeDef *MTP_Handle = phost->pActiveClass->pData; |
| 855 |
uint32_t timeout = phost->Timer + 5000; |
| 856 |
|
| 857 |
if(MTP_Handle->is_ready) |
| 858 |
{ |
| 859 |
while ((status = USBH_PTP_SendObject (phost, handle, object, size)) == USBH_BUSY) |
| 860 |
{ |
| 861 |
if((phost->Timer > timeout) || (phost->device.is_connected == 0)) |
| 862 |
{ |
| 863 |
return USBH_FAIL; |
| 864 |
} |
| 865 |
} |
| 866 |
} |
| 867 |
return status; |
| 868 |
} |
| 869 |
|
| 870 |
/** |
| 871 |
* @brief Handle HID Control process |
| 872 |
* @param phost: Host handle |
| 873 |
* @retval USBH Status |
| 874 |
*/ |
| 875 |
static USBH_StatusTypeDef USBH_MTP_Events (USBH_HandleTypeDef *phost) |
| 876 |
{ |
| 877 |
USBH_StatusTypeDef status = USBH_BUSY ; |
| 878 |
MTP_HandleTypeDef *MTP_Handle = phost->pActiveClass->pData; |
| 879 |
|
| 880 |
|
| 881 |
switch(MTP_Handle->events.state) |
| 882 |
{ |
| 883 |
case MTP_EVENTS_INIT: |
| 884 |
if((phost->Timer & 1) == 0) |
| 885 |
{ |
| 886 |
MTP_Handle->events.timer = phost->Timer; |
| 887 |
USBH_InterruptReceiveData(phost, |
| 888 |
(uint8_t *)&(MTP_Handle->events.container), |
| 889 |
MTP_Handle->NotificationEpSize, |
| 890 |
MTP_Handle->NotificationPipe); |
| 891 |
|
| 892 |
|
| 893 |
MTP_Handle->events.state = MTP_EVENTS_GETDATA ; |
| 894 |
} |
| 895 |
break; |
| 896 |
case MTP_EVENTS_GETDATA: |
| 897 |
if(USBH_LL_GetURBState(phost , MTP_Handle->NotificationPipe) == USBH_URB_DONE) |
| 898 |
{ |
| 899 |
MTP_DecodeEvent(phost); |
| 900 |
} |
| 901 |
|
| 902 |
if(( phost->Timer - MTP_Handle->events.timer) >= MTP_Handle->events.poll) |
| 903 |
{ |
| 904 |
MTP_Handle->events.timer = phost->Timer; |
| 905 |
|
| 906 |
USBH_InterruptReceiveData(phost, |
| 907 |
(uint8_t *)&(MTP_Handle->events.container), |
| 908 |
MTP_Handle->NotificationEpSize, |
| 909 |
MTP_Handle->NotificationPipe); |
| 910 |
|
| 911 |
} |
| 912 |
break; |
| 913 |
|
| 914 |
default: |
| 915 |
break; |
| 916 |
} |
| 917 |
|
| 918 |
return status; |
| 919 |
} |
| 920 |
|
| 921 |
/** |
| 922 |
* @brief MTP_DecodeEvent |
| 923 |
* Decode device event sent by responder |
| 924 |
* @param phost: Host handle |
| 925 |
* @retval None |
| 926 |
*/ |
| 927 |
static void MTP_DecodeEvent (USBH_HandleTypeDef *phost) |
| 928 |
{ |
| 929 |
MTP_HandleTypeDef *MTP_Handle = phost->pActiveClass->pData; |
| 930 |
|
| 931 |
uint16_t code; |
| 932 |
uint32_t param1; |
| 933 |
|
| 934 |
/* Process the event */ |
| 935 |
code = MTP_Handle->events.container.code; |
| 936 |
param1 = MTP_Handle->events.container.param1; |
| 937 |
|
| 938 |
switch(code) |
| 939 |
{ |
| 940 |
case PTP_EC_Undefined: |
| 941 |
USBH_DbgLog("EVT: PTP_EC_Undefined in session %u", MTP_Handle->ptp.session_id); |
| 942 |
break; |
| 943 |
case PTP_EC_CancelTransaction: |
| 944 |
USBH_DbgLog("EVT: PTP_EC_CancelTransaction in session %u", MTP_Handle->ptp.session_id); |
| 945 |
break; |
| 946 |
case PTP_EC_ObjectAdded: |
| 947 |
USBH_DbgLog("EVT: PTP_EC_ObjectAdded in session %u", MTP_Handle->ptp.session_id); |
| 948 |
break; |
| 949 |
|
| 950 |
case PTP_EC_ObjectRemoved: |
| 951 |
USBH_DbgLog("EVT: PTP_EC_ObjectRemoved in session %u", MTP_Handle->ptp.session_id); |
| 952 |
break; |
| 953 |
|
| 954 |
case PTP_EC_StoreAdded: |
| 955 |
USBH_DbgLog("EVT: PTP_EC_StoreAdded in session %u", MTP_Handle->ptp.session_id); |
| 956 |
break; |
| 957 |
|
| 958 |
case PTP_EC_StoreRemoved: |
| 959 |
USBH_DbgLog("EVT: PTP_EC_StoreRemoved in session %u", MTP_Handle->ptp.session_id); |
| 960 |
break; |
| 961 |
|
| 962 |
case PTP_EC_DevicePropChanged: |
| 963 |
USBH_DbgLog("EVT: PTP_EC_DevicePropChanged in session %u", MTP_Handle->ptp.session_id); |
| 964 |
break; |
| 965 |
|
| 966 |
case PTP_EC_ObjectInfoChanged: |
| 967 |
USBH_DbgLog("EVT: PTP_EC_ObjectInfoChanged in session %u", MTP_Handle->ptp.session_id); |
| 968 |
break; |
| 969 |
|
| 970 |
case PTP_EC_DeviceInfoChanged: |
| 971 |
USBH_DbgLog("EVT: PTP_EC_DeviceInfoChanged in session %u", MTP_Handle->ptp.session_id); |
| 972 |
break; |
| 973 |
|
| 974 |
case PTP_EC_RequestObjectTransfer: |
| 975 |
USBH_DbgLog("EVT: PTP_EC_RequestObjectTransfer in session %u", MTP_Handle->ptp.session_id); |
| 976 |
break; |
| 977 |
|
| 978 |
case PTP_EC_StoreFull: |
| 979 |
USBH_DbgLog("EVT: PTP_EC_StoreFull in session %u", MTP_Handle->ptp.session_id); |
| 980 |
break; |
| 981 |
|
| 982 |
case PTP_EC_DeviceReset: |
| 983 |
USBH_DbgLog("EVT: PTP_EC_DeviceReset in session %u", MTP_Handle->ptp.session_id); |
| 984 |
break; |
| 985 |
|
| 986 |
case PTP_EC_StorageInfoChanged : |
| 987 |
USBH_DbgLog( "EVT: PTP_EC_StorageInfoChanged in session %u", MTP_Handle->ptp.session_id); |
| 988 |
break; |
| 989 |
|
| 990 |
case PTP_EC_CaptureComplete : |
| 991 |
USBH_DbgLog( "EVT: PTP_EC_CaptureComplete in session %u", MTP_Handle->ptp.session_id); |
| 992 |
break; |
| 993 |
|
| 994 |
case PTP_EC_UnreportedStatus : |
| 995 |
USBH_DbgLog( "EVT: PTP_EC_UnreportedStatus in session %u", MTP_Handle->ptp.session_id); |
| 996 |
break; |
| 997 |
|
| 998 |
default : |
| 999 |
USBH_DbgLog( "Received unknown event in session %u", MTP_Handle->ptp.session_id); |
| 1000 |
break; |
| 1001 |
} |
| 1002 |
|
| 1003 |
USBH_MTP_EventsCallback(phost, code, param1); |
| 1004 |
} |
| 1005 |
|
| 1006 |
/** |
| 1007 |
* @brief USBH_MTP_GetDevicePropDesc |
| 1008 |
* Gets object partially |
| 1009 |
* @param phost: Host handle |
| 1010 |
* @param dev_info: Device info structure |
| 1011 |
* @retval USBH Status |
| 1012 |
*/ |
| 1013 |
USBH_StatusTypeDef USBH_MTP_GetDevicePropDesc (USBH_HandleTypeDef *phost, |
| 1014 |
uint16_t propcode, |
| 1015 |
PTP_DevicePropDescTypdef* devicepropertydesc) |
| 1016 |
|
| 1017 |
{ |
| 1018 |
USBH_StatusTypeDef status = USBH_FAIL; |
| 1019 |
MTP_HandleTypeDef *MTP_Handle = phost->pActiveClass->pData; |
| 1020 |
uint32_t timeout = phost->Timer + 5000; |
| 1021 |
|
| 1022 |
if(MTP_Handle->is_ready) |
| 1023 |
{ |
| 1024 |
while ((status = USBH_PTP_GetDevicePropDesc (phost, propcode, devicepropertydesc)) == USBH_BUSY) |
| 1025 |
{ |
| 1026 |
if((phost->Timer > timeout) || (phost->device.is_connected == 0)) |
| 1027 |
{ |
| 1028 |
return USBH_FAIL; |
| 1029 |
} |
| 1030 |
} |
| 1031 |
} |
| 1032 |
return status; |
| 1033 |
} |
| 1034 |
/** |
| 1035 |
* @brief The function informs that host has rceived an event |
| 1036 |
* @param pdev: Selected device |
| 1037 |
* @retval None |
| 1038 |
*/ |
| 1039 |
__weak void USBH_MTP_EventsCallback(USBH_HandleTypeDef *phost, uint32_t event, uint32_t param) |
| 1040 |
{ |
| 1041 |
|
| 1042 |
} |
| 1043 |
/** |
| 1044 |
* @} |
| 1045 |
*/ |
| 1046 |
|
| 1047 |
/** |
| 1048 |
* @} |
| 1049 |
*/ |
| 1050 |
|
| 1051 |
/** |
| 1052 |
* @} |
| 1053 |
*/ |
| 1054 |
|
| 1055 |
|
| 1056 |
/** |
| 1057 |
* @} |
| 1058 |
*/ |
| 1059 |
|
| 1060 |
|
| 1061 |
/** |
| 1062 |
* @} |
| 1063 |
*/ |
| 1064 |
|
| 1065 |
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |