Library to allo USB PTP device to be hosted by the mbed platform

Dependents:   class_project_main

Revision:
1:71c0e9dc153d
Parent:
0:98cf19bcd828
Child:
4:9c6f5867f050
--- a/USBHostPTP.h	Fri Aug 23 00:52:52 2013 +0000
+++ b/USBHostPTP.h	Fri Aug 23 19:34:59 2013 +0000
@@ -1,19 +1,9 @@
-/* mbed USBHost Library
- * Copyright (c) 2006-2013 ARM Limited
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+/* mbed USBHostPTP Library
+ * Copyright (c) 2013 Dwayne Dilbeck
+ * This software is distributed under the terms of the GNU Lesser General Public License
  */
 
+
 #ifndef USBHOSTPTP_H
 #define USBHOSTPTP_H
 
@@ -23,13 +13,7 @@
 
 //#define USDBPTPDEBUG 1
 
-    #ifdef USDBPTPDEBUG
-    #define PTPTRACE(s) (Notify((s))
-    #define PTPTRACE2(s,r) (Message((s),(r))
-    #else
-    #define PTPTRACE(s) ((void)0)
-    #define PTPTRACE2(s,r) (wait_us(1))
-    #endif
+ 
     
 /** 
  * USB PTP definitions
@@ -41,7 +25,7 @@
 #define USB_PTP_CLASS_REQUEST_DEVICE_RESET            0x66
 #define USB_PTP_CLASS_REQUEST_GET_DEVICE_STATUS       0x67
 
-
+//Define a data handler function pointer type to allow handler function pointeers to be readable in function definitions.
 typedef void (*DataHandler)(void *object, uint8_t *bufffer, uint16_t length);
 
 /**
@@ -50,14 +34,19 @@
  */        
 class USBHostPTP : public IUSBEnumerator {
 public:
+
+   /**
+    * Define a set of flags to make calls to execute Operations a simple wrapper.  
+    * This copied from the Circuits At Home Arduino Library to match thier format.
+    */
    struct OperFlags
         {
                 uint16_t        opParams        :       3;                      // 7    - maximum number of operation parameters
                 uint16_t        rsParams        :       3;                      // 7    - maximum number of response parameters
                 uint16_t        txOperation     :       1;                      // I->R operation if the flag is set
                 uint16_t        dataStage       :       1;                      // operation has data stage if the flag is set
-                uint16_t        typeOfVoid      :       2;                      // 0 - NULL, 1 - PTPReadParser/PTPDataSupplyer, 2 - WRITEPARSER, 3 - buffer pointer
-                uint16_t        dataSize        :       6;                      // size of data buffer (64 bytes maximum)               
+                uint16_t        typeOfVoid      :       2;                      // NOT USED
+                uint16_t        dataSize        :       6;                      // NOT USED - This is meant to be used when sending data to the PTP device               
         };     
 
     /**
@@ -81,14 +70,19 @@
      */
     bool connect();
 
+    /**
+     *  Cancel Request
+     *  USB PTP class specific operation to allow cancelation of a bulk transaction
+     *
+     *  @param TransactionID  The idnumber of the transaction to cancel
+     *
+     *  @return true if the operation was succesful
+     */
     bool CancelRequest(unsigned int TransactionID);
     bool DeviceResetRequest(void);
     bool GetDeviceStatus(void);
     bool GetExtendedEventData(void);
     
-    uint16_t Transaction(uint16_t operationCode, OperFlags *flags, uint32_t *params = NULL, void *pVoid = NULL);
-    uint32_t transactionCnt;
-    uint32_t sessionID;
     
     DeviceInfoStruct deviceInfo;
     ObjectInfoStruct objectInfo;
@@ -149,6 +143,8 @@
     PIMAContainer      responseContainer;
     PIMAContainer      dataContainer;
     PIMAContainer      eventContainer;
+    uint32_t           transactionCnt;
+    uint32_t           sessionID;
     uint8_t            buffer[1024];
     int                ptp_intf;
     
@@ -160,6 +156,8 @@
     bool CheckEvent(void);
     static void ParseDeviceInfoDataBlock(void *ptp, uint8_t *buffer,uint16_t length); 
     static void ParseObjectInfoDataBlock(void *ptp, uint8_t *buffer,uint16_t length);
+    uint16_t Transaction(uint16_t operationCode, OperFlags *flags, uint32_t *params = NULL, void *pVoid = NULL);
+
 };
 
 #endif