STM32F769IDiscovery  1.00
uDANTE Audio Networking with STM32F7 DISCO board
usbh_mtp_ptp.c
Go to the documentation of this file.
1 
28 /* Includes ------------------------------------------------------------------*/
29 #include "usbh_mtp_ptp.h"
30 #include "usbh_mtp.h"
83 static void PTP_DecodeDeviceInfo (USBH_HandleTypeDef *phost, PTP_DeviceInfoTypedef *dev_info);
84 static void PTP_GetStorageIDs (USBH_HandleTypeDef *phost, PTP_StorageIDsTypedef *stor_ids);
85 static void PTP_GetStorageInfo (USBH_HandleTypeDef *phost, uint32_t storage_id, PTP_StorageInfoTypedef *stor_info);
86 static void PTP_GetObjectPropDesc (USBH_HandleTypeDef *phost, PTP_ObjectPropDescTypeDef *opd, uint32_t opdlen);
87 static void PTP_DecodeDeviceInfo (USBH_HandleTypeDef *phost, PTP_DeviceInfoTypedef *dev_info);
88 static void PTP_GetDevicePropValue(USBH_HandleTypeDef *phost,
89  uint32_t *offset,
90  uint32_t total,
92  uint16_t datatype);
93 
94 static uint32_t PTP_GetObjectPropList (USBH_HandleTypeDef *phost,
95  MTP_PropertiesTypedef *props,
96  uint32_t len);
97 
98 
99 static void PTP_BufferFullCallback(USBH_HandleTypeDef *phost);
100 static void PTP_GetString(uint8_t *str, uint8_t* data, uint16_t *len);
101 static uint32_t PTP_GetArray16 (uint16_t *array, uint8_t *data, uint32_t offset);
102 static uint32_t PTP_GetArray32 (uint32_t *array, uint8_t *data, uint32_t offset);
126 {
127  MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
128 
129  /* Set state to idle to be ready for operations */
130  MTP_Handle->ptp.state = PTP_IDLE;
131  MTP_Handle->ptp.req_state = PTP_REQ_SEND;
132 
133  return USBH_OK;
134 }
135 
144 {
145  USBH_StatusTypeDef status = USBH_BUSY;
146  USBH_URBStateTypeDef URB_Status = USBH_URB_IDLE;
147  MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
148  PTP_ContainerTypedef ptp_container;
149  uint32_t len;
150 
151  switch (MTP_Handle->ptp.state)
152  {
153  case PTP_IDLE:
154  /*Do Nothing */
155  break;
156 
157  case PTP_OP_REQUEST_STATE:
158  USBH_BulkSendData (phost,
159  (uint8_t*)&(MTP_Handle->ptp.op_container),
160  MTP_Handle->ptp.op_container.length,
161  MTP_Handle->DataOutPipe,
162  1);
163  MTP_Handle->ptp.state = PTP_OP_REQUEST_WAIT_STATE;
164  break;
165 
167  URB_Status = USBH_LL_GetURBState(phost, MTP_Handle->DataOutPipe);
168 
169  if(URB_Status == USBH_URB_DONE)
170  {
171  if(MTP_Handle->ptp.flags == PTP_DP_NODATA)
172  {
173  MTP_Handle->ptp.state = PTP_RESPONSE_STATE;
174  }
175  else if(MTP_Handle->ptp.flags == PTP_DP_SENDDATA)
176  {
177  MTP_Handle->ptp.state = PTP_DATA_OUT_PHASE_STATE;
178  }
179  else if(MTP_Handle->ptp.flags == PTP_DP_GETDATA)
180  {
181  MTP_Handle->ptp.state = PTP_DATA_IN_PHASE_STATE;
182  }
183 #if (USBH_USE_OS == 1)
184  osMessagePut ( phost->os_event, USBH_URB_EVENT, 0);
185 #endif
186  }
187  else if(URB_Status == USBH_URB_NOTREADY)
188  {
189  /* Resend Request */
190  MTP_Handle->ptp.state = PTP_OP_REQUEST_STATE;
191 #if (USBH_USE_OS == 1)
192  osMessagePut ( phost->os_event, USBH_URB_EVENT, 0);
193 #endif
194  }
195  else if(URB_Status == USBH_URB_STALL)
196  {
197  MTP_Handle->ptp.state = PTP_ERROR;
198 #if (USBH_USE_OS == 1)
199  osMessagePut ( phost->os_event, USBH_URB_EVENT, 0);
200 #endif
201  }
202  break;
203 
205 
206  USBH_BulkSendData (phost,
207  MTP_Handle->ptp.data_ptr,
208  MTP_Handle->DataOutEpSize ,
209  MTP_Handle->DataOutPipe,
210  1);
211 
212 
213  MTP_Handle->ptp.state = PTP_DATA_OUT_PHASE_WAIT_STATE;
214  break;
215 
217  URB_Status = USBH_LL_GetURBState(phost, MTP_Handle->DataOutPipe);
218 
219  if(URB_Status == USBH_URB_DONE)
220  {
221  /* Adjust Data pointer and data length */
222  if(MTP_Handle->ptp.data_length > MTP_Handle->DataOutEpSize)
223  {
224  MTP_Handle->ptp.data_ptr += MTP_Handle->DataOutEpSize;
225  MTP_Handle->ptp.data_length -= MTP_Handle->DataOutEpSize;
226  MTP_Handle->ptp.data_packet += MTP_Handle->DataOutEpSize;
227 
229  {
230  PTP_BufferFullCallback (phost);
231  MTP_Handle->ptp.data_packet = 0;
232  MTP_Handle->ptp.iteration++;
233  }
234 
235  }
236  else
237  {
238  MTP_Handle->ptp.data_length = 0;
239  }
240 
241  /* More Data To be Sent */
242  if(MTP_Handle->ptp.data_length > 0)
243  {
244  USBH_BulkSendData (phost,
245  MTP_Handle->ptp.data_ptr,
246  MTP_Handle->DataOutEpSize ,
247  MTP_Handle->DataOutPipe,
248  1);
249  }
250  else
251  {
252  /* If value was 0, and successful transfer, then change the state */
253  MTP_Handle->ptp.state = PTP_RESPONSE_STATE;
254  }
255 #if (USBH_USE_OS == 1)
256  osMessagePut ( phost->os_event, USBH_URB_EVENT, 0);
257 #endif
258  }
259 
260  else if(URB_Status == USBH_URB_NOTREADY)
261  {
262  /* Resend same data */
263  MTP_Handle->ptp.state = PTP_DATA_OUT_PHASE_STATE;
264 #if (USBH_USE_OS == 1)
265  osMessagePut ( phost->os_event, USBH_URB_EVENT, 0);
266 #endif
267  }
268 
269  else if(URB_Status == USBH_URB_STALL)
270  {
271  MTP_Handle->ptp.state = PTP_ERROR;
272 #if (USBH_USE_OS == 1)
273  osMessagePut ( phost->os_event, USBH_URB_EVENT, 0);
274 #endif
275  }
276  break;
277 
279  /* Send first packet */
280  USBH_BulkReceiveData (phost,
281  MTP_Handle->ptp.data_ptr,
282  MTP_Handle->DataInEpSize,
283  MTP_Handle->DataInPipe);
284 
285  MTP_Handle->ptp.state = PTP_DATA_IN_PHASE_WAIT_STATE;
286  break;
287 
289  URB_Status = USBH_LL_GetURBState(phost, MTP_Handle->DataInPipe);
290 
291  if(URB_Status == USBH_URB_DONE)
292  {
293  len = USBH_LL_GetLastXferSize (phost, MTP_Handle->DataInPipe);
294 
295  if( MTP_Handle->ptp.data_packet_counter++ == 0)
296  {
297  /* This is the first packet; so retrieve exact data length from payload */
298  MTP_Handle->ptp.data_length = *(uint32_t*)(MTP_Handle->ptp.data_ptr);
299  MTP_Handle->ptp.iteration = 0;
300  }
301 
302  if((len >= MTP_Handle->DataInEpSize) && (MTP_Handle->ptp.data_length > 0))
303  {
304  MTP_Handle->ptp.data_ptr += len;
305  MTP_Handle->ptp.data_length -= len;
306  MTP_Handle->ptp.data_packet += len;
307 
309  {
310  PTP_BufferFullCallback (phost);
311  MTP_Handle->ptp.data_packet = 0;
312  MTP_Handle->ptp.iteration++;
313  }
314 
315  /* Continue receiving data*/
316  USBH_BulkReceiveData (phost,
317  MTP_Handle->ptp.data_ptr,
318  MTP_Handle->DataInEpSize,
319  MTP_Handle->DataInPipe);
320  }
321  else
322  {
323  MTP_Handle->ptp.data_length -= len;
324  MTP_Handle->ptp.state = PTP_RESPONSE_STATE;
325 #if (USBH_USE_OS == 1)
326  osMessagePut ( phost->os_event, USBH_URB_EVENT, 0);
327 #endif
328  }
329  }
330  else if(URB_Status == USBH_URB_STALL)
331  {
332  MTP_Handle->ptp.state = PTP_ERROR;
333 #if (USBH_USE_OS == 1)
334  osMessagePut ( phost->os_event, USBH_URB_EVENT, 0);
335 #endif
336  }
337  break;
338 
339  case PTP_RESPONSE_STATE:
340 
341  USBH_BulkReceiveData (phost,
342  (uint8_t*)&(MTP_Handle->ptp.resp_container),
344  MTP_Handle->DataInPipe);
345 
346  MTP_Handle->ptp.state = PTP_RESPONSE_WAIT_STATE;
347  break;
348 
350  URB_Status = USBH_LL_GetURBState(phost, MTP_Handle->DataInPipe);
351 
352  if(URB_Status == USBH_URB_DONE)
353  {
354  USBH_PTP_GetResponse (phost, &ptp_container);
355 
356  if(ptp_container.Code == PTP_RC_OK)
357  {
358  status = USBH_OK;
359  }
360  else
361  {
362  status = USBH_FAIL;
363  }
364  MTP_Handle->ptp.req_state = PTP_REQ_SEND;
365  }
366  else if(URB_Status == USBH_URB_STALL)
367  {
368  MTP_Handle->ptp.state = PTP_ERROR;
369 #if (USBH_USE_OS == 1)
370  osMessagePut ( phost->os_event, USBH_URB_EVENT, 0);
371 #endif
372  }
373  break;
374 
375  case PTP_ERROR:
376  MTP_Handle->ptp.req_state = PTP_REQ_SEND;
377  break;
378 
379  default:
380  break;
381  }
382  return status;
383 }
384 
392 {
393  USBH_StatusTypeDef status = USBH_OK;
394  MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
395 
396  /* Clear PTP Data container*/
397  USBH_memset(&(MTP_Handle->ptp.op_container), 0, sizeof(PTP_OpContainerTypedef));
398 
399  /* build appropriate USB container */
400  MTP_Handle->ptp.op_container.length = PTP_USB_BULK_REQ_LEN- (sizeof(uint32_t)*(5-req->Nparam));
402  MTP_Handle->ptp.op_container.code = req->Code;
403  MTP_Handle->ptp.op_container.trans_id = req->Transaction_ID;
404  MTP_Handle->ptp.op_container.param1 = req->Param1;
405  MTP_Handle->ptp.op_container.param2 = req->Param2;
406  MTP_Handle->ptp.op_container.param3 = req->Param3;
407  MTP_Handle->ptp.op_container.param4 = req->Param4;
408  MTP_Handle->ptp.op_container.param5 = req->Param5;
409 
410  return status;
411 }
412 
420 {
421  USBH_StatusTypeDef status = USBH_OK;
422  MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
423 
424  /* build an appropriate PTPContainer */
425  resp->Code = MTP_Handle->ptp.resp_container.code;
426  resp->SessionID = MTP_Handle->ptp.session_id;
427  resp->Transaction_ID = MTP_Handle->ptp.resp_container.trans_id;
428  resp->Param1 = MTP_Handle->ptp.resp_container.param1;
429  resp->Param2 = MTP_Handle->ptp.resp_container.param2;
430  resp->Param3 = MTP_Handle->ptp.resp_container.param3;
431  resp->Param4 = MTP_Handle->ptp.resp_container.param4;
432  resp->Param5 = MTP_Handle->ptp.resp_container.param5;
433 
434  return status;
435 }
436 
442 void PTP_BufferFullCallback(USBH_HandleTypeDef *phost)
443 {
444  MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
445 
446  switch (MTP_Handle->ptp.data_container.code)
447  {
449  PTP_DecodeDeviceInfo (phost, &(MTP_Handle->info.devinfo));
450  break;
451 
453  case PTP_OC_GetObject:
454 
455  /* first packet is in the PTP data payload buffer */
456  if(MTP_Handle->ptp.iteration == 0)
457  {
458  /* copy it to object */
460 
461  /* next packet should be directly copied to object */
462  MTP_Handle->ptp.data_ptr = (MTP_Handle->ptp.object_ptr + PTP_USB_BULK_PAYLOAD_LEN_READ);
463  }
464  break;
465 
466  case PTP_OC_SendObject:
467  /* first packet is in the PTP data payload buffer */
468  if(MTP_Handle->ptp.iteration == 0)
469  {
470  /* next packet should be directly copied to object */
471  MTP_Handle->ptp.data_ptr = (MTP_Handle->ptp.object_ptr + PTP_USB_BULK_PAYLOAD_LEN_READ);
472  }
473  break;
474 
475  default:
476  break;
477 
478 
479  }
480 }
481 
489 static void PTP_DecodeDeviceInfo (USBH_HandleTypeDef *phost, PTP_DeviceInfoTypedef *dev_info)
490 {
491  MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
492  uint8_t *data = MTP_Handle->ptp.data_container.payload.data;
493  uint32_t totallen;
494  uint16_t len;
495 
496  /* Max device info is PTP_USB_BULK_HS_MAX_PACKET_LEN_READ */
497  USBH_DbgLog (" MTP device info size exceeds internal buffer size.\
498  only available data are decoded.");
499 
500  if(MTP_Handle->ptp.iteration == 0)
501  {
502  dev_info->StandardVersion = LE16(&data[PTP_di_StandardVersion]);
503  dev_info->VendorExtensionID = LE32(&data[PTP_di_VendorExtensionID]);
505  PTP_GetString(dev_info->VendorExtensionDesc, &data[PTP_di_VendorExtensionDesc], &len);
506 
507  totallen=len*2+1;
508  dev_info->FunctionalMode = LE16(&data[PTP_di_FunctionalMode+totallen]);
509  dev_info->OperationsSupported_len = PTP_GetArray16 ((uint16_t *)&dev_info->OperationsSupported,
510  data,
511  PTP_di_OperationsSupported+totallen);
512 
513  totallen=totallen+dev_info->OperationsSupported_len*sizeof(uint16_t)+sizeof(uint32_t);
514  dev_info->EventsSupported_len = PTP_GetArray16 ((uint16_t *)&dev_info->EventsSupported,
515  data,
516  PTP_di_OperationsSupported+totallen);
517 
518  totallen=totallen+dev_info->EventsSupported_len*sizeof(uint16_t)+sizeof(uint32_t);
519  dev_info->DevicePropertiesSupported_len = PTP_GetArray16 ((uint16_t *)&dev_info->DevicePropertiesSupported,
520  data,
521  PTP_di_OperationsSupported+totallen);
522 
523  totallen=totallen+dev_info->DevicePropertiesSupported_len*sizeof(uint16_t)+sizeof(uint32_t);
524 
525  dev_info->CaptureFormats_len = PTP_GetArray16 ((uint16_t *)&dev_info->CaptureFormats,
526  data,
527  PTP_di_OperationsSupported+totallen);
528 
529  totallen=totallen+dev_info->CaptureFormats_len*sizeof(uint16_t)+sizeof(uint32_t);
530  dev_info->ImageFormats_len = PTP_GetArray16 ((uint16_t *)&dev_info->ImageFormats,
531  data,
532  PTP_di_OperationsSupported+totallen);
533 
534  totallen=totallen+dev_info->ImageFormats_len*sizeof(uint16_t)+sizeof(uint32_t);
535  PTP_GetString(dev_info->Manufacturer, &data[PTP_di_OperationsSupported+totallen], &len);
536 
537  totallen+=len*2+1;
538  PTP_GetString(dev_info->Model, &data[PTP_di_OperationsSupported+totallen], &len);
539 
540  totallen+=len*2+1;
541  PTP_GetString(dev_info->DeviceVersion, &data[PTP_di_OperationsSupported+totallen], &len);
542 
543  totallen+=len*2+1;
544  PTP_GetString(dev_info->SerialNumber, &data[PTP_di_OperationsSupported+totallen], &len);
545  }
546 }
547 
555 static void PTP_GetStorageIDs (USBH_HandleTypeDef *phost, PTP_StorageIDsTypedef *stor_ids)
556 {
557  MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
558  uint8_t *data = MTP_Handle->ptp.data_container.payload.data;
559 
560  stor_ids->n = PTP_GetArray32 (stor_ids->Storage, data, 0);
561 }
562 
563 
571 static void PTP_GetStorageInfo (USBH_HandleTypeDef *phost, uint32_t storage_id, PTP_StorageInfoTypedef *stor_info)
572 {
573  MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
574  uint8_t *data = MTP_Handle->ptp.data_container.payload.data;
575 
576  uint16_t len;
577 
578  stor_info->StorageType=LE16(&data[PTP_si_StorageType]);
579  stor_info->FilesystemType=LE16(&data[PTP_si_FilesystemType]);
580  stor_info->AccessCapability=LE16(&data[PTP_si_AccessCapability]);
581  stor_info->MaxCapability=LE64(&data[PTP_si_MaxCapability]);
582  stor_info->FreeSpaceInBytes=LE64(&data[PTP_si_FreeSpaceInBytes]);
584 
585  PTP_GetString(stor_info->StorageDescription, &data[PTP_si_StorageDescription], &len);
586  PTP_GetString(stor_info->VolumeLabel, &data[PTP_si_StorageDescription+len*2+1], &len);
587 }
588 
596 static void PTP_GetObjectInfo (USBH_HandleTypeDef *phost, PTP_ObjectInfoTypedef *object_info)
597 {
598  MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
599  uint8_t *data = MTP_Handle->ptp.data_container.payload.data;
600  uint16_t filenamelen;
601 
602  object_info->StorageID=LE32(&data[PTP_oi_StorageID]);
603  object_info->ObjectFormat=LE16(&data[PTP_oi_ObjectFormat]);
604  object_info->ProtectionStatus=LE16(&data[PTP_oi_ProtectionStatus]);
606 
607  /* For Samsung Galaxy */
608  if ((data[PTP_oi_filenamelen] == 0) && (data[PTP_oi_filenamelen+4] != 0))
609  {
610  data += 4;
611  }
612  object_info->ThumbFormat=LE16(&data[PTP_oi_ThumbFormat]);
614  object_info->ThumbPixWidth=LE32(&data[PTP_oi_ThumbPixWidth]);
615  object_info->ThumbPixHeight=LE32(&data[PTP_oi_ThumbPixHeight]);
616  object_info->ImagePixWidth=LE32(&data[PTP_oi_ImagePixWidth]);
617  object_info->ImagePixHeight=LE32(&data[PTP_oi_ImagePixHeight]);
618  object_info->ImageBitDepth=LE32(&data[PTP_oi_ImageBitDepth]);
619  object_info->ParentObject=LE32(&data[PTP_oi_ParentObject]);
620  object_info->AssociationType=LE16(&data[PTP_oi_AssociationType]);
621  object_info->AssociationDesc=LE32(&data[PTP_oi_AssociationDesc]);
622  object_info->SequenceNumber=LE32(&data[PTP_oi_SequenceNumber]);
623  PTP_GetString(object_info->Filename, &data[PTP_oi_filenamelen], &filenamelen);
624 }
625 
626 
634 static void PTP_GetObjectPropDesc (USBH_HandleTypeDef *phost, PTP_ObjectPropDescTypeDef *opd, uint32_t opdlen)
635 {
636  MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
637  uint8_t *data = MTP_Handle->ptp.data_container.payload.data;
638  uint32_t offset = 0, i;
639 
641  opd->DataType=LE16(&data[PTP_opd_DataType]);
642  opd->GetSet=*(uint8_t *)(&data[PTP_opd_GetSet]);
643 
645  PTP_GetDevicePropValue (phost, &offset, opdlen, &opd->FactoryDefaultValue, opd->DataType);
646 
647  opd->GroupCode=LE32(&data[offset]);
648  offset+=sizeof(uint32_t);
649 
650  opd->FormFlag=*(uint8_t *)(&data[offset]);
651  offset+=sizeof(uint8_t);
652 
653  switch (opd->FormFlag)
654  {
655  case PTP_OPFF_Range:
656  PTP_GetDevicePropValue(phost, &offset, opdlen, &opd->FORM.Range.MinimumValue, opd->DataType);
657  PTP_GetDevicePropValue(phost, &offset, opdlen, &opd->FORM.Range.MaximumValue, opd->DataType);
658  PTP_GetDevicePropValue(phost, &offset, opdlen, &opd->FORM.Range.StepSize, opd->DataType);
659  break;
660 
662 
663  opd->FORM.Enum.NumberOfValues = LE16(&data[offset]);
664  offset+=sizeof(uint16_t);
665 
666  for (i=0 ; i < opd->FORM.Enum.NumberOfValues ; i++)
667  {
668  PTP_GetDevicePropValue(phost, &offset, opdlen, &opd->FORM.Enum.SupportedValue[i], opd->DataType);
669  }
670  break;
671  default:
672  break;
673  }
674 }
675 
683 static void PTP_GetDevicePropValue(USBH_HandleTypeDef *phost,
684  uint32_t *offset,
685  uint32_t total,
686  PTP_PropertyValueTypedef* value,
687  uint16_t datatype)
688 {
689  MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
690  uint8_t *data = MTP_Handle->ptp.data_container.payload.data;
691  uint16_t len;
692  switch (datatype)
693  {
694  case PTP_DTC_INT8:
695  value->i8 = *(uint8_t *)&(data[*offset]);
696  *offset += 1;
697  break;
698  case PTP_DTC_UINT8:
699  value->u8 = *(uint8_t *)&(data[*offset]);
700  *offset += 1;
701  break;
702  case PTP_DTC_INT16:
703 
704  value->i16 = LE16(&(data[*offset]));
705  *offset += 2;
706  break;
707  case PTP_DTC_UINT16:
708  value->u16 = LE16(&(data[*offset]));
709  *offset += 2;
710  break;
711  case PTP_DTC_INT32:
712  value->i32 = LE32(&(data[*offset]));
713  *offset += 4;
714  break;
715  case PTP_DTC_UINT32:
716  value->u32 = LE32(&(data[*offset]));
717  *offset += 4;
718  break;
719  case PTP_DTC_INT64:
720  value->i64 = LE64(&(data[*offset]));
721  *offset += 8;
722  break;
723  case PTP_DTC_UINT64:
724  value->u64 = LE64(&(data[*offset]));
725  *offset += 8;
726  break;
727 
728  case PTP_DTC_UINT128:
729  *offset += 16;
730  break;
731  case PTP_DTC_INT128:
732  *offset += 16;
733  break;
734 
735  case PTP_DTC_STR:
736 
737  PTP_GetString((uint8_t *)value->str, (uint8_t *)&(data[*offset]), &len);
738  *offset += len*2+1;
739  break;
740  default:
741  break;
742  }
743 }
744 
745 
753 static uint32_t PTP_GetObjectPropList (USBH_HandleTypeDef *phost,
754  MTP_PropertiesTypedef *props,
755  uint32_t len)
756 {
757  MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
758  uint8_t *data = MTP_Handle->ptp.data_container.payload.data;
759  uint32_t prop_count;
760  uint32_t offset = 0, i;
761 
762  prop_count = LE32(data);
763 
764 
765  if (prop_count == 0)
766  {
767  return 0;
768  }
769 
770  data += sizeof(uint32_t);
771  len -= sizeof(uint32_t);
772 
773  for (i = 0; i < prop_count; i++)
774  {
775  if (len <= 0)
776  {
777  return 0;
778  }
779 
780  props[i].ObjectHandle = LE32(data);
781  data += sizeof(uint32_t);
782  len -= sizeof(uint32_t);
783 
784  props[i].property = LE16(data);
785  data += sizeof(uint16_t);
786  len -= sizeof(uint16_t);
787 
788  props[i].datatype = LE16(data);
789  data += sizeof(uint16_t);
790  len -= sizeof(uint16_t);
791 
792  offset = 0;
793 
794  PTP_GetDevicePropValue(phost, &offset, len, &props[i].propval, props[i].datatype);
795 
796  data += offset;
797  len -= offset;
798  }
799 
800  return prop_count;
801 }
802 
810 static void PTP_GetString (uint8_t *str, uint8_t* data, uint16_t *len)
811 {
812  uint16_t strlength;
813  uint16_t idx;
814 
815  *len = data[0];
816  strlength = 2 * data[0];
817  data ++; /* Adjust the offset ignoring the String Len */
818 
819  for (idx = 0; idx < strlength; idx+=2 )
820  {
821  /* Copy Only the string and ignore the UNICODE ID, hence add the src */
822  *str = data[idx];
823  str++;
824  }
825  *str = 0; /* mark end of string */
826 }
827 
836 static uint32_t PTP_GetArray16 (uint16_t *array, uint8_t *data, uint32_t offset)
837 {
838  uint32_t size, idx = 0;
839 
840  size=LE32(&data[offset]);
841  while (size > idx)
842  {
843  array[idx] = LE16(&data[offset+(sizeof(uint16_t)*(idx+2))]);
844  idx++;
845  }
846  return size;
847 }
848 
857 static uint32_t PTP_GetArray32 (uint32_t *array, uint8_t *data, uint32_t offset)
858 {
859  uint32_t size, idx = 0;
860 
861  size=LE32(&data[offset]);
862  while (size > idx)
863  {
864  array[idx] = LE32(&data[offset+(sizeof(uint32_t)*(idx+1))]);
865  idx++;
866  }
867  return size;
868 }
869 
870 /*******************************************************************************
871 
872  PTP Requests
873 
874 *******************************************************************************/
883 {
884  USBH_StatusTypeDef status = USBH_BUSY;
885  MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
886  PTP_ContainerTypedef ptp_container;
887 
888  switch(MTP_Handle->ptp.req_state)
889  {
890  case PTP_REQ_SEND:
891 
892  /* Init session params */
893  MTP_Handle->ptp.transaction_id = 0x00000000;
894  MTP_Handle->ptp.session_id = session;
895  MTP_Handle->ptp.flags = PTP_DP_NODATA;
896 
897  /* Fill operation request params */
898  ptp_container.Code = PTP_OC_OpenSession;
899  ptp_container.SessionID = session;
900  ptp_container.Transaction_ID = MTP_Handle->ptp.transaction_id ++;
901  ptp_container.Param1 = session;
902  ptp_container.Nparam = 1;
903 
904  /* convert request packet inti USB raw packet*/
905  USBH_PTP_SendRequest (phost, &ptp_container);
906 
907  /* Setup State machine and start transfer */
908  MTP_Handle->ptp.state = PTP_OP_REQUEST_STATE;
909  MTP_Handle->ptp.req_state = PTP_REQ_WAIT;
910  status = USBH_BUSY;
911 #if (USBH_USE_OS == 1)
912  osMessagePut ( phost->os_event, USBH_STATE_CHANGED_EVENT, 0);
913 #endif
914  break;
915 
916  case PTP_REQ_WAIT:
917  status = USBH_PTP_Process(phost);
918  break;
919 
920  default:
921  break;
922  }
923  return status;
924 }
925 
934  uint16_t propcode,
935  PTP_DevicePropDescTypdef* devicepropertydesc)
936 {
937  USBH_StatusTypeDef status = USBH_BUSY;
938  MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
939  PTP_ContainerTypedef ptp_container;
940  uint8_t *data = MTP_Handle->ptp.data_container.payload.data;
941  switch(MTP_Handle->ptp.req_state)
942  {
943  case PTP_REQ_SEND:
944 
945  /* Set operation request type */
946  MTP_Handle->ptp.flags = PTP_DP_GETDATA;
947  MTP_Handle->ptp.data_ptr = (uint8_t *)&(MTP_Handle->ptp.data_container);
948  MTP_Handle->ptp.data_length = 0;
949  MTP_Handle->ptp.data_packet_counter = 0;
950  MTP_Handle->ptp.data_packet = 0;
951 
952  /* Fill operation request params */
953  ptp_container.Code = PTP_OC_GetDevicePropDesc;
954  ptp_container.SessionID = MTP_Handle->ptp.session_id;
955  ptp_container.Transaction_ID = MTP_Handle->ptp.transaction_id ++;
956  ptp_container.Param1 = propcode;
957  ptp_container.Nparam = 1;
958 
959  /* convert request packet into USB raw packet*/
960  USBH_PTP_SendRequest (phost, &ptp_container);
961 
962  /* Setup State machine and start transfer */
963  MTP_Handle->ptp.state = PTP_OP_REQUEST_STATE;
964  MTP_Handle->ptp.req_state = PTP_REQ_WAIT;
965  status = USBH_BUSY;
966 #if (USBH_USE_OS == 1)
967  osMessagePut ( phost->os_event, USBH_STATE_CHANGED_EVENT, 0);
968 #endif
969  break;
970 
971  case PTP_REQ_WAIT:
972  status = USBH_PTP_Process(phost);
973 
974  if(status == USBH_OK)
975  {
976  devicepropertydesc->DevicePropertyCode = LE16(&data[PTP_dpd_DevicePropertyCode]);
977  devicepropertydesc->DataType = LE16(&data[PTP_dpd_DataType]);
978  devicepropertydesc->GetSet = *(uint8_t *)(&data[PTP_dpd_GetSet]);
979  devicepropertydesc->FormFlag = PTP_DPFF_None;
980  }
981  break;
982 
983  default:
984  break;
985  }
986  return status;
987 }
996 {
997  USBH_StatusTypeDef status = USBH_BUSY;
998  MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
999  PTP_ContainerTypedef ptp_container;
1000 
1001  switch(MTP_Handle->ptp.req_state)
1002  {
1003  case PTP_REQ_SEND:
1004 
1005  /* Set operation request type */
1006  MTP_Handle->ptp.flags = PTP_DP_GETDATA;
1007  MTP_Handle->ptp.data_ptr = (uint8_t *)&(MTP_Handle->ptp.data_container);
1008  MTP_Handle->ptp.data_length = 0;
1009  MTP_Handle->ptp.data_packet_counter = 0;
1010  MTP_Handle->ptp.data_packet = 0;
1011 
1012  /* Fill operation request params */
1013  ptp_container.Code = PTP_OC_GetDeviceInfo;
1014  ptp_container.SessionID = MTP_Handle->ptp.session_id;
1015  ptp_container.Transaction_ID = MTP_Handle->ptp.transaction_id ++;
1016  ptp_container.Nparam = 0;
1017 
1018  /* convert request packet inti USB raw packet*/
1019  USBH_PTP_SendRequest (phost, &ptp_container);
1020 
1021  /* Setup State machine and start transfer */
1022  MTP_Handle->ptp.state = PTP_OP_REQUEST_STATE;
1023  MTP_Handle->ptp.req_state = PTP_REQ_WAIT;
1024  status = USBH_BUSY;
1025 #if (USBH_USE_OS == 1)
1026  osMessagePut ( phost->os_event, USBH_STATE_CHANGED_EVENT, 0);
1027 #endif
1028  break;
1029 
1030  case PTP_REQ_WAIT:
1031  status = USBH_PTP_Process(phost);
1032 
1033  if(status == USBH_OK)
1034  {
1035  PTP_DecodeDeviceInfo (phost, dev_info);
1036  }
1037  break;
1038 
1039  default:
1040  break;
1041  }
1042  return status;
1043 }
1044 
1053 {
1054  USBH_StatusTypeDef status = USBH_BUSY;
1055  MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
1056  PTP_ContainerTypedef ptp_container;
1057 
1058  switch(MTP_Handle->ptp.req_state)
1059  {
1060  case PTP_REQ_SEND:
1061 
1062  /* Set operation request type */
1063  MTP_Handle->ptp.flags = PTP_DP_GETDATA;
1064  MTP_Handle->ptp.data_ptr = (uint8_t *)&(MTP_Handle->ptp.data_container);
1065  MTP_Handle->ptp.data_length = 0;
1066  MTP_Handle->ptp.data_packet_counter = 0;
1067  MTP_Handle->ptp.data_packet = 0;
1068 
1069  /* Fill operation request params */
1070  ptp_container.Code = PTP_OC_GetStorageIDs;
1071  ptp_container.SessionID = MTP_Handle->ptp.session_id;
1072  ptp_container.Transaction_ID = MTP_Handle->ptp.transaction_id ++;
1073  ptp_container.Nparam = 0;
1074 
1075  /* convert request packet inti USB raw packet*/
1076  USBH_PTP_SendRequest (phost, &ptp_container);
1077 
1078  /* Setup State machine and start transfer */
1079  MTP_Handle->ptp.state = PTP_OP_REQUEST_STATE;
1080  MTP_Handle->ptp.req_state = PTP_REQ_WAIT;
1081  status = USBH_BUSY;
1082 #if (USBH_USE_OS == 1)
1083  osMessagePut ( phost->os_event, USBH_STATE_CHANGED_EVENT, 0);
1084 #endif
1085  break;
1086 
1087  case PTP_REQ_WAIT:
1088  status = USBH_PTP_Process(phost);
1089 
1090  if(status == USBH_OK)
1091  {
1092  PTP_GetStorageIDs (phost, storage_ids);
1093  }
1094  break;
1095 
1096  default:
1097  break;
1098  }
1099  return status;
1100 }
1101 
1110 {
1111  USBH_StatusTypeDef status = USBH_BUSY;
1112  MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
1113  PTP_ContainerTypedef ptp_container;
1114 
1115  switch(MTP_Handle->ptp.req_state)
1116  {
1117  case PTP_REQ_SEND:
1118 
1119  /* Set operation request type */
1120  MTP_Handle->ptp.flags = PTP_DP_GETDATA;
1121  MTP_Handle->ptp.data_ptr = (uint8_t *)&(MTP_Handle->ptp.data_container);
1122  MTP_Handle->ptp.data_length = 0;
1123  MTP_Handle->ptp.data_packet_counter = 0;
1124  MTP_Handle->ptp.data_packet = 0;
1125 
1126  /* Fill operation request params */
1127  ptp_container.Code = PTP_OC_GetStorageInfo;
1128  ptp_container.SessionID = MTP_Handle->ptp.session_id;
1129  ptp_container.Transaction_ID = MTP_Handle->ptp.transaction_id ++;
1130  ptp_container.Param1 = storage_id;
1131  ptp_container.Nparam = 1;
1132 
1133  /* convert request packet inti USB raw packet*/
1134  USBH_PTP_SendRequest (phost, &ptp_container);
1135 
1136  /* Setup State machine and start transfer */
1137  MTP_Handle->ptp.state = PTP_OP_REQUEST_STATE;
1138  MTP_Handle->ptp.req_state = PTP_REQ_WAIT;
1139  status = USBH_BUSY;
1140 #if (USBH_USE_OS == 1)
1141  osMessagePut ( phost->os_event, USBH_STATE_CHANGED_EVENT, 0);
1142 #endif
1143  break;
1144 
1145  case PTP_REQ_WAIT:
1146  status = USBH_PTP_Process(phost);
1147 
1148  if(status == USBH_OK)
1149  {
1150  PTP_GetStorageInfo (phost, storage_id, storage_info);
1151  }
1152  break;
1153 
1154  default:
1155  break;
1156  }
1157  return status;
1158 }
1159 
1168  uint32_t storage_id,
1169  uint32_t objectformatcode,
1170  uint32_t associationOH,
1171  uint32_t* numobs)
1172 {
1173  USBH_StatusTypeDef status = USBH_BUSY;
1174  MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
1175  PTP_ContainerTypedef ptp_container;
1176 
1177  switch(MTP_Handle->ptp.req_state)
1178  {
1179  case PTP_REQ_SEND:
1180 
1181  /* Set operation request type */
1182  MTP_Handle->ptp.flags = PTP_DP_NODATA;
1183 
1184  /* Fill operation request params */
1185  ptp_container.Code = PTP_OC_GetNumObjects;
1186  ptp_container.SessionID = MTP_Handle->ptp.session_id;
1187  ptp_container.Transaction_ID = MTP_Handle->ptp.transaction_id ++;
1188  ptp_container.Param1 = storage_id;
1189  ptp_container.Param2 = objectformatcode;
1190  ptp_container.Param3 = associationOH;
1191  ptp_container.Nparam = 3;
1192 
1193  /* convert request packet into USB raw packet*/
1194  USBH_PTP_SendRequest (phost, &ptp_container);
1195 
1196  /* Setup State machine and start transfer */
1197  MTP_Handle->ptp.state = PTP_OP_REQUEST_STATE;
1198  MTP_Handle->ptp.req_state = PTP_REQ_WAIT;
1199  status = USBH_BUSY;
1200 #if (USBH_USE_OS == 1)
1201  osMessagePut ( phost->os_event, USBH_STATE_CHANGED_EVENT, 0);
1202 #endif
1203  break;
1204 
1205  case PTP_REQ_WAIT:
1206  status = USBH_PTP_Process(phost);
1207 
1208  if(status == USBH_OK)
1209  {
1210  *numobs = MTP_Handle->ptp.resp_container.param1;
1211  }
1212  break;
1213 
1214  default:
1215  break;
1216  }
1217  return status;
1218 }
1219 
1228  uint32_t storage_id,
1229  uint32_t objectformatcode,
1230  uint32_t associationOH,
1231  PTP_ObjectHandlesTypedef* objecthandles)
1232 {
1233  USBH_StatusTypeDef status = USBH_BUSY;
1234  MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
1235  PTP_ContainerTypedef ptp_container;
1236 
1237  switch(MTP_Handle->ptp.req_state)
1238  {
1239  case PTP_REQ_SEND:
1240 
1241  /* Set operation request type */
1242  MTP_Handle->ptp.flags = PTP_DP_GETDATA;
1243  MTP_Handle->ptp.data_ptr = (uint8_t *)&(MTP_Handle->ptp.data_container);
1244  MTP_Handle->ptp.data_length = 0;
1245  MTP_Handle->ptp.data_packet_counter = 0;
1246  MTP_Handle->ptp.data_packet = 0;
1247 
1248  /* Fill operation request params */
1249  ptp_container.Code = PTP_OC_GetObjectHandles;
1250  ptp_container.SessionID = MTP_Handle->ptp.session_id;
1251  ptp_container.Transaction_ID = MTP_Handle->ptp.transaction_id ++;
1252  ptp_container.Param1 = storage_id;
1253  ptp_container.Param2 = objectformatcode;
1254  ptp_container.Param3 = associationOH;
1255  ptp_container.Nparam = 3;
1256 
1257  /* convert request packet into USB raw packet*/
1258  USBH_PTP_SendRequest (phost, &ptp_container);
1259 
1260  /* Setup State machine and start transfer */
1261  MTP_Handle->ptp.state = PTP_OP_REQUEST_STATE;
1262  MTP_Handle->ptp.req_state = PTP_REQ_WAIT;
1263  status = USBH_BUSY;
1264 #if (USBH_USE_OS == 1)
1265  osMessagePut ( phost->os_event, USBH_STATE_CHANGED_EVENT, 0);
1266 #endif
1267  break;
1268 
1269  case PTP_REQ_WAIT:
1270  status = USBH_PTP_Process(phost);
1271 
1272  if(status == USBH_OK)
1273  {
1274  objecthandles->n = PTP_GetArray32 (objecthandles->Handler,
1275  MTP_Handle->ptp.data_container.payload.data,
1276  0);
1277  }
1278  break;
1279 
1280  default:
1281  break;
1282  }
1283  return status;
1284 }
1285 
1294  uint32_t handle,
1295  PTP_ObjectInfoTypedef* object_info)
1296 {
1297  USBH_StatusTypeDef status = USBH_BUSY;
1298  MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
1299  PTP_ContainerTypedef ptp_container;
1300 
1301  switch(MTP_Handle->ptp.req_state)
1302  {
1303  case PTP_REQ_SEND:
1304 
1305  /* Set operation request type */
1306  MTP_Handle->ptp.flags = PTP_DP_GETDATA;
1307  MTP_Handle->ptp.data_ptr = (uint8_t *)&(MTP_Handle->ptp.data_container);
1308  MTP_Handle->ptp.data_length = 0;
1309  MTP_Handle->ptp.data_packet_counter = 0;
1310  MTP_Handle->ptp.data_packet = 0;
1311 
1312  /* Fill operation request params */
1313  ptp_container.Code = PTP_OC_GetObjectInfo;
1314  ptp_container.SessionID = MTP_Handle->ptp.session_id;
1315  ptp_container.Transaction_ID = MTP_Handle->ptp.transaction_id ++;
1316  ptp_container.Param1 = handle;
1317  ptp_container.Nparam = 1;
1318 
1319  /* convert request packet into USB raw packet*/
1320  USBH_PTP_SendRequest (phost, &ptp_container);
1321 
1322  /* Setup State machine and start transfer */
1323  MTP_Handle->ptp.state = PTP_OP_REQUEST_STATE;
1324  MTP_Handle->ptp.req_state = PTP_REQ_WAIT;
1325  status = USBH_BUSY;
1326 #if (USBH_USE_OS == 1)
1327  osMessagePut ( phost->os_event, USBH_STATE_CHANGED_EVENT, 0);
1328 #endif
1329  break;
1330 
1331  case PTP_REQ_WAIT:
1332  status = USBH_PTP_Process(phost);
1333 
1334  if(status == USBH_OK)
1335  {
1336  PTP_GetObjectInfo (phost, object_info);
1337  }
1338  break;
1339 
1340  default:
1341  break;
1342  }
1343  return status;
1344 }
1345 
1354  uint32_t handle,
1355  uint32_t objectformatcode)
1356 {
1357  USBH_StatusTypeDef status = USBH_BUSY;
1358  MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
1359  PTP_ContainerTypedef ptp_container;
1360 
1361  switch(MTP_Handle->ptp.req_state)
1362  {
1363  case PTP_REQ_SEND:
1364 
1365  /* Set operation request type */
1366  MTP_Handle->ptp.flags = PTP_DP_NODATA;
1367 
1368  /* Fill operation request params */
1369  ptp_container.Code = PTP_OC_DeleteObject;
1370  ptp_container.SessionID = MTP_Handle->ptp.session_id;
1371  ptp_container.Transaction_ID = MTP_Handle->ptp.transaction_id ++;
1372  ptp_container.Param1 = handle;
1373  ptp_container.Param2 = objectformatcode;
1374  ptp_container.Nparam = 2;
1375 
1376  /* convert request packet into USB raw packet*/
1377  USBH_PTP_SendRequest (phost, &ptp_container);
1378 
1379  /* Setup State machine and start transfer */
1380  MTP_Handle->ptp.state = PTP_OP_REQUEST_STATE;
1381  MTP_Handle->ptp.req_state = PTP_REQ_WAIT;
1382  status = USBH_BUSY;
1383 #if (USBH_USE_OS == 1)
1384  osMessagePut ( phost->os_event, USBH_STATE_CHANGED_EVENT, 0);
1385 #endif
1386  break;
1387 
1388  case PTP_REQ_WAIT:
1389  status = USBH_PTP_Process(phost);
1390  break;
1391 
1392  default:
1393  break;
1394  }
1395  return status;
1396 }
1397 
1406  uint32_t handle,
1407  uint8_t *object)
1408 {
1409  USBH_StatusTypeDef status = USBH_BUSY;
1410  MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
1411  PTP_ContainerTypedef ptp_container;
1412 
1413  switch(MTP_Handle->ptp.req_state)
1414  {
1415  case PTP_REQ_SEND:
1416 
1417  /* Set operation request type */
1418  MTP_Handle->ptp.flags = PTP_DP_GETDATA;
1419  MTP_Handle->ptp.data_ptr = (uint8_t *)&(MTP_Handle->ptp.data_container);
1420  MTP_Handle->ptp.data_length = 0;
1421  MTP_Handle->ptp.data_packet_counter = 0;
1422  MTP_Handle->ptp.data_packet = 0;
1423 
1424  /* set object control params */
1425  MTP_Handle->ptp.object_ptr = object;
1426 
1427  /* Fill operation request params */
1428  ptp_container.Code = PTP_OC_GetObject;
1429  ptp_container.SessionID = MTP_Handle->ptp.session_id;
1430  ptp_container.Transaction_ID = MTP_Handle->ptp.transaction_id ++;
1431  ptp_container.Param1 = handle;
1432  ptp_container.Nparam = 1;
1433 
1434 
1435  /* convert request packet into USB raw packet*/
1436  USBH_PTP_SendRequest (phost, &ptp_container);
1437 
1438  /* Setup State machine and start transfer */
1439  MTP_Handle->ptp.state = PTP_OP_REQUEST_STATE;
1440  MTP_Handle->ptp.req_state = PTP_REQ_WAIT;
1441  status = USBH_BUSY;
1442 #if (USBH_USE_OS == 1)
1443  osMessagePut ( phost->os_event, USBH_STATE_CHANGED_EVENT, 0);
1444 #endif
1445  break;
1446 
1447  case PTP_REQ_WAIT:
1448  status = USBH_PTP_Process(phost);
1449 
1450  if(status == USBH_OK)
1451  {
1452  /* first packet is in the PTP data payload buffer */
1453  if(MTP_Handle->ptp.iteration == 0)
1454  {
1455  /* copy it to object */
1457  }
1458  }
1459  break;
1460 
1461  default:
1462  break;
1463  }
1464  return status;
1465 }
1466 
1475  uint32_t handle,
1476  uint32_t offset,
1477  uint32_t maxbytes,
1478  uint8_t *object,
1479  uint32_t *len)
1480 {
1481  USBH_StatusTypeDef status = USBH_BUSY;
1482  MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
1483  PTP_ContainerTypedef ptp_container;
1484 
1485  switch(MTP_Handle->ptp.req_state)
1486  {
1487  case PTP_REQ_SEND:
1488 
1489  /* Set operation request type */
1490  MTP_Handle->ptp.flags = PTP_DP_GETDATA;
1491  MTP_Handle->ptp.data_ptr = (uint8_t *)&(MTP_Handle->ptp.data_container);
1492  MTP_Handle->ptp.data_length = 0;
1493  MTP_Handle->ptp.data_packet_counter = 0;
1494  MTP_Handle->ptp.data_packet = 0;
1495 
1496  /* set object control params */
1497  MTP_Handle->ptp.object_ptr = object;
1498 
1499  /* Fill operation request params */
1500  ptp_container.Code = PTP_OC_GetPartialObject;
1501  ptp_container.SessionID = MTP_Handle->ptp.session_id;
1502  ptp_container.Transaction_ID = MTP_Handle->ptp.transaction_id ++;
1503  ptp_container.Param1 = handle;
1504  ptp_container.Param2 = offset;
1505  ptp_container.Param3 = maxbytes;
1506  ptp_container.Nparam = 3;
1507 
1508  /* convert request packet into USB raw packet*/
1509  USBH_PTP_SendRequest (phost, &ptp_container);
1510 
1511  /* Setup State machine and start transfer */
1512  MTP_Handle->ptp.state = PTP_OP_REQUEST_STATE;
1513  MTP_Handle->ptp.req_state = PTP_REQ_WAIT;
1514  status = USBH_BUSY;
1515 #if (USBH_USE_OS == 1)
1516  osMessagePut ( phost->os_event, USBH_STATE_CHANGED_EVENT, 0);
1517 #endif
1518  break;
1519 
1520  case PTP_REQ_WAIT:
1521  status = USBH_PTP_Process(phost);
1522 
1523  if(status == USBH_OK)
1524  {
1525  *len = MTP_Handle->ptp.resp_container.param1;
1526  /* first packet is in the PTP data payload buffer */
1527  if(MTP_Handle->ptp.iteration == 0)
1528  {
1529  /* copy it to object */
1530  USBH_memcpy(MTP_Handle->ptp.object_ptr, MTP_Handle->ptp.data_container.payload.data, *len);
1531  }
1532  }
1533  break;
1534 
1535  default:
1536  break;
1537  }
1538  return status;
1539 }
1540 
1549  uint16_t ofc,
1550  uint32_t *propnum,
1551  uint16_t *props)
1552 {
1553  USBH_StatusTypeDef status = USBH_BUSY;
1554  MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
1555  PTP_ContainerTypedef ptp_container;
1556 
1557  switch(MTP_Handle->ptp.req_state)
1558  {
1559  case PTP_REQ_SEND:
1560 
1561  /* Set operation request type */
1562  MTP_Handle->ptp.flags = PTP_DP_GETDATA;
1563  MTP_Handle->ptp.data_ptr = (uint8_t *)&(MTP_Handle->ptp.data_container);
1564  MTP_Handle->ptp.data_length = 0;
1565  MTP_Handle->ptp.data_packet_counter = 0;
1566  MTP_Handle->ptp.data_packet = 0;
1567 
1568  /* Fill operation request params */
1569  ptp_container.Code = PTP_OC_GetObjectPropsSupported;
1570  ptp_container.SessionID = MTP_Handle->ptp.session_id;
1571  ptp_container.Transaction_ID = MTP_Handle->ptp.transaction_id ++;
1572  ptp_container.Param1 = ofc;
1573  ptp_container.Nparam = 1;
1574 
1575  /* convert request packet into USB raw packet*/
1576  USBH_PTP_SendRequest (phost, &ptp_container);
1577 
1578  /* Setup State machine and start transfer */
1579  MTP_Handle->ptp.state = PTP_OP_REQUEST_STATE;
1580  MTP_Handle->ptp.req_state = PTP_REQ_WAIT;
1581  status = USBH_BUSY;
1582 #if (USBH_USE_OS == 1)
1583  osMessagePut ( phost->os_event, USBH_STATE_CHANGED_EVENT, 0);
1584 #endif
1585  break;
1586 
1587  case PTP_REQ_WAIT:
1588  status = USBH_PTP_Process(phost);
1589 
1590  if(status == USBH_OK)
1591  {
1592  *propnum = PTP_GetArray16 (props, MTP_Handle->ptp.data_container.payload.data, 0);
1593  }
1594  break;
1595 
1596  default:
1597  break;
1598  }
1599  return status;
1600 }
1601 
1610  uint16_t opc,
1611  uint16_t ofc,
1613 {
1614  USBH_StatusTypeDef status = USBH_BUSY;
1615  MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
1616  PTP_ContainerTypedef ptp_container;
1617 
1618  switch(MTP_Handle->ptp.req_state)
1619  {
1620  case PTP_REQ_SEND:
1621 
1622  /* Set operation request type */
1623  MTP_Handle->ptp.flags = PTP_DP_GETDATA;
1624  MTP_Handle->ptp.data_ptr = (uint8_t *)&(MTP_Handle->ptp.data_container);
1625  MTP_Handle->ptp.data_length = 0;
1626  MTP_Handle->ptp.data_packet_counter = 0;
1627  MTP_Handle->ptp.data_packet = 0;
1628 
1629  /* Fill operation request params */
1630  ptp_container.Code = PTP_OC_GetObjectPropDesc;
1631  ptp_container.SessionID = MTP_Handle->ptp.session_id;
1632  ptp_container.Transaction_ID = MTP_Handle->ptp.transaction_id ++;
1633  ptp_container.Param1 = opc;
1634  ptp_container.Param2 = ofc;
1635  ptp_container.Nparam = 2;
1636 
1637  /* convert request packet into USB raw packet*/
1638  USBH_PTP_SendRequest (phost, &ptp_container);
1639 
1640  /* Setup State machine and start transfer */
1641  MTP_Handle->ptp.state = PTP_OP_REQUEST_STATE;
1642  MTP_Handle->ptp.req_state = PTP_REQ_WAIT;
1643  status = USBH_BUSY;
1644 #if (USBH_USE_OS == 1)
1645  osMessagePut ( phost->os_event, USBH_STATE_CHANGED_EVENT, 0);
1646 #endif
1647  break;
1648 
1649  case PTP_REQ_WAIT:
1650  status = USBH_PTP_Process(phost);
1651 
1652  if(status == USBH_OK)
1653  {
1654  PTP_GetObjectPropDesc(phost, opd, MTP_Handle->ptp.data_length);
1655  }
1656  break;
1657 
1658  default:
1659  break;
1660  }
1661  return status;
1662 }
1663 
1672  uint32_t handle,
1673  MTP_PropertiesTypedef *pprops,
1674  uint32_t *nrofprops)
1675 {
1676  USBH_StatusTypeDef status = USBH_BUSY;
1677  MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
1678  PTP_ContainerTypedef ptp_container;
1679 
1680  switch(MTP_Handle->ptp.req_state)
1681  {
1682  case PTP_REQ_SEND:
1683 
1684  /* Set operation request type */
1685  MTP_Handle->ptp.flags = PTP_DP_GETDATA;
1686  MTP_Handle->ptp.data_ptr = (uint8_t *)&(MTP_Handle->ptp.data_container);
1687  MTP_Handle->ptp.data_length = 0;
1688  MTP_Handle->ptp.data_packet_counter = 0;
1689  MTP_Handle->ptp.data_packet = 0;
1690 
1691  /* copy first packet of the object into data container */
1693 
1694  /* Fill operation request params */
1695  ptp_container.Code = PTP_OC_GetObjPropList;
1696  ptp_container.SessionID = MTP_Handle->ptp.session_id;
1697  ptp_container.Transaction_ID = MTP_Handle->ptp.transaction_id ++;
1698  ptp_container.Param1 = handle;
1699  ptp_container.Param2 = 0x00000000U; /* 0x00000000U should be "all formats" */
1700  ptp_container.Param3 = 0xFFFFFFFFU; /* 0xFFFFFFFFU should be "all properties" */
1701  ptp_container.Param4 = 0x00000000U;
1702  ptp_container.Param5 = 0xFFFFFFFFU; /* Return full tree below the Param1 handle */
1703  ptp_container.Nparam = 5;
1704 
1705  /* convert request packet into USB raw packet*/
1706  USBH_PTP_SendRequest (phost, &ptp_container);
1707 
1708  /* Setup State machine and start transfer */
1709  MTP_Handle->ptp.state = PTP_OP_REQUEST_STATE;
1710  MTP_Handle->ptp.req_state = PTP_REQ_WAIT;
1711  status = USBH_BUSY;
1712 #if (USBH_USE_OS == 1)
1713  osMessagePut ( phost->os_event, USBH_STATE_CHANGED_EVENT, 0);
1714 #endif
1715  break;
1716 
1717  case PTP_REQ_WAIT:
1718  status = USBH_PTP_Process(phost);
1719 
1720  if(status == USBH_OK)
1721  {
1722  PTP_GetObjectPropList (phost, pprops, MTP_Handle->ptp.data_length);
1723  }
1724  break;
1725 
1726  default:
1727  break;
1728  }
1729  return status;
1730 }
1731 
1740  uint32_t handle,
1741  uint8_t *object,
1742  uint32_t size)
1743 {
1744  USBH_StatusTypeDef status = USBH_BUSY;
1745  MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
1746  PTP_ContainerTypedef ptp_container;
1747 
1748  switch(MTP_Handle->ptp.req_state)
1749  {
1750  case PTP_REQ_SEND:
1751 
1752  /* Set operation request type */
1753  MTP_Handle->ptp.flags = PTP_DP_SENDDATA;
1754  MTP_Handle->ptp.data_ptr = (uint8_t *)&(MTP_Handle->ptp.data_container);
1755  MTP_Handle->ptp.data_packet_counter = 0;
1756  MTP_Handle->ptp.data_packet = 0;
1757  MTP_Handle->ptp.iteration = 0;
1758 
1759  /* set object control params */
1760  MTP_Handle->ptp.object_ptr = object;
1761  MTP_Handle->ptp.data_length = size;
1762 
1763  /* Fill operation request params */
1764  ptp_container.Code = PTP_OC_SendObject;
1765  ptp_container.SessionID = MTP_Handle->ptp.session_id;
1766  ptp_container.Transaction_ID = MTP_Handle->ptp.transaction_id ++;
1767  ptp_container.Nparam = 0;
1768 
1769 
1770  /* convert request packet into USB raw packet*/
1771  USBH_PTP_SendRequest (phost, &ptp_container);
1772 
1773  /* Setup State machine and start transfer */
1774  MTP_Handle->ptp.state = PTP_OP_REQUEST_STATE;
1775  MTP_Handle->ptp.req_state = PTP_REQ_WAIT;
1776  status = USBH_BUSY;
1777 #if (USBH_USE_OS == 1)
1778  osMessagePut ( phost->os_event, USBH_STATE_CHANGED_EVENT, 0);
1779 #endif
1780  break;
1781 
1782  case PTP_REQ_WAIT:
1783  status = USBH_PTP_Process(phost);
1784  break;
1785 
1786  default:
1787  break;
1788  }
1789  return status;
1790 }
1811 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
1812 
1813 
1814 
USBH_StatusTypeDef USBH_PTP_GetStorageIds(USBH_HandleTypeDef *phost, PTP_StorageIDsTypedef *storage_ids)
USBH_PTP_GetStorageIds Gets device info dataset and fills deviceinfo structure.
#define PTP_si_FilesystemType
Definition: usbh_mtp_ptp.h:397
PTP_ProcessStateTypeDef state
Definition: usbh_mtp_ptp.h:305
uint32_t data_packet_counter
Definition: usbh_mtp_ptp.h:335
uint8_t Model[PTP_MAX_STR_SIZE]
Definition: usbh_mtp_ptp.h:379
uint8_t DataOutPipe
Definition: usbh_mtp.h:129
#define PTP_di_VendorExtensionDesc
Definition: usbh_mtp_ptp.h:349
PTP_RespContainerTypedef resp_container
Definition: usbh_mtp_ptp.h:309
#define PTP_oi_ImageBitDepth
Definition: usbh_mtp_ptp.h:738
Header file for usbh_mtp_ptp.c.
USBH_StatusTypeDef USBH_PTP_GetNumObjects(USBH_HandleTypeDef *phost, uint32_t storage_id, uint32_t objectformatcode, uint32_t associationOH, uint32_t *numobs)
USBH_PTP_GetNumObjects Gets device info dataset and fills deviceinfo structure.
uint8_t VolumeLabel[PTP_MAX_STR_SIZE]
Definition: usbh_mtp_ptp.h:435
#define USBH_memset
uint64_t ObjectCompressedSize
Definition: usbh_mtp_ptp.h:753
#define PTP_OPFF_Range
Definition: usbh_mtp_ptp.h:848
#define PTP_DP_NODATA
Definition: usbh_mtp_ptp.h:182
uint32_t DevicePropertiesSupported_len
Definition: usbh_mtp_ptp.h:372
#define PTP_OC_GetNumObjects
Definition: usbh_mtp_ptp.h:66
#define PTP_OC_OpenSession
Definition: usbh_mtp_ptp.h:62
uint8_t Filename[PTP_MAX_STR_SIZE]
Definition: usbh_mtp_ptp.h:765
#define PTP_oi_SequenceNumber
Definition: usbh_mtp_ptp.h:742
uint32_t EventsSupported_len
Definition: usbh_mtp_ptp.h:370
uint32_t idx
Definition: lcd_log.c:247
#define PTP_OPFF_Enumeration
Definition: usbh_mtp_ptp.h:849
#define PTP_USB_BULK_REQ_RESP_MAX_LEN
Definition: usbh_mtp_ptp.h:239
#define PTP_OC_GetObjectPropDesc
Definition: usbh_mtp_ptp.h:103
#define PTP_OC_GetDevicePropDesc
Definition: usbh_mtp_ptp.h:80
#define PTP_OC_GetObjPropList
Definition: usbh_mtp_ptp.h:106
#define PTP_oi_ParentObject
Definition: usbh_mtp_ptp.h:739
#define PTP_OC_GetObjectPropsSupported
Definition: usbh_mtp_ptp.h:102
#define PTP_di_VendorExtensionID
Definition: usbh_mtp_ptp.h:347
PTP_RequestStateTypeDef req_state
Definition: usbh_mtp_ptp.h:306
USBH_StatusTypeDef USBH_PTP_GetStorageInfo(USBH_HandleTypeDef *phost, uint32_t storage_id, PTP_StorageInfoTypedef *storage_info)
USBH_PTP_GetDeviceInfo Gets device info dataset and fills deviceinfo structure.
#define PTP_oi_ThumbFormat
Definition: usbh_mtp_ptp.h:732
USBH_StatusTypeDef USBH_BulkReceiveData(USBH_HandleTypeDef *phost, uint8_t *buff, uint16_t length, uint8_t hc_num)
USBH_BulkReceiveData Receives IN bulk packet from device.
Definition: usbh_ioreq.c:218
uint16_t OperationsSupported[PTP_SUPPORTED_OPERATIONS_NBR]
Definition: usbh_mtp_ptp.h:369
PTP_PropertyValueTypedef SupportedValue[PTP_SUPPORTED_PROPRIETIES_NBR]
Definition: usbh_mtp_ptp.h:804
#define PTP_si_AccessCapability
Definition: usbh_mtp_ptp.h:398
uint8_t DeviceVersion[PTP_MAX_STR_SIZE]
Definition: usbh_mtp_ptp.h:380
USBH_StatusTypeDef USBH_PTP_GetPartialObject(USBH_HandleTypeDef *phost, uint32_t handle, uint32_t offset, uint32_t maxbytes, uint8_t *object, uint32_t *len)
USBH_PTP_GetPartialObject Gets object partially.
#define PTP_DTC_UINT128
Definition: usbh_mtp_ptp.h:892
#define PTP_opd_ObjectPropertyCode
Definition: usbh_mtp_ptp.h:809
uint32_t data_packet
Definition: usbh_mtp_ptp.h:329
#define PTP_OC_GetPartialObject
Definition: usbh_mtp_ptp.h:87
#define PTP_DTC_INT64
Definition: usbh_mtp_ptp.h:889
PTP_PropertyValueTypedef MaximumValue
Definition: usbh_mtp_ptp.h:794
uint32_t ThumbCompressedSize
Definition: usbh_mtp_ptp.h:755
uint32_t OperationsSupported_len
Definition: usbh_mtp_ptp.h:368
uint8_t * object_ptr
Definition: usbh_mtp_ptp.h:340
#define PTP_oi_StorageID
Definition: usbh_mtp_ptp.h:728
PTP_OpContainerTypedef op_container
Definition: usbh_mtp_ptp.h:307
#define PTP_OC_GetStorageIDs
Definition: usbh_mtp_ptp.h:64
USBH_StatusTypeDef USBH_BulkSendData(USBH_HandleTypeDef *phost, uint8_t *buff, uint16_t length, uint8_t hc_num, uint8_t do_ping)
USBH_BulkSendData Sends the Bulk Packet to the device.
Definition: usbh_ioreq.c:186
PTP_HandleTypeDef ptp
Definition: usbh_mtp.h:141
#define PTP_DTC_UINT64
Definition: usbh_mtp_ptp.h:890
uint32_t USBH_LL_GetLastXferSize(USBH_HandleTypeDef *phost, uint8_t)
USBH_LL_GetLastXferSize Return the last transferred packet size.
uint8_t Manufacturer[PTP_MAX_STR_SIZE]
Definition: usbh_mtp_ptp.h:378
uint16_t EventsSupported[PTP_SUPPORTED_EVENTS_NBR]
Definition: usbh_mtp_ptp.h:371
#define PTP_DP_GETDATA
Definition: usbh_mtp_ptp.h:184
char str[PTP_MAX_STR_SIZE]
Definition: usbh_mtp_ptp.h:776
This file contains all the prototypes for the usbh_mtp.c.
uint16_t DevicePropertiesSupported[PTP_SUPPORTED_PROPRIETIES_NBR]
Definition: usbh_mtp_ptp.h:373
uint8_t VendorExtensionDesc[PTP_MAX_STR_SIZE]
Definition: usbh_mtp_ptp.h:366
#define PTP_DTC_INT32
Definition: usbh_mtp_ptp.h:887
#define PTP_USB_CONTAINER_COMMAND
Definition: usbh_mtp_ptp.h:160
#define PTP_OC_DeleteObject
Definition: usbh_mtp_ptp.h:71
#define PTP_DTC_INT16
Definition: usbh_mtp_ptp.h:885
#define PTP_USB_BULK_REQ_LEN
Definition: usbh_mtp_ptp.h:238
#define PTP_opd_FactoryDefaultValue
Definition: usbh_mtp_ptp.h:812
union PTP_ObjectPropDescTypeDef::@39 FORM
#define PTP_si_StorageType
Definition: usbh_mtp_ptp.h:396
#define PTP_oi_ImagePixWidth
Definition: usbh_mtp_ptp.h:736
MTP_InfoTypedef info
Definition: usbh_mtp.h:125
uint32_t Handler[PTP_MAX_HANDLER_NBR]
Definition: usbh_mtp_ptp.h:723
#define PTP_si_StorageDescription
Definition: usbh_mtp_ptp.h:402
#define PTP_DTC_INT8
Definition: usbh_mtp_ptp.h:883
#define PTP_USB_BULK_PAYLOAD_LEN_READ
Definition: usbh_mtp_ptp.h:237
uint16_t ImageFormats[PTP_IMAGE_FORMATS_NBR]
Definition: usbh_mtp_ptp.h:377
uint16_t DataInEpSize
Definition: usbh_mtp.h:137
#define LE16(addr)
Definition: usbh_def.h:69
#define PTP_OC_GetObjectInfo
Definition: usbh_mtp_ptp.h:68
#define PTP_oi_AssociationType
Definition: usbh_mtp_ptp.h:740
PTP_PropertyValueTypedef StepSize
Definition: usbh_mtp_ptp.h:795
#define PTP_DP_SENDDATA
Definition: usbh_mtp_ptp.h:183
USBH_StatusTypeDef USBH_PTP_GetResponse(USBH_HandleTypeDef *phost, PTP_ContainerTypedef *resp)
USBH_PTP_OpenSession Open a new session.
Definition: usbh_mtp_ptp.c:419
#define USBH_memcpy
union PTP_DataContainerTypedef::@37 payload
#define PTP_dpd_DevicePropertyCode
Definition: usbh_mtp_ptp.h:858
#define PTP_oi_ObjectFormat
Definition: usbh_mtp_ptp.h:729
USBH_StatusTypeDef USBH_PTP_GetObjectPropList(USBH_HandleTypeDef *phost, uint32_t handle, MTP_PropertiesTypedef *pprops, uint32_t *nrofprops)
USBH_PTP_GetObjectPropList Gets object partially.
#define PTP_di_VendorExtensionVersion
Definition: usbh_mtp_ptp.h:348
uint16_t CaptureFormats[PTP_CAPTURE_FORMATS_NBR]
Definition: usbh_mtp_ptp.h:375
#define PTP_OC_SendObject
Definition: usbh_mtp_ptp.h:73
#define PTP_OC_GetStorageInfo
Definition: usbh_mtp_ptp.h:65
#define PTP_opd_DataType
Definition: usbh_mtp_ptp.h:810
USBH_StatusTypeDef USBH_PTP_GetObjectHandles(USBH_HandleTypeDef *phost, uint32_t storage_id, uint32_t objectformatcode, uint32_t associationOH, PTP_ObjectHandlesTypedef *objecthandles)
USBH_PTP_GetObjectHandles Gets device info dataset and fills deviceinfo structure.
uint16_t VendorExtensionVersion
Definition: usbh_mtp_ptp.h:365
USBH_URBStateTypeDef
Definition: usbh_def.h:384
uint32_t Storage[PTP_MAX_STORAGE_UNITS_NBR]
Definition: usbh_mtp_ptp.h:390
USBH_StatusTypeDef USBH_PTP_Process(USBH_HandleTypeDef *phost)
USBH_PTP_Process The function handle the BOT protocol.
Definition: usbh_mtp_ptp.c:143
USBH_StatusTypeDef USBH_PTP_GetDevicePropDesc(USBH_HandleTypeDef *phost, uint16_t propcode, PTP_DevicePropDescTypdef *devicepropertydesc)
USBH_PTP_GetDevicePropDesc Gets object partially.
Definition: usbh_mtp_ptp.c:933
#define PTP_DPFF_None
Definition: usbh_mtp_ptp.h:842
#define PTP_OC_GetDeviceInfo
Definition: usbh_mtp_ptp.h:61
USBH_URBStateTypeDef USBH_LL_GetURBState(USBH_HandleTypeDef *phost, uint8_t)
USBH_LL_GetURBState Get a URB state from the low level driver.
#define PTP_oi_ImagePixHeight
Definition: usbh_mtp_ptp.h:737
#define PTP_oi_ThumbPixWidth
Definition: usbh_mtp_ptp.h:734
uint8_t DataInPipe
Definition: usbh_mtp.h:128
uint8_t SerialNumber[PTP_MAX_STR_SIZE]
Definition: usbh_mtp_ptp.h:381
PTP_DeviceInfoTypedef devinfo
Definition: usbh_mtp.h:115
#define PTP_oi_ProtectionStatus
Definition: usbh_mtp_ptp.h:730
#define LE32(addr)
Definition: usbh_def.h:74
PTP_PropDescEnumFormTypedef Enum
Definition: usbh_mtp_ptp.h:823
USBH_StatusTypeDef USBH_PTP_DeleteObject(USBH_HandleTypeDef *phost, uint32_t handle, uint32_t objectformatcode)
USBH_PTP_DeleteObject Delete an object.
USBH_StatusTypeDef
Definition: usbh_def.h:302
#define PTP_si_FreeSpaceInBytes
Definition: usbh_mtp_ptp.h:400
#define PTP_DTC_STR
Definition: usbh_mtp_ptp.h:907
#define USBH_DbgLog(...)
#define PTP_oi_AssociationDesc
Definition: usbh_mtp_ptp.h:741
#define PTP_oi_filenamelen
Definition: usbh_mtp_ptp.h:743
USBH_StatusTypeDef USBH_PTP_GetObjectPropDesc(USBH_HandleTypeDef *phost, uint16_t opc, uint16_t ofc, PTP_ObjectPropDescTypeDef *opd)
USBH_PTP_GetObjectPropDesc Gets object partially.
#define PTP_oi_ThumbPixHeight
Definition: usbh_mtp_ptp.h:735
#define PTP_di_StandardVersion
Definition: usbh_mtp_ptp.h:346
#define LE64(addr)
Definition: usbh_def.h:79
USBH_StatusTypeDef USBH_PTP_GetObjectPropsSupported(USBH_HandleTypeDef *phost, uint16_t ofc, uint32_t *propnum, uint16_t *props)
USBH_PTP_GetObjectPropsSupported Gets object partially.
#define PTP_OC_GetObject
Definition: usbh_mtp_ptp.h:69
#define PTP_si_MaxCapability
Definition: usbh_mtp_ptp.h:399
#define PTP_DTC_UINT16
Definition: usbh_mtp_ptp.h:886
#define PTP_dpd_GetSet
Definition: usbh_mtp_ptp.h:860
PTP_PropertyValueTypedef MinimumValue
Definition: usbh_mtp_ptp.h:793
osStatus osMessagePut(osMessageQId queue_id, uint32_t info, uint32_t millisec)
Put a Message to a Queue.
Definition: cmsis_os.c:951
uint8_t data[PTP_USB_BULK_PAYLOAD_LEN_READ]
Definition: usbh_mtp_ptp.h:284
PTP_PropDescRangeFormTypedef Range
Definition: usbh_mtp_ptp.h:824
USBH_StatusTypeDef USBH_PTP_SendObject(USBH_HandleTypeDef *phost, uint32_t handle, uint8_t *object, uint32_t size)
USBH_PTP_SendObject Send an object.
#define PTP_di_FunctionalMode
Definition: usbh_mtp_ptp.h:350
PTP_PropertyValueTypedef FactoryDefaultValue
Definition: usbh_mtp_ptp.h:819
uint16_t DataOutEpSize
Definition: usbh_mtp.h:136
#define PTP_RC_OK
Definition: usbh_mtp_ptp.h:120
USBH_StatusTypeDef USBH_PTP_OpenSession(USBH_HandleTypeDef *phost, uint32_t session)
USBH_PTP_OpenSession Open a new session.
Definition: usbh_mtp_ptp.c:882
#define PTP_OC_GetObjectHandles
Definition: usbh_mtp_ptp.h:67
USBH_ClassTypeDef * pActiveClass
Definition: usbh_def.h:458
uint32_t transaction_id
Definition: usbh_mtp_ptp.h:312
PTP_DataContainerTypedef data_container
Definition: usbh_mtp_ptp.h:308
uint8_t * data_ptr
Definition: usbh_mtp_ptp.h:323
#define PTP_oi_ThumbCompressedSize
Definition: usbh_mtp_ptp.h:733
USBH_StatusTypeDef USBH_PTP_Init(USBH_HandleTypeDef *phost)
USBH_PTP_Init The function Initializes the BOT protocol.
Definition: usbh_mtp_ptp.c:125
#define PTP_DTC_UINT8
Definition: usbh_mtp_ptp.h:884
USBH_StatusTypeDef USBH_PTP_SendRequest(USBH_HandleTypeDef *phost, PTP_ContainerTypedef *req)
USBH_PTP_OpenSession Open a new session.
Definition: usbh_mtp_ptp.c:391
#define PTP_DTC_INT128
Definition: usbh_mtp_ptp.h:891
uint8_t StorageDescription[PTP_MAX_STR_SIZE]
Definition: usbh_mtp_ptp.h:434
#define PTP_oi_ObjectCompressedSize
Definition: usbh_mtp_ptp.h:731
USBH_StatusTypeDef USBH_PTP_GetObjectInfo(USBH_HandleTypeDef *phost, uint32_t handle, PTP_ObjectInfoTypedef *object_info)
USBH_PTP_GetObjectInfo Gets objert info.
#define PTP_DTC_UINT32
Definition: usbh_mtp_ptp.h:888
USBH_StatusTypeDef USBH_PTP_GetDeviceInfo(USBH_HandleTypeDef *phost, PTP_DeviceInfoTypedef *dev_info)
USBH_PTP_GetDeviceInfo Gets device info dataset and fills deviceinfo structure.
Definition: usbh_mtp_ptp.c:995
#define PTP_di_OperationsSupported
Definition: usbh_mtp_ptp.h:351
#define PTP_dpd_DataType
Definition: usbh_mtp_ptp.h:859
#define PTP_opd_GetSet
Definition: usbh_mtp_ptp.h:811
USBH_StatusTypeDef USBH_PTP_GetObject(USBH_HandleTypeDef *phost, uint32_t handle, uint8_t *object)
USBH_PTP_GetObject Gets object.
#define PTP_si_FreeSpaceInImages
Definition: usbh_mtp_ptp.h:401