Library to allo USB PTP device to be hosted by the mbed platform
Dependents: class_project_main
PIMA15740/PIMAArray.h@1:71c0e9dc153d, 2013-08-23 (annotated)
- Committer:
- jakowisp
- Date:
- Fri Aug 23 19:34:59 2013 +0000
- Revision:
- 1:71c0e9dc153d
- Parent:
- 0:98cf19bcd828
- Child:
- 3:1fcb46ab18df
Inital publication to begin documentation
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jakowisp | 1:71c0e9dc153d | 1 | /* mbed USBHostPTP Library(PIMA15740 definitions) |
jakowisp | 1:71c0e9dc153d | 2 | * Copyright (c) 2013 Dwayne Dilbeck |
jakowisp | 1:71c0e9dc153d | 3 | * This software is distributed under the terms of the GNU Lesser General Public License |
jakowisp | 1:71c0e9dc153d | 4 | */ |
jakowisp | 0:98cf19bcd828 | 5 | |
jakowisp | 0:98cf19bcd828 | 6 | |
jakowisp | 0:98cf19bcd828 | 7 | /** |
jakowisp | 0:98cf19bcd828 | 8 | * Class PIMA array |
jakowisp | 0:98cf19bcd828 | 9 | * |
jakowisp | 0:98cf19bcd828 | 10 | * |
jakowisp | 0:98cf19bcd828 | 11 | * |
jakowisp | 0:98cf19bcd828 | 12 | */ |
jakowisp | 0:98cf19bcd828 | 13 | class PIMAArray { |
jakowisp | 0:98cf19bcd828 | 14 | public: |
jakowisp | 0:98cf19bcd828 | 15 | /** |
jakowisp | 0:98cf19bcd828 | 16 | * Constructor |
jakowisp | 0:98cf19bcd828 | 17 | * @params: None |
jakowisp | 0:98cf19bcd828 | 18 | * |
jakowisp | 0:98cf19bcd828 | 19 | */ |
jakowisp | 0:98cf19bcd828 | 20 | PIMAArray() { |
jakowisp | 0:98cf19bcd828 | 21 | numberOfElements=0; |
jakowisp | 0:98cf19bcd828 | 22 | codes=NULL; |
jakowisp | 0:98cf19bcd828 | 23 | }; |
jakowisp | 0:98cf19bcd828 | 24 | |
jakowisp | 0:98cf19bcd828 | 25 | ~PIMAArray() { |
jakowisp | 0:98cf19bcd828 | 26 | if( codes !=NULL) |
jakowisp | 0:98cf19bcd828 | 27 | free(codes); |
jakowisp | 0:98cf19bcd828 | 28 | }; |
jakowisp | 0:98cf19bcd828 | 29 | |
jakowisp | 0:98cf19bcd828 | 30 | int FillArray(uint8_t *currentPtr) { |
jakowisp | 0:98cf19bcd828 | 31 | SetNumberOfElements(*((uint32_t *)currentPtr)); |
jakowisp | 0:98cf19bcd828 | 32 | SetCodes((uint16_t *)(currentPtr+4)); |
jakowisp | 0:98cf19bcd828 | 33 | return (2*numberOfElements) + 4; |
jakowisp | 0:98cf19bcd828 | 34 | } |
jakowisp | 0:98cf19bcd828 | 35 | |
jakowisp | 0:98cf19bcd828 | 36 | void SetNumberOfElements(uint8_t length) { |
jakowisp | 0:98cf19bcd828 | 37 | this->numberOfElements=length; |
jakowisp | 0:98cf19bcd828 | 38 | if( codes !=NULL) |
jakowisp | 0:98cf19bcd828 | 39 | free(codes); |
jakowisp | 0:98cf19bcd828 | 40 | codes = (uint16_t *) malloc(sizeof(uint16_t)*length); |
jakowisp | 0:98cf19bcd828 | 41 | }; |
jakowisp | 0:98cf19bcd828 | 42 | |
jakowisp | 0:98cf19bcd828 | 43 | void SetCodes(uint16_t *buffer){ |
jakowisp | 0:98cf19bcd828 | 44 | if(buffer!=NULL && codes !=NULL) |
jakowisp | 0:98cf19bcd828 | 45 | for(int i=0;i<this->numberOfElements;i++) |
jakowisp | 0:98cf19bcd828 | 46 | codes[i]=buffer[i]; |
jakowisp | 0:98cf19bcd828 | 47 | }; |
jakowisp | 0:98cf19bcd828 | 48 | |
jakowisp | 0:98cf19bcd828 | 49 | uint32_t numberOfElements; |
jakowisp | 0:98cf19bcd828 | 50 | uint16_t *codes; |
jakowisp | 0:98cf19bcd828 | 51 | }; |
jakowisp | 1:71c0e9dc153d | 52 |