Fork of https://developer.mbed.org/users/bscott/code/STM32_USBDevice/

Fork of STM32_USBDevice by Bradley Scott

Revision:
68:f8305faf7917
Parent:
66:b129e98ab7a0
Child:
72:e23cba70dd77
--- a/USBDevice/USBHAL.h	Mon Oct 24 17:40:10 2016 +0100
+++ b/USBDevice/USBHAL.h	Tue Nov 22 11:16:27 2016 +0000
@@ -124,6 +124,31 @@
     void DataOutStageCallback(uint8_t epnum);
     void ResetCallback();
     void SOFCallback();
+
+private:
+    class PacketBufferAreaManager {
+    public:
+        PacketBufferAreaManager(int bufsize_):bufsize(bufsize_) {
+            reset();
+        }
+        void reset() { 
+            head = 0; 
+            tail = bufsize; 
+        }
+        int allocBuf(int maxPacketSize) {
+            head += 4;
+            tail -= maxPacketSize;
+            if (tail < head) {
+                return 0;
+            }
+            return tail;
+        }
+    private:
+        int head,tail;
+        int bufsize;
+    };
+    
+    PacketBufferAreaManager PktBufArea;
 #endif // TARGET_STM32L1
 };
 #endif