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

Dependents:   class_project_main

Revision:
0:98cf19bcd828
Child:
1:71c0e9dc153d
diff -r 000000000000 -r 98cf19bcd828 PIMA15740/PIMAArray.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PIMA15740/PIMAArray.h	Fri Aug 23 00:52:52 2013 +0000
@@ -0,0 +1,48 @@
+
+#include "mallocdebug.h"
+
+/**
+*  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;
+};