Library to allo USB PTP device to be hosted by the mbed platform
Dependents: class_project_main
PIMA15740/PIMAArray.h
- Committer:
- jakowisp
- Date:
- 2013-08-23
- Revision:
- 1:71c0e9dc153d
- Parent:
- 0:98cf19bcd828
- Child:
- 3:1fcb46ab18df
File content as of revision 1:71c0e9dc153d:
/* mbed USBHostPTP Library(PIMA15740 definitions) * Copyright (c) 2013 Dwayne Dilbeck * This software is distributed under the terms of the GNU Lesser General Public License */ /** * Class PIMA array * * * */ class PIMAArray { public: /** * Constructor * @params: None * */ PIMAArray() { numberOfElements=0; codes=NULL; }; ~PIMAArray() { if( codes !=NULL) free(codes); }; int FillArray(uint8_t *currentPtr) { SetNumberOfElements(*((uint32_t *)currentPtr)); SetCodes((uint16_t *)(currentPtr+4)); return (2*numberOfElements) + 4; } void SetNumberOfElements(uint8_t length) { this->numberOfElements=length; if( codes !=NULL) free(codes); codes = (uint16_t *) malloc(sizeof(uint16_t)*length); }; void SetCodes(uint16_t *buffer){ if(buffer!=NULL && codes !=NULL) for(int i=0;i<this->numberOfElements;i++) codes[i]=buffer[i]; }; uint32_t numberOfElements; uint16_t *codes; };