Library to allo USB PTP device to be hosted by the mbed platform
Dependents: class_project_main
PIMA15740/PIMAPropDescr.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 | 10:fc1cb68fc91e | 1 | /** |
jakowisp | 10:fc1cb68fc91e | 2 | * @file PIMAPropDesc.h |
jakowisp | 10:fc1cb68fc91e | 3 | * @brief PIMA Property Description class definition |
jakowisp | 10:fc1cb68fc91e | 4 | * @author Dwayne Dilbeck |
jakowisp | 10:fc1cb68fc91e | 5 | * @date 9/16/2013 |
jakowisp | 10:fc1cb68fc91e | 6 | * |
jakowisp | 10:fc1cb68fc91e | 7 | * mbed USBHostPTP Library(PIMA15740 String definition) |
jakowisp | 10:fc1cb68fc91e | 8 | * @par Copyright: |
jakowisp | 10:fc1cb68fc91e | 9 | * Copyright (c) 2013 Dwayne Dilbeck |
jakowisp | 10:fc1cb68fc91e | 10 | * @par License: |
jakowisp | 10:fc1cb68fc91e | 11 | * This software is distributed under the terms of the GNU Lesser General Public License |
jakowisp | 10:fc1cb68fc91e | 12 | */ |
jakowisp | 10:fc1cb68fc91e | 13 | #include "PIMADTS.h" |
jakowisp | 10:fc1cb68fc91e | 14 | |
jakowisp | 10:fc1cb68fc91e | 15 | /** |
jakowisp | 10:fc1cb68fc91e | 16 | * Class Property Description |
jakowisp | 10:fc1cb68fc91e | 17 | * |
jakowisp | 10:fc1cb68fc91e | 18 | * The PIMA15740 standard defines |
jakowisp | 10:fc1cb68fc91e | 19 | * |
jakowisp | 10:fc1cb68fc91e | 20 | */ |
jakowisp | 10:fc1cb68fc91e | 21 | class PIMAPropDesc { |
jakowisp | 10:fc1cb68fc91e | 22 | public: |
jakowisp | 10:fc1cb68fc91e | 23 | |
jakowisp | 10:fc1cb68fc91e | 24 | |
jakowisp | 10:fc1cb68fc91e | 25 | |
jakowisp | 11:3b072cf16df8 | 26 | int FillPropDesc(uint8_t *initialPtr) { |
jakowisp | 11:3b072cf16df8 | 27 | uint8_t *currentPtr = initialPtr; |
jakowisp | 11:3b072cf16df8 | 28 | |
jakowisp | 10:fc1cb68fc91e | 29 | devicePropertyCode = *((uint16_t *)currentPtr); |
jakowisp | 11:3b072cf16df8 | 30 | currentPtr+=sizeof(uint16_t); |
jakowisp | 11:3b072cf16df8 | 31 | dataType = *((uint16_t *)(currentPtr)); |
jakowisp | 11:3b072cf16df8 | 32 | currentPtr+=sizeof(uint16_t); |
jakowisp | 11:3b072cf16df8 | 33 | getSet=*((uint8_t *)(currentPtr)); |
jakowisp | 11:3b072cf16df8 | 34 | currentPtr+=sizeof(uint8_t); |
jakowisp | 11:3b072cf16df8 | 35 | currentPtr+=ParseValue(currentPtr,&factoryDefault); |
jakowisp | 11:3b072cf16df8 | 36 | currentPtr+=ParseValue(currentPtr,¤tValue); |
jakowisp | 11:3b072cf16df8 | 37 | formFlag=*((uint8_t *)(currentPtr)); |
jakowisp | 11:3b072cf16df8 | 38 | currentPtr+=sizeof(uint8_t); |
jakowisp | 11:3b072cf16df8 | 39 | |
jakowisp | 11:3b072cf16df8 | 40 | return (currentPtr-initialPtr); //TODO: Finish Fill function. |
jakowisp | 10:fc1cb68fc91e | 41 | } |
jakowisp | 10:fc1cb68fc91e | 42 | |
jakowisp | 10:fc1cb68fc91e | 43 | private: |
jakowisp | 11:3b072cf16df8 | 44 | unsigned int ParseValue(uint8_t *currentPtr, DTSUnion *DTSUnionIn){ |
jakowisp | 11:3b072cf16df8 | 45 | unsigned int result; |
jakowisp | 11:3b072cf16df8 | 46 | switch(dataType) { |
jakowisp | 11:3b072cf16df8 | 47 | case PIMA_DATATYPE_CODE_INT8: |
jakowisp | 11:3b072cf16df8 | 48 | result=fill<int8_t > ((void *)&(DTSUnionIn->signed8bitInt),currentPtr); |
jakowisp | 11:3b072cf16df8 | 49 | break; |
jakowisp | 11:3b072cf16df8 | 50 | case PIMA_DATATYPE_CODE_UINT8: |
jakowisp | 11:3b072cf16df8 | 51 | result=fill<uint8_t > ((void *)&(DTSUnionIn->unsigned8bitInt),currentPtr); |
jakowisp | 11:3b072cf16df8 | 52 | break; |
jakowisp | 11:3b072cf16df8 | 53 | case PIMA_DATATYPE_CODE_INT16: |
jakowisp | 11:3b072cf16df8 | 54 | result=fill<int16_t > ((void *)&(DTSUnionIn->signed16bitInt),currentPtr); |
jakowisp | 11:3b072cf16df8 | 55 | break; |
jakowisp | 11:3b072cf16df8 | 56 | case PIMA_DATATYPE_CODE_UINT16: |
jakowisp | 11:3b072cf16df8 | 57 | result=fill<uint16_t > ((void *)&(DTSUnionIn->unsigned16bitInt),currentPtr); |
jakowisp | 11:3b072cf16df8 | 58 | break; |
jakowisp | 11:3b072cf16df8 | 59 | case PIMA_DATATYPE_CODE_INT32: |
jakowisp | 11:3b072cf16df8 | 60 | result=fill<int32_t > ((void *)&(DTSUnionIn->signed32bitInt),currentPtr); |
jakowisp | 11:3b072cf16df8 | 61 | break; |
jakowisp | 11:3b072cf16df8 | 62 | case PIMA_DATATYPE_CODE_UINT32: |
jakowisp | 11:3b072cf16df8 | 63 | result=fill<uint32_t > ((void *)&(DTSUnionIn->signed32bitInt),currentPtr); |
jakowisp | 11:3b072cf16df8 | 64 | break; |
jakowisp | 11:3b072cf16df8 | 65 | case PIMA_DATATYPE_CODE_INT64: |
jakowisp | 11:3b072cf16df8 | 66 | result=fill<int64_t > ((void *)&(DTSUnionIn->signed64bitInt),currentPtr); |
jakowisp | 11:3b072cf16df8 | 67 | break; |
jakowisp | 11:3b072cf16df8 | 68 | case PIMA_DATATYPE_CODE_UINT64: |
jakowisp | 11:3b072cf16df8 | 69 | result=fill<uint64_t > ((void *)&(DTSUnionIn->signed64bitInt),currentPtr); |
jakowisp | 11:3b072cf16df8 | 70 | break; |
jakowisp | 11:3b072cf16df8 | 71 | case PIMA_DATATYPE_CODE_INT128: |
jakowisp | 11:3b072cf16df8 | 72 | break; |
jakowisp | 11:3b072cf16df8 | 73 | case PIMA_DATATYPE_CODE_UINT128: |
jakowisp | 11:3b072cf16df8 | 74 | break; |
jakowisp | 11:3b072cf16df8 | 75 | case PIMA_DATATYPE_CODE_AINT8: |
jakowisp | 11:3b072cf16df8 | 76 | DTSUnionIn->arraysigned8bitInt = new PIMAArray<int8_t> ; |
jakowisp | 11:3b072cf16df8 | 77 | result=DTSUnionIn->arraysigned8bitInt->FillArray(currentPtr); |
jakowisp | 11:3b072cf16df8 | 78 | break; |
jakowisp | 11:3b072cf16df8 | 79 | case PIMA_DATATYPE_CODE_AUINT8: |
jakowisp | 11:3b072cf16df8 | 80 | DTSUnionIn->arrayunsigned8bitInt = new PIMAArray<uint8_t> ; |
jakowisp | 11:3b072cf16df8 | 81 | result=DTSUnionIn->arrayunsigned8bitInt->FillArray(currentPtr); |
jakowisp | 11:3b072cf16df8 | 82 | break; |
jakowisp | 11:3b072cf16df8 | 83 | case PIMA_DATATYPE_CODE_AINT16: |
jakowisp | 11:3b072cf16df8 | 84 | DTSUnionIn->arraysigned16bitInt = new PIMAArray<int16_t> ; |
jakowisp | 11:3b072cf16df8 | 85 | result=DTSUnionIn->arraysigned16bitInt->FillArray(currentPtr); |
jakowisp | 11:3b072cf16df8 | 86 | break; |
jakowisp | 11:3b072cf16df8 | 87 | case PIMA_DATATYPE_CODE_AUINT16: |
jakowisp | 11:3b072cf16df8 | 88 | DTSUnionIn->arrayunsigned16bitInt = new PIMAArray<uint16_t> ; |
jakowisp | 11:3b072cf16df8 | 89 | result=DTSUnionIn->arrayunsigned16bitInt->FillArray(currentPtr); |
jakowisp | 11:3b072cf16df8 | 90 | break; |
jakowisp | 11:3b072cf16df8 | 91 | case PIMA_DATATYPE_CODE_AINT32: |
jakowisp | 11:3b072cf16df8 | 92 | DTSUnionIn->arraysigned32bitInt = new PIMAArray<int32_t> ; |
jakowisp | 11:3b072cf16df8 | 93 | result=DTSUnionIn->arraysigned32bitInt->FillArray(currentPtr); |
jakowisp | 11:3b072cf16df8 | 94 | break; |
jakowisp | 11:3b072cf16df8 | 95 | case PIMA_DATATYPE_CODE_AUINT32: |
jakowisp | 11:3b072cf16df8 | 96 | DTSUnionIn->arrayunsigned32bitInt = new PIMAArray<uint32_t> ; |
jakowisp | 11:3b072cf16df8 | 97 | result=DTSUnionIn->arrayunsigned32bitInt->FillArray(currentPtr); |
jakowisp | 11:3b072cf16df8 | 98 | break; |
jakowisp | 11:3b072cf16df8 | 99 | case PIMA_DATATYPE_CODE_AINT64: |
jakowisp | 11:3b072cf16df8 | 100 | DTSUnionIn->arraysigned64bitInt = new PIMAArray<int64_t> ; |
jakowisp | 11:3b072cf16df8 | 101 | result=DTSUnionIn->arraysigned64bitInt->FillArray(currentPtr); |
jakowisp | 11:3b072cf16df8 | 102 | break; |
jakowisp | 11:3b072cf16df8 | 103 | case PIMA_DATATYPE_CODE_AUINT64: |
jakowisp | 11:3b072cf16df8 | 104 | DTSUnionIn->arrayunsigned64bitInt = new PIMAArray<uint64_t> ; |
jakowisp | 11:3b072cf16df8 | 105 | result=DTSUnionIn->arrayunsigned64bitInt->FillArray(currentPtr); |
jakowisp | 11:3b072cf16df8 | 106 | break; |
jakowisp | 11:3b072cf16df8 | 107 | /* case PIMA_DATATYPE_CODE_AINT128: |
jakowisp | 11:3b072cf16df8 | 108 | break; |
jakowisp | 11:3b072cf16df8 | 109 | case PIMA_DATATYPE_CODE_AUINT128: |
jakowisp | 11:3b072cf16df8 | 110 | break; |
jakowisp | 11:3b072cf16df8 | 111 | case PIMA_DATATYPE_CODE_STR: |
jakowisp | 11:3b072cf16df8 | 112 | DTSUnionIn->ptri8 = new DTS<PIMAString>; |
jakowisp | 11:3b072cf16df8 | 113 | break; */ |
jakowisp | 11:3b072cf16df8 | 114 | default: |
jakowisp | 11:3b072cf16df8 | 115 | break; |
jakowisp | 11:3b072cf16df8 | 116 | } |
jakowisp | 11:3b072cf16df8 | 117 | return result; |
jakowisp | 11:3b072cf16df8 | 118 | } |
jakowisp | 11:3b072cf16df8 | 119 | |
jakowisp | 11:3b072cf16df8 | 120 | template<class Type> |
jakowisp | 11:3b072cf16df8 | 121 | unsigned int fill(void *targetPtr,uint8_t *ptr){ |
jakowisp | 11:3b072cf16df8 | 122 | Type temp; |
jakowisp | 11:3b072cf16df8 | 123 | |
jakowisp | 11:3b072cf16df8 | 124 | temp=*((Type *)ptr); |
jakowisp | 11:3b072cf16df8 | 125 | *((Type *)targetPtr)=temp; |
jakowisp | 11:3b072cf16df8 | 126 | |
jakowisp | 11:3b072cf16df8 | 127 | return sizeof(temp); |
jakowisp | 11:3b072cf16df8 | 128 | } |
jakowisp | 11:3b072cf16df8 | 129 | |
jakowisp | 10:fc1cb68fc91e | 130 | ///PIMA 15740:2000 Section 13, table 23 |
jakowisp | 10:fc1cb68fc91e | 131 | uint16_t devicePropertyCode; |
jakowisp | 10:fc1cb68fc91e | 132 | uint16_t dataType; |
jakowisp | 10:fc1cb68fc91e | 133 | uint8_t getSet; |
jakowisp | 11:3b072cf16df8 | 134 | DTSUnion factoryDefault; |
jakowisp | 11:3b072cf16df8 | 135 | DTSUnion currentValue; |
jakowisp | 10:fc1cb68fc91e | 136 | |
jakowisp | 10:fc1cb68fc91e | 137 | uint8_t formFlag; |
jakowisp | 10:fc1cb68fc91e | 138 | typedef union { |
jakowisp | 10:fc1cb68fc91e | 139 | struct { |
jakowisp | 11:3b072cf16df8 | 140 | DTSUnion minimumValue; |
jakowisp | 11:3b072cf16df8 | 141 | DTSUnion maximumValue; |
jakowisp | 11:3b072cf16df8 | 142 | DTSUnion stepSize; |
jakowisp | 10:fc1cb68fc91e | 143 | } rangeForm; |
jakowisp | 11:3b072cf16df8 | 144 | PIMAArray<DTSUnion> *enumerationForm; |
jakowisp | 10:fc1cb68fc91e | 145 | } FORMS; |
jakowisp | 10:fc1cb68fc91e | 146 | FORMS FORM; |
jakowisp | 10:fc1cb68fc91e | 147 | }; |