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

Dependents:   class_project_main

Committer:
jakowisp
Date:
Wed Aug 28 03:25:53 2013 +0000
Revision:
4:9c6f5867f050
Parent:
1:71c0e9dc153d
Child:
5:728b5d58e135
Documentation and initial publishing;

Who changed what in which revision?

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