Library to allo USB PTP device to be hosted by the mbed platform
Dependents: class_project_main
Revision 9:961c3357504d, committed 2013-09-10
- Comitter:
- jakowisp
- Date:
- Tue Sep 10 07:40:44 2013 +0000
- Parent:
- 8:5f6024e68aa7
- Child:
- 10:fc1cb68fc91e
- Commit message:
- milestone: Image taken by camera remotely.
Changed in this revision
USBHostPTP.cpp | Show annotated file Show diff for this revision Revisions of this file |
USBHostPTP.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/USBHostPTP.cpp Tue Sep 03 07:08:56 2013 +0000 +++ b/USBHostPTP.cpp Tue Sep 10 07:40:44 2013 +0000 @@ -321,10 +321,32 @@ this->dataLeftToTransfer = bytesRemaining; #ifdef USDBPTPDEBUG printf("Loopcheck: %ld\r\n",bytesRemaining); - #endif + #endif } while( bytesRemaining>0 ); return true; -} +} + +bool USBHostPTP::SendDataContainer(void *dataGeneratorFunctionCastToVoid, uint16_t *responseCode){ + + uint32_t *length; + int transferResult=0; + + length=(uint32_t *)dataGeneratorFunctionCastToVoid; + + *responseCode=PIMA_RETURN_CODE_Undefined; + if (*length > 1024-0xc) { + printf("Multiple block DataOut not coded\r\n"); + } else { + transferResult = this->host->bulkWrite(this->pointerToDevice, + this->bulk_out, + (uint8_t *)dataGeneratorFunctionCastToVoid, + *length); + if (checkResult(transferResult, this->bulk_out)) + *responseCode= PIMA_RETURN_CODE_GeneralError; + } + return true; +} + uint16_t USBHostPTP::Transaction(uint16_t operationCode, OperFlags *operationFlags, @@ -358,7 +380,12 @@ return responseCode; } } else { - printf("DataOut not coded\r\n"); + if ( SendDataContainer(dataHandlerFunctionCastToVoid,&responseCode) != true ) { + return PIMA_RETURN_CODE_GeneralError; + } else { + if (responseCode != PIMA_RETURN_CODE_Undefined) + return responseCode; + } } } transferResult = host->bulkRead(pointerToDevice, bulk_in,(uint8_t *)&responseContainer, sizeof(responseContainer)); @@ -580,15 +607,20 @@ { OperFlags flags = { 1, 0, 1, 1, 3, 4 }; uint32_t params[1]; - uint32_t value; + + params[0]=pcode; - params[0] = (uint32_t)pcode; - value = val; + this->dataContainer.length=0x10; + this->dataContainer.type=0x0002; + this->dataContainer.code=PIMA_OPERATION_CODE_SetDevicePropValue; + this->dataContainer.transactionID=this->transactionCnt+1; + this->dataContainer.payload[0]=val; + if(IsPropertySupported(pcode)==false) return PIMA_RETURN_CODE_DevicePropertyNotSupported; - return Transaction(PIMA_OPERATION_CODE_SetDevicePropValue, &flags, params, (void*)&value); + return Transaction(PIMA_OPERATION_CODE_SetDevicePropValue, &flags, params, (void*)&(this->dataContainer)); }
--- a/USBHostPTP.h Tue Sep 03 07:08:56 2013 +0000 +++ b/USBHostPTP.h Tue Sep 10 07:40:44 2013 +0000 @@ -390,6 +390,7 @@ OperFlags *operationFlags, uint32_t *parameters); bool RecieveDataContainer(void *dataHandlerFunctionCastToVoid, uint16_t *responseCode); + bool SendDataContainer(void *dataGeneratorFunctionCastToVoid, uint16_t *responseCode); uint16_t Transaction(uint16_t operationCode, OperFlags *flags, uint32_t *params = NULL, void *pVoid = NULL); };