Library to allo USB PTP device to be hosted by the mbed platform
Dependents: class_project_main
USBHostPTP.h@11:3b072cf16df8, 2013-10-07 (annotated)
- Committer:
- jakowisp
- Date:
- Mon Oct 07 04:45:55 2013 +0000
- Revision:
- 11:3b072cf16df8
- Parent:
- 10:fc1cb68fc91e
Add code for Property description download.; Add code decoder logic.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jakowisp | 4:9c6f5867f050 | 1 | /** |
jakowisp | 4:9c6f5867f050 | 2 | * @file USBHostPTP.h |
jakowisp | 4:9c6f5867f050 | 3 | * @brief USBHostPTP class definition |
jakowisp | 4:9c6f5867f050 | 4 | * @author Dwayne Dilbeck |
jakowisp | 4:9c6f5867f050 | 5 | * @date 8/23/2013 |
jakowisp | 4:9c6f5867f050 | 6 | * |
jakowisp | 4:9c6f5867f050 | 7 | * mbed USBHostPTP Library |
jakowisp | 4:9c6f5867f050 | 8 | * |
jakowisp | 4:9c6f5867f050 | 9 | * @par Copyright: |
jakowisp | 4:9c6f5867f050 | 10 | * Copyright (c) 2013 Dwayne Dilbeck |
jakowisp | 4:9c6f5867f050 | 11 | * @par License: |
jakowisp | 4:9c6f5867f050 | 12 | * This software is distributed under the terms of the GNU Lesser General Public License |
jakowisp | 4:9c6f5867f050 | 13 | */ |
jakowisp | 0:98cf19bcd828 | 14 | |
jakowisp | 1:71c0e9dc153d | 15 | |
jakowisp | 0:98cf19bcd828 | 16 | #ifndef USBHOSTPTP_H |
jakowisp | 0:98cf19bcd828 | 17 | #define USBHOSTPTP_H |
jakowisp | 0:98cf19bcd828 | 18 | |
jakowisp | 0:98cf19bcd828 | 19 | #include "USBHostConf.h" |
jakowisp | 0:98cf19bcd828 | 20 | #include "USBHost.h" |
jakowisp | 0:98cf19bcd828 | 21 | #include "PIMA15740_types.h" |
jakowisp | 0:98cf19bcd828 | 22 | |
jakowisp | 0:98cf19bcd828 | 23 | //#define USDBPTPDEBUG 1 |
jakowisp | 0:98cf19bcd828 | 24 | |
jakowisp | 1:71c0e9dc153d | 25 | |
jakowisp | 0:98cf19bcd828 | 26 | |
jakowisp | 0:98cf19bcd828 | 27 | /** |
jakowisp | 0:98cf19bcd828 | 28 | * USB PTP definitions |
jakowisp | 0:98cf19bcd828 | 29 | * |
jakowisp | 0:98cf19bcd828 | 30 | */ |
jakowisp | 0:98cf19bcd828 | 31 | #define USB_PTP_CLASS_CODE 0x06 |
jakowisp | 0:98cf19bcd828 | 32 | #define USB_PTP_CLASS_REQUEST_CANCELREQEUST 0x64 |
jakowisp | 0:98cf19bcd828 | 33 | #define USB_PTP_CLASS_REQUEST_GET_EXTENDED_EVENT_DATA 0x65 |
jakowisp | 0:98cf19bcd828 | 34 | #define USB_PTP_CLASS_REQUEST_DEVICE_RESET 0x66 |
jakowisp | 0:98cf19bcd828 | 35 | #define USB_PTP_CLASS_REQUEST_GET_DEVICE_STATUS 0x67 |
jakowisp | 0:98cf19bcd828 | 36 | |
jakowisp | 1:71c0e9dc153d | 37 | //Define a data handler function pointer type to allow handler function pointeers to be readable in function definitions. |
jakowisp | 0:98cf19bcd828 | 38 | typedef void (*DataHandler)(void *object, uint8_t *bufffer, uint16_t length); |
jakowisp | 11:3b072cf16df8 | 39 | typedef bool (*CodeDecoder)(uint16_t code, char *bufffer); |
jakowisp | 0:98cf19bcd828 | 40 | |
jakowisp | 0:98cf19bcd828 | 41 | /** |
jakowisp | 0:98cf19bcd828 | 42 | * USBHostPTP class |
jakowisp | 0:98cf19bcd828 | 43 | * |
jakowisp | 0:98cf19bcd828 | 44 | */ |
jakowisp | 0:98cf19bcd828 | 45 | class USBHostPTP : public IUSBEnumerator { |
jakowisp | 0:98cf19bcd828 | 46 | public: |
jakowisp | 1:71c0e9dc153d | 47 | |
jakowisp | 1:71c0e9dc153d | 48 | /** |
jakowisp | 1:71c0e9dc153d | 49 | * Define a set of flags to make calls to execute Operations a simple wrapper. |
jakowisp | 4:9c6f5867f050 | 50 | * This structure is copied from the 'Circuits At Home' Arduino Library to match thier format. |
jakowisp | 1:71c0e9dc153d | 51 | */ |
jakowisp | 0:98cf19bcd828 | 52 | struct OperFlags |
jakowisp | 0:98cf19bcd828 | 53 | { |
jakowisp | 0:98cf19bcd828 | 54 | uint16_t opParams : 3; // 7 - maximum number of operation parameters |
jakowisp | 0:98cf19bcd828 | 55 | uint16_t rsParams : 3; // 7 - maximum number of response parameters |
jakowisp | 0:98cf19bcd828 | 56 | uint16_t txOperation : 1; // I->R operation if the flag is set |
jakowisp | 0:98cf19bcd828 | 57 | uint16_t dataStage : 1; // operation has data stage if the flag is set |
jakowisp | 1:71c0e9dc153d | 58 | uint16_t typeOfVoid : 2; // NOT USED |
jakowisp | 1:71c0e9dc153d | 59 | uint16_t dataSize : 6; // NOT USED - This is meant to be used when sending data to the PTP device |
jakowisp | 0:98cf19bcd828 | 60 | }; |
jakowisp | 0:98cf19bcd828 | 61 | |
jakowisp | 0:98cf19bcd828 | 62 | /** |
jakowisp | 0:98cf19bcd828 | 63 | * Constructor |
jakowisp | 0:98cf19bcd828 | 64 | * |
jakowisp | 0:98cf19bcd828 | 65 | * @param None |
jakowisp | 0:98cf19bcd828 | 66 | */ |
jakowisp | 0:98cf19bcd828 | 67 | USBHostPTP(void); |
jakowisp | 0:98cf19bcd828 | 68 | |
jakowisp | 0:98cf19bcd828 | 69 | /** |
jakowisp | 0:98cf19bcd828 | 70 | * Check if a PTP device is connected |
jakowisp | 0:98cf19bcd828 | 71 | * |
jakowisp | 0:98cf19bcd828 | 72 | * @return true if a PTP device is connected |
jakowisp | 0:98cf19bcd828 | 73 | */ |
jakowisp | 0:98cf19bcd828 | 74 | bool connected(); |
jakowisp | 0:98cf19bcd828 | 75 | |
jakowisp | 0:98cf19bcd828 | 76 | /** |
jakowisp | 0:98cf19bcd828 | 77 | * Try to connect to a PTP device |
jakowisp | 0:98cf19bcd828 | 78 | * |
jakowisp | 0:98cf19bcd828 | 79 | * @return true if connection was successful |
jakowisp | 0:98cf19bcd828 | 80 | */ |
jakowisp | 0:98cf19bcd828 | 81 | bool connect(); |
jakowisp | 0:98cf19bcd828 | 82 | |
jakowisp | 1:71c0e9dc153d | 83 | /** |
jakowisp | 1:71c0e9dc153d | 84 | * Cancel Request |
jakowisp | 1:71c0e9dc153d | 85 | * USB PTP class specific operation to allow cancelation of a bulk transaction |
jakowisp | 1:71c0e9dc153d | 86 | * |
jakowisp | 1:71c0e9dc153d | 87 | * @param TransactionID The idnumber of the transaction to cancel |
jakowisp | 1:71c0e9dc153d | 88 | * |
jakowisp | 1:71c0e9dc153d | 89 | * @return true if the operation was succesful |
jakowisp | 1:71c0e9dc153d | 90 | */ |
jakowisp | 0:98cf19bcd828 | 91 | bool CancelRequest(unsigned int TransactionID); |
jakowisp | 4:9c6f5867f050 | 92 | |
jakowisp | 4:9c6f5867f050 | 93 | /** |
jakowisp | 4:9c6f5867f050 | 94 | * DeviceResetRequest |
jakowisp | 4:9c6f5867f050 | 95 | * The Device Reset Request is used by the host to return the |
jakowisp | 4:9c6f5867f050 | 96 | * Still Image Capture Device to the Idle state after the Bulk-pipe |
jakowisp | 4:9c6f5867f050 | 97 | * has stalled. The request may also be used to clear any vendor specified suspend conditions. |
jakowisp | 4:9c6f5867f050 | 98 | * |
jakowisp | 4:9c6f5867f050 | 99 | * @param none |
jakowisp | 4:9c6f5867f050 | 100 | * |
jakowisp | 4:9c6f5867f050 | 101 | * @return true if the operation was succesful |
jakowisp | 4:9c6f5867f050 | 102 | */ |
jakowisp | 0:98cf19bcd828 | 103 | bool DeviceResetRequest(void); |
jakowisp | 0:98cf19bcd828 | 104 | |
jakowisp | 0:98cf19bcd828 | 105 | |
jakowisp | 4:9c6f5867f050 | 106 | /** |
jakowisp | 4:9c6f5867f050 | 107 | * GetDeviceStatus |
jakowisp | 4:9c6f5867f050 | 108 | * This request is used by the host to retrieve information needed to |
jakowisp | 4:9c6f5867f050 | 109 | * clear halted endpoints that result from a device initiated data transfer cancellation. |
jakowisp | 4:9c6f5867f050 | 110 | * |
jakowisp | 4:9c6f5867f050 | 111 | * @param none |
jakowisp | 4:9c6f5867f050 | 112 | * |
jakowisp | 4:9c6f5867f050 | 113 | * @return true if the operation was succesful |
jakowisp | 4:9c6f5867f050 | 114 | */ |
jakowisp | 4:9c6f5867f050 | 115 | bool GetDeviceStatus(void); |
jakowisp | 4:9c6f5867f050 | 116 | |
jakowisp | 4:9c6f5867f050 | 117 | /** |
jakowisp | 4:9c6f5867f050 | 118 | * GetExtendedEventData |
jakowisp | 4:9c6f5867f050 | 119 | * The data stage transfers to the host extended information regarding |
jakowisp | 4:9c6f5867f050 | 120 | * an asynchronous event or vendor condition. |
jakowisp | 4:9c6f5867f050 | 121 | * |
jakowisp | 4:9c6f5867f050 | 122 | * @param none |
jakowisp | 4:9c6f5867f050 | 123 | * |
jakowisp | 4:9c6f5867f050 | 124 | * @return true if the operation was succesful |
jakowisp | 4:9c6f5867f050 | 125 | */ |
jakowisp | 4:9c6f5867f050 | 126 | bool GetExtendedEventData(void); |
jakowisp | 4:9c6f5867f050 | 127 | |
jakowisp | 4:9c6f5867f050 | 128 | ///Provide external access to deviceInfo |
jakowisp | 0:98cf19bcd828 | 129 | DeviceInfoStruct deviceInfo; |
jakowisp | 4:9c6f5867f050 | 130 | ///provide external access to ObjectInfo |
jakowisp | 0:98cf19bcd828 | 131 | ObjectInfoStruct objectInfo; |
jakowisp | 4:9c6f5867f050 | 132 | ///provide external access to storageInfo |
jakowisp | 4:9c6f5867f050 | 133 | StorageInfoStruct storageInfo; |
jakowisp | 4:9c6f5867f050 | 134 | ///Provide a visible counter of bytes remaining during long transfers |
jakowisp | 0:98cf19bcd828 | 135 | uint32_t dataLeftToTransfer; |
jakowisp | 4:9c6f5867f050 | 136 | ///Provide a visible value of total data to transfer during long transfers |
jakowisp | 0:98cf19bcd828 | 137 | uint32_t totalDataToTransfer; |
jakowisp | 0:98cf19bcd828 | 138 | |
jakowisp | 4:9c6f5867f050 | 139 | /** |
jakowisp | 4:9c6f5867f050 | 140 | * Simple PTP operation caller which has no data stage. Any number of uint32_t params can be supplied. |
jakowisp | 4:9c6f5867f050 | 141 | * |
jakowisp | 4:9c6f5867f050 | 142 | * @param opcode The operation to send to the device for execeution |
jakowisp | 4:9c6f5867f050 | 143 | * @param nparams The number of parameters being supplied for the operation |
jakowisp | 4:9c6f5867f050 | 144 | * @param params A pointer to the paratmers array to be used. |
jakowisp | 4:9c6f5867f050 | 145 | * |
jakowisp | 4:9c6f5867f050 | 146 | * @return A PTP response code |
jakowisp | 4:9c6f5867f050 | 147 | */ |
jakowisp | 4:9c6f5867f050 | 148 | uint16_t Operation(uint16_t opcode, uint8_t nparams = 0, uint32_t *params = NULL); |
jakowisp | 4:9c6f5867f050 | 149 | |
jakowisp | 4:9c6f5867f050 | 150 | /** |
jakowisp | 4:9c6f5867f050 | 151 | * Open a new session on the PTP device, this is required before any other operations besides GetDeviceInfo can be called. |
jakowisp | 4:9c6f5867f050 | 152 | * |
jakowisp | 4:9c6f5867f050 | 153 | * @param none |
jakowisp | 4:9c6f5867f050 | 154 | * @return A PTP response code |
jakowisp | 4:9c6f5867f050 | 155 | */ |
jakowisp | 0:98cf19bcd828 | 156 | uint16_t OpenSession(); |
jakowisp | 4:9c6f5867f050 | 157 | |
jakowisp | 4:9c6f5867f050 | 158 | /** |
jakowisp | 4:9c6f5867f050 | 159 | * Close the currently open session. The PIMA standard does not allow muliptl session to be open at a time. |
jakowisp | 4:9c6f5867f050 | 160 | * |
jakowisp | 4:9c6f5867f050 | 161 | * @param none |
jakowisp | 4:9c6f5867f050 | 162 | * @return A PTP response code |
jakowisp | 4:9c6f5867f050 | 163 | */ |
jakowisp | 4:9c6f5867f050 | 164 | uint16_t CloseSession(); |
jakowisp | 4:9c6f5867f050 | 165 | |
jakowisp | 4:9c6f5867f050 | 166 | /** |
jakowisp | 4:9c6f5867f050 | 167 | * This command get the device configuration information, including the operations, porperties, and events the divce supports. |
jakowisp | 4:9c6f5867f050 | 168 | * @param none |
jakowisp | 4:9c6f5867f050 | 169 | * @return A PTP response code |
jakowisp | 4:9c6f5867f050 | 170 | */ |
jakowisp | 0:98cf19bcd828 | 171 | uint16_t GetDeviceInfo(); |
jakowisp | 4:9c6f5867f050 | 172 | |
jakowisp | 4:9c6f5867f050 | 173 | /** |
jakowisp | 4:9c6f5867f050 | 174 | * Request a device power down. |
jakowisp | 4:9c6f5867f050 | 175 | * |
jakowisp | 4:9c6f5867f050 | 176 | * @param none |
jakowisp | 4:9c6f5867f050 | 177 | * @return A PTP response code |
jakowisp | 4:9c6f5867f050 | 178 | */ |
jakowisp | 0:98cf19bcd828 | 179 | uint16_t PowerDown(); |
jakowisp | 4:9c6f5867f050 | 180 | |
jakowisp | 4:9c6f5867f050 | 181 | /** |
jakowisp | 4:9c6f5867f050 | 182 | * Execute a self test |
jakowisp | 4:9c6f5867f050 | 183 | * |
jakowisp | 4:9c6f5867f050 | 184 | * @param type (Optional) Specify the test to execute. |
jakowisp | 4:9c6f5867f050 | 185 | * @param none |
jakowisp | 4:9c6f5867f050 | 186 | * @return A PTP response code |
jakowisp | 4:9c6f5867f050 | 187 | */ |
jakowisp | 0:98cf19bcd828 | 188 | uint16_t SelfTest(uint16_t type = 0); |
jakowisp | 4:9c6f5867f050 | 189 | |
jakowisp | 4:9c6f5867f050 | 190 | /** |
jakowisp | 4:9c6f5867f050 | 191 | * Get the number of objects stored on the device |
jakowisp | 4:9c6f5867f050 | 192 | * |
jakowisp | 4:9c6f5867f050 | 193 | * @param retval a pointer to a uint32_t value , this will be set by the function to return the value |
jakowisp | 4:9c6f5867f050 | 194 | * @param storage_id Provide a way to filter by storage ID. |
jakowisp | 4:9c6f5867f050 | 195 | * @param format Provide a way to filter by format. PTP devices are not required to support filtering by format |
jakowisp | 4:9c6f5867f050 | 196 | * @param assoc Provide a way to filter by association. PTP devices are not required to support filtering by association |
jakowisp | 4:9c6f5867f050 | 197 | * @return A PTP response code |
jakowisp | 4:9c6f5867f050 | 198 | */ |
jakowisp | 0:98cf19bcd828 | 199 | uint16_t GetNumObjects(uint32_t *retval, uint32_t storage_id=0xffffffff, uint16_t format=0x0000, uint32_t assoc=0x0000); |
jakowisp | 4:9c6f5867f050 | 200 | |
jakowisp | 4:9c6f5867f050 | 201 | /** |
jakowisp | 4:9c6f5867f050 | 202 | * Get an array of file handles for the objects stored on the device |
jakowisp | 4:9c6f5867f050 | 203 | * |
jakowisp | 4:9c6f5867f050 | 204 | * @param storage_id Provide a way to filter by storage ID. |
jakowisp | 4:9c6f5867f050 | 205 | * @param format Provide a way to filter by format. PTP devices are not required to support filtering by format |
jakowisp | 4:9c6f5867f050 | 206 | * @param assoc Provide a way to filter by association. PTP devices are not required to support filtering by association |
jakowisp | 4:9c6f5867f050 | 207 | * @param parser A pointer to a function to handle the data returned from the device. If left in the default value of NULL the data is thrown away as it is recieved. |
jakowisp | 4:9c6f5867f050 | 208 | * @return A PTP response code |
jakowisp | 4:9c6f5867f050 | 209 | */ |
jakowisp | 0:98cf19bcd828 | 210 | uint16_t GetObjectHandles(uint32_t storage_id=0xffffffff, uint16_t format=0x0000, uint16_t assoc=0x0000, void *parser=NULL); |
jakowisp | 4:9c6f5867f050 | 211 | |
jakowisp | 4:9c6f5867f050 | 212 | /** |
jakowisp | 4:9c6f5867f050 | 213 | * Get information about an object |
jakowisp | 4:9c6f5867f050 | 214 | * |
jakowisp | 4:9c6f5867f050 | 215 | * @param handle the file handle of the object to get information about. |
jakowisp | 4:9c6f5867f050 | 216 | * @return A PTP response code |
jakowisp | 4:9c6f5867f050 | 217 | */ |
jakowisp | 0:98cf19bcd828 | 218 | uint16_t GetObjectInfo(uint32_t handle); |
jakowisp | 4:9c6f5867f050 | 219 | /** |
jakowisp | 4:9c6f5867f050 | 220 | * Ge a thumbnail for an object |
jakowisp | 4:9c6f5867f050 | 221 | * |
jakowisp | 4:9c6f5867f050 | 222 | * @param handle the file handle of the object. |
jakowisp | 4:9c6f5867f050 | 223 | * @param parser A pointer to a function to handle the data returned from the device. If left in the default value of NULL the data is thrown away as it is recieved. |
jakowisp | 4:9c6f5867f050 | 224 | * @return A PTP response code |
jakowisp | 4:9c6f5867f050 | 225 | */ |
jakowisp | 0:98cf19bcd828 | 226 | uint16_t GetThumb(uint32_t handle, void *parser=NULL); |
jakowisp | 4:9c6f5867f050 | 227 | /** |
jakowisp | 4:9c6f5867f050 | 228 | * |
jakowisp | 4:9c6f5867f050 | 229 | * @param handle |
jakowisp | 4:9c6f5867f050 | 230 | * @param parser A pointer to a function to handle the data returned from the device. If left in the default value of NULL the data is thrown away as it is recieved. |
jakowisp | 4:9c6f5867f050 | 231 | * @return A PTP response code |
jakowisp | 4:9c6f5867f050 | 232 | */ |
jakowisp | 0:98cf19bcd828 | 233 | uint16_t GetObject(uint32_t handle, void *parser=NULL); |
jakowisp | 4:9c6f5867f050 | 234 | /** |
jakowisp | 4:9c6f5867f050 | 235 | * |
jakowisp | 4:9c6f5867f050 | 236 | * @param parser A pointer to a function to handle the data returned from the device. If left in the default value of NULL the data is thrown away as it is recieved. |
jakowisp | 4:9c6f5867f050 | 237 | * @return A PTP response code |
jakowisp | 4:9c6f5867f050 | 238 | */ |
jakowisp | 0:98cf19bcd828 | 239 | uint16_t GetStorageIDs(void *parser=NULL); |
jakowisp | 4:9c6f5867f050 | 240 | |
jakowisp | 4:9c6f5867f050 | 241 | /** |
jakowisp | 4:9c6f5867f050 | 242 | * Obtain inforamtion about a storge. |
jakowisp | 4:9c6f5867f050 | 243 | * |
jakowisp | 4:9c6f5867f050 | 244 | * @param storage_id |
jakowisp | 4:9c6f5867f050 | 245 | * @return A PTP response code |
jakowisp | 4:9c6f5867f050 | 246 | */ |
jakowisp | 4:9c6f5867f050 | 247 | uint16_t GetStorageInfo(uint32_t storage_id); |
jakowisp | 4:9c6f5867f050 | 248 | |
jakowisp | 4:9c6f5867f050 | 249 | /** |
jakowisp | 4:9c6f5867f050 | 250 | * |
jakowisp | 4:9c6f5867f050 | 251 | * @param handle |
jakowisp | 4:9c6f5867f050 | 252 | * @param storage_id |
jakowisp | 4:9c6f5867f050 | 253 | * @param parent |
jakowisp | 4:9c6f5867f050 | 254 | * @param new_handle |
jakowisp | 4:9c6f5867f050 | 255 | * @return A PTP response code |
jakowisp | 4:9c6f5867f050 | 256 | */ |
jakowisp | 0:98cf19bcd828 | 257 | uint16_t CopyObject(uint32_t handle, uint32_t storage_id, uint32_t parent, uint32_t *new_handle); |
jakowisp | 4:9c6f5867f050 | 258 | /** |
jakowisp | 4:9c6f5867f050 | 259 | * |
jakowisp | 4:9c6f5867f050 | 260 | * @param handle |
jakowisp | 4:9c6f5867f050 | 261 | * @param format |
jakowisp | 4:9c6f5867f050 | 262 | * @return A PTP response code |
jakowisp | 4:9c6f5867f050 | 263 | */ |
jakowisp | 0:98cf19bcd828 | 264 | uint16_t DeleteObject(uint32_t handle, uint16_t format); |
jakowisp | 4:9c6f5867f050 | 265 | /** |
jakowisp | 4:9c6f5867f050 | 266 | * |
jakowisp | 4:9c6f5867f050 | 267 | * @param handle |
jakowisp | 4:9c6f5867f050 | 268 | * @param attrib |
jakowisp | 4:9c6f5867f050 | 269 | * @return A PTP response code |
jakowisp | 4:9c6f5867f050 | 270 | */ |
jakowisp | 0:98cf19bcd828 | 271 | uint16_t SetObjectProtection(uint32_t handle, uint16_t attrib); |
jakowisp | 4:9c6f5867f050 | 272 | /** |
jakowisp | 4:9c6f5867f050 | 273 | * |
jakowisp | 4:9c6f5867f050 | 274 | * @param handle |
jakowisp | 4:9c6f5867f050 | 275 | * @param storage_id |
jakowisp | 4:9c6f5867f050 | 276 | * @param parent |
jakowisp | 4:9c6f5867f050 | 277 | * @return A PTP response code |
jakowisp | 4:9c6f5867f050 | 278 | */ |
jakowisp | 0:98cf19bcd828 | 279 | uint16_t MoveObject(uint32_t handle, uint32_t storage_id, uint32_t parent); |
jakowisp | 4:9c6f5867f050 | 280 | /** |
jakowisp | 4:9c6f5867f050 | 281 | * |
jakowisp | 4:9c6f5867f050 | 282 | * @param pcode |
jakowisp | 4:9c6f5867f050 | 283 | * @param parser A pointer to a function to handle the data returned from the device. If left in the default value of NULL the data is thrown away as it is recieved. |
jakowisp | 4:9c6f5867f050 | 284 | * @return A PTP response code |
jakowisp | 4:9c6f5867f050 | 285 | */ |
jakowisp | 0:98cf19bcd828 | 286 | uint16_t GetDevicePropDesc(const uint16_t pcode, void *parser=NULL); |
jakowisp | 4:9c6f5867f050 | 287 | /** |
jakowisp | 4:9c6f5867f050 | 288 | * |
jakowisp | 4:9c6f5867f050 | 289 | * @param pcode |
jakowisp | 4:9c6f5867f050 | 290 | * @param parser A pointer to a function to handle the data returned from the device. If left in the default value of NULL the data is thrown away as it is recieved. |
jakowisp | 4:9c6f5867f050 | 291 | * @return A PTP response code |
jakowisp | 4:9c6f5867f050 | 292 | */ |
jakowisp | 0:98cf19bcd828 | 293 | uint16_t GetDevicePropValue(const uint16_t pcode, void *parser=NULL); |
jakowisp | 4:9c6f5867f050 | 294 | /** |
jakowisp | 4:9c6f5867f050 | 295 | * |
jakowisp | 4:9c6f5867f050 | 296 | * @param pcode |
jakowisp | 4:9c6f5867f050 | 297 | * @param val |
jakowisp | 4:9c6f5867f050 | 298 | * @return A PTP response code |
jakowisp | 4:9c6f5867f050 | 299 | */ |
jakowisp | 0:98cf19bcd828 | 300 | uint16_t SetDevicePropValue(uint16_t pcode, uint32_t val); |
jakowisp | 4:9c6f5867f050 | 301 | /** |
jakowisp | 4:9c6f5867f050 | 302 | * |
jakowisp | 4:9c6f5867f050 | 303 | * @param pcode |
jakowisp | 4:9c6f5867f050 | 304 | * @return A PTP response code |
jakowisp | 4:9c6f5867f050 | 305 | */ |
jakowisp | 0:98cf19bcd828 | 306 | uint16_t ResetDevicePropValue(const uint16_t pcode); |
jakowisp | 4:9c6f5867f050 | 307 | /** |
jakowisp | 4:9c6f5867f050 | 308 | * |
jakowisp | 4:9c6f5867f050 | 309 | * @param storage_id |
jakowisp | 4:9c6f5867f050 | 310 | * @param fsformat |
jakowisp | 4:9c6f5867f050 | 311 | * @return A PTP response code |
jakowisp | 4:9c6f5867f050 | 312 | */ |
jakowisp | 0:98cf19bcd828 | 313 | uint16_t FormatStore(uint32_t storage_id, uint32_t fsformat); |
jakowisp | 4:9c6f5867f050 | 314 | /** |
jakowisp | 4:9c6f5867f050 | 315 | * |
jakowisp | 4:9c6f5867f050 | 316 | * @param storage_id |
jakowisp | 4:9c6f5867f050 | 317 | * @param format |
jakowisp | 4:9c6f5867f050 | 318 | * @return A PTP response code |
jakowisp | 4:9c6f5867f050 | 319 | */ |
jakowisp | 0:98cf19bcd828 | 320 | uint16_t InitiateCapture(uint32_t storage_id, uint16_t format); |
jakowisp | 4:9c6f5867f050 | 321 | /** |
jakowisp | 4:9c6f5867f050 | 322 | * |
jakowisp | 4:9c6f5867f050 | 323 | * @param storage_id |
jakowisp | 4:9c6f5867f050 | 324 | * @param format |
jakowisp | 4:9c6f5867f050 | 325 | * @return A PTP response code |
jakowisp | 4:9c6f5867f050 | 326 | */ |
jakowisp | 0:98cf19bcd828 | 327 | uint16_t InitiateOpenCapture(uint32_t storage_id, uint16_t format); |
jakowisp | 4:9c6f5867f050 | 328 | |
jakowisp | 4:9c6f5867f050 | 329 | /** |
jakowisp | 4:9c6f5867f050 | 330 | * |
jakowisp | 4:9c6f5867f050 | 331 | * @param tran_id |
jakowisp | 4:9c6f5867f050 | 332 | * @return A PTP response code |
jakowisp | 4:9c6f5867f050 | 333 | */ |
jakowisp | 0:98cf19bcd828 | 334 | uint16_t TerminateOpenCapture(uint32_t trans_id); |
jakowisp | 4:9c6f5867f050 | 335 | |
jakowisp | 4:9c6f5867f050 | 336 | /** |
jakowisp | 4:9c6f5867f050 | 337 | * Send the contents of the deviceInfo variable via serial communication |
jakowisp | 4:9c6f5867f050 | 338 | * @param none |
jakowisp | 4:9c6f5867f050 | 339 | * @return void |
jakowisp | 4:9c6f5867f050 | 340 | */ |
jakowisp | 0:98cf19bcd828 | 341 | void DumpDeviceInfo(void); |
jakowisp | 4:9c6f5867f050 | 342 | |
jakowisp | 4:9c6f5867f050 | 343 | /** |
jakowisp | 4:9c6f5867f050 | 344 | * Send the contents of the objectInfo variable via serial communication |
jakowisp | 4:9c6f5867f050 | 345 | * @param none |
jakowisp | 4:9c6f5867f050 | 346 | * @return void |
jakowisp | 4:9c6f5867f050 | 347 | */ |
jakowisp | 0:98cf19bcd828 | 348 | void DumpObjectInfo(void); |
jakowisp | 6:124a01eaf569 | 349 | PIMAContainer dataContainer; |
jakowisp | 7:c3a16a61643f | 350 | |
jakowisp | 7:c3a16a61643f | 351 | //This is a generic function should belong to some other class or namespance. |
jakowisp | 7:c3a16a61643f | 352 | void DumpBuffer(uint8_t *buffer,uint32_t length); |
jakowisp | 11:3b072cf16df8 | 353 | void (*LookupCodeStringFunctionPointer)(uint16_t value,char *stringValue); |
jakowisp | 11:3b072cf16df8 | 354 | |
jakowisp | 11:3b072cf16df8 | 355 | CodeDecoder CodeDecoderFunction; |
jakowisp | 0:98cf19bcd828 | 356 | |
jakowisp | 7:c3a16a61643f | 357 | //protected: |
jakowisp | 0:98cf19bcd828 | 358 | //From IUSBEnumerator |
jakowisp | 0:98cf19bcd828 | 359 | virtual void setVidPid(uint16_t vid, uint16_t pid); |
jakowisp | 0:98cf19bcd828 | 360 | virtual bool parseInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol); //Must return true if the interface should be parsed |
jakowisp | 0:98cf19bcd828 | 361 | virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used |
jakowisp | 0:98cf19bcd828 | 362 | |
jakowisp | 7:c3a16a61643f | 363 | void DumpResponseContainer(void); |
jakowisp | 11:3b072cf16df8 | 364 | void PrintCodeInformation(uint16_t value); |
jakowisp | 0:98cf19bcd828 | 365 | |
jakowisp | 7:c3a16a61643f | 366 | //private: |
jakowisp | 0:98cf19bcd828 | 367 | USBHost * host; |
jakowisp | 0:98cf19bcd828 | 368 | USBDeviceConnected * pointerToDevice; |
jakowisp | 0:98cf19bcd828 | 369 | bool deviceFound; |
jakowisp | 0:98cf19bcd828 | 370 | bool deviceConnected; |
jakowisp | 0:98cf19bcd828 | 371 | USBEndpoint * bulk_in; |
jakowisp | 0:98cf19bcd828 | 372 | USBEndpoint * bulk_out; |
jakowisp | 0:98cf19bcd828 | 373 | USBEndpoint * int_in; |
jakowisp | 0:98cf19bcd828 | 374 | uint8_t numberOfEndpoints; |
jakowisp | 0:98cf19bcd828 | 375 | |
jakowisp | 0:98cf19bcd828 | 376 | PIMAContainer commandContainer; |
jakowisp | 0:98cf19bcd828 | 377 | PIMAContainer responseContainer; |
jakowisp | 6:124a01eaf569 | 378 | //PIMAContainer dataContainer; |
jakowisp | 0:98cf19bcd828 | 379 | PIMAContainer eventContainer; |
jakowisp | 11:3b072cf16df8 | 380 | PIMAPropDesc propertyDescription; |
jakowisp | 1:71c0e9dc153d | 381 | uint32_t transactionCnt; |
jakowisp | 1:71c0e9dc153d | 382 | uint32_t sessionID; |
jakowisp | 0:98cf19bcd828 | 383 | uint8_t buffer[1024]; |
jakowisp | 0:98cf19bcd828 | 384 | int ptp_intf; |
jakowisp | 0:98cf19bcd828 | 385 | |
jakowisp | 0:98cf19bcd828 | 386 | void initializeClassData(); |
jakowisp | 0:98cf19bcd828 | 387 | int checkResult(uint8_t res, USBEndpoint * ep); |
jakowisp | 0:98cf19bcd828 | 388 | bool IsCommandSupported(uint16_t opcode); |
jakowisp | 0:98cf19bcd828 | 389 | bool IsPropertySupported(uint16_t code); |
jakowisp | 0:98cf19bcd828 | 390 | bool CheckEvent(void); |
jakowisp | 0:98cf19bcd828 | 391 | static void ParseDeviceInfoDataBlock(void *ptp, uint8_t *buffer,uint16_t length); |
jakowisp | 0:98cf19bcd828 | 392 | static void ParseObjectInfoDataBlock(void *ptp, uint8_t *buffer,uint16_t length); |
jakowisp | 4:9c6f5867f050 | 393 | static void ParseStorageInfoDataBlock(void *ptp, uint8_t *buffer,uint16_t length); |
jakowisp | 10:fc1cb68fc91e | 394 | static void ParseDevicePropDescrBlock(void *ptp,uint8_t *buffer,uint16_t length); |
jakowisp | 5:728b5d58e135 | 395 | void PrepareControlContainer(uint16_t operationCode, |
jakowisp | 5:728b5d58e135 | 396 | OperFlags *operationFlags, |
jakowisp | 5:728b5d58e135 | 397 | uint32_t *parameters); |
jakowisp | 5:728b5d58e135 | 398 | bool RecieveDataContainer(void *dataHandlerFunctionCastToVoid, uint16_t *responseCode); |
jakowisp | 9:961c3357504d | 399 | bool SendDataContainer(void *dataGeneratorFunctionCastToVoid, uint16_t *responseCode); |
jakowisp | 1:71c0e9dc153d | 400 | uint16_t Transaction(uint16_t operationCode, OperFlags *flags, uint32_t *params = NULL, void *pVoid = NULL); |
jakowisp | 1:71c0e9dc153d | 401 | |
jakowisp | 0:98cf19bcd828 | 402 | }; |
jakowisp | 0:98cf19bcd828 | 403 | |
jakowisp | 0:98cf19bcd828 | 404 | #endif |
jakowisp | 0:98cf19bcd828 | 405 | |
jakowisp | 0:98cf19bcd828 | 406 | |
jakowisp | 0:98cf19bcd828 | 407 | |
jakowisp | 0:98cf19bcd828 | 408 |