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

Fork of STM32_USBDevice by Bradley Scott

Revision:
68:f8305faf7917
Parent:
67:6099ce7e71c9
Child:
70:b17ecdbfb0ce
--- a/USBDevice/USBHAL_STM32L1.cpp	Mon Oct 24 17:40:10 2016 +0100
+++ b/USBDevice/USBHAL_STM32L1.cpp	Tue Nov 22 11:16:27 2016 +0000
@@ -57,7 +57,7 @@
 USBHAL * USBHAL::instance;
 uint32_t USBHAL::endpointReadcore(uint8_t endpoint, uint8_t *buffer) {return 0;}
 
-USBHAL::USBHAL(void) {
+USBHAL::USBHAL(void) : PktBufArea(512) {
     #if defined(TARGET_STM32F3)
         // Configure USB pins
         pin_function(PA_11, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF14_USB));
@@ -112,28 +112,6 @@
     HAL_PCD_SetAddress(&hpcd_USB_FS, address);
 }
 
-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;
-} PktBufArea(512);
-
 bool USBHAL::realiseEndpoint(uint8_t endpoint, uint32_t maxPacket, uint32_t flags) {
     int pmaadress = PktBufArea.allocBuf(maxPacket);
     MBED_ASSERT(pmaadress != 0);