Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of USBDevice by
Diff: USBDevice/USBHAL_KL25Z.cpp
- Revision:
- 24:96a0946caef5
- Parent:
- 23:c7639faed2eb
- Child:
- 25:f0299e22d4c0
--- a/USBDevice/USBHAL_KL25Z.cpp	Mon Apr 28 12:15:41 2014 +0000
+++ b/USBDevice/USBHAL_KL25Z.cpp	Tue May 06 18:09:48 2014 +0000
@@ -66,8 +66,7 @@
 //    * 16 bidirectionnal endpt -> 32 physical endpt
 //    * as there are ODD and EVEN buffer -> 32*2 bdt
 __attribute__((__aligned__(512))) BDT bdt[NUMBER_OF_PHYSICAL_ENDPOINTS * 2];
-uint8_t * endpoint_buffer[(NUMBER_OF_PHYSICAL_ENDPOINTS - 2) * 2];
-uint8_t * endpoint_buffer_iso[2*2];
+uint8_t endpoint_buffer[(NUMBER_OF_PHYSICAL_ENDPOINTS - 2) * 2][64];
 
 static uint8_t set_addr = 0;
 static uint8_t addr = 0;
@@ -172,16 +171,6 @@
     USB0->CTL &= ~USB_CTL_USBENSOFEN_MASK;
     // Pull up disable
     USB0->CONTROL &= ~USB_CONTROL_DPPULLUPNONOTG_MASK;
-
-    //Free buffers if required:
-    for (int i = 0; i<(NUMBER_OF_PHYSICAL_ENDPOINTS - 2) * 2; i++) {
-        free(endpoint_buffer[i]);
-        endpoint_buffer[i] = NULL;
-    }
-    free(endpoint_buffer_iso[2]);
-    endpoint_buffer_iso[2] = NULL;
-    free(endpoint_buffer_iso[0]);
-    endpoint_buffer_iso[0] = NULL;
 }
 
 void USBHAL::configureDevice(void) {
@@ -212,25 +201,10 @@
 
     if ((flags & ISOCHRONOUS) == 0) {
         handshake_flag = USB_ENDPT_EPHSHK_MASK;
-        if (IN_EP(endpoint)) {
-            if (endpoint_buffer[EP_BDT_IDX(log_endpoint, TX, ODD)] == NULL)
-                endpoint_buffer[EP_BDT_IDX(log_endpoint, TX, ODD)] = (uint8_t *) malloc (64*2);
-            buf = &endpoint_buffer[EP_BDT_IDX(log_endpoint, TX, ODD)][0];
-        } else {
-            if (endpoint_buffer[EP_BDT_IDX(log_endpoint, RX, ODD)] == NULL)
-                endpoint_buffer[EP_BDT_IDX(log_endpoint, RX, ODD)] = (uint8_t *) malloc (64*2);
-            buf = &endpoint_buffer[EP_BDT_IDX(log_endpoint, RX, ODD)][0];
-        }
-    } else {
-        if (IN_EP(endpoint)) {
-            if (endpoint_buffer_iso[2] == NULL)
-                endpoint_buffer_iso[2] = (uint8_t *) malloc (1023*2);
-            buf = &endpoint_buffer_iso[2][0];
-        } else {
-            if (endpoint_buffer_iso[0] == NULL)
-                endpoint_buffer_iso[0] = (uint8_t *) malloc (1023*2);
-            buf = &endpoint_buffer_iso[0][0];
-        }
+        if (IN_EP(endpoint))
+            buf = &endpoint_buffer[EP_BDT_IDX(log_endpoint, TX, ODD )][0];
+        else
+            buf = &endpoint_buffer[EP_BDT_IDX(log_endpoint, RX, ODD )][0];
     }
 
     // IN endpt -> device to host (TX)
@@ -297,7 +271,6 @@
 
 EP_STATUS USBHAL::endpointReadResult(uint8_t endpoint, uint8_t * buffer, uint32_t *bytesRead) {
     uint32_t n, sz, idx, setup = 0;
-    uint8_t not_iso;
     uint8_t * ep_buf;
 
     uint32_t log_endpoint = PHY_TO_LOG(endpoint);
@@ -313,10 +286,9 @@
 
     idx = EP_BDT_IDX(log_endpoint, RX, 0);
     sz  = bdt[idx].byte_count;
-    not_iso = USB0->ENDPOINT[log_endpoint].ENDPT & USB_ENDPT_EPHSHK_MASK;
 
     //for isochronous endpoint, we don't wait an interrupt
-    if ((log_endpoint != 0) && not_iso && !(epComplete & EP(endpoint))) {
+    if ((log_endpoint != 0) && !(epComplete & EP(endpoint))) {
         return EP_PENDING;
     }
 
@@ -325,11 +297,7 @@
     }
 
     // non iso endpoint
-    if (not_iso) {
-        ep_buf = endpoint_buffer[idx];
-    } else {
-        ep_buf = endpoint_buffer_iso[0];
-    }
+    ep_buf = endpoint_buffer[idx];
 
     for (n = 0; n < sz; n++) {
         buffer[n] = ep_buf[n];
@@ -374,11 +342,7 @@
 
 
     // non iso endpoint
-    if (USB0->ENDPOINT[PHY_TO_LOG(endpoint)].ENDPT & USB_ENDPT_EPHSHK_MASK) {
-        ep_buf = endpoint_buffer[idx];
-    } else {
-        ep_buf = endpoint_buffer_iso[2];
-    }
+    ep_buf = endpoint_buffer[idx];
 
     for (n = 0; n < size; n++) {
         ep_buf[n] = data[n];
    