Pinscape Controller version 1 fork. This is a fork to allow for ongoing bug fixes to the original controller version, from before the major changes for the expansion board project.

Dependencies:   FastIO FastPWM SimpleDMA mbed

Fork of Pinscape_Controller by Mike R

Files at this revision

API Documentation at this revision

Comitter:
mjr
Date:
Fri Feb 12 21:46:21 2016 +0000
Parent:
64:d839d8c94950
Child:
66:cbb142cbf426
Child:
68:edfecf67a931
Commit message:
Tweaks to EP0 stall handling - check to see if it fixes compatibility problem

Changed in this revision

USBDevice/USBDevice/USBHAL_KL25Z.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/USBDevice/USBDevice/USBHAL_KL25Z.cpp	Thu Feb 11 23:35:00 2016 +0000
+++ b/USBDevice/USBDevice/USBHAL_KL25Z.cpp	Fri Feb 12 21:46:21 2016 +0000
@@ -545,11 +545,26 @@
 {
     ENTER_CRITICAL_SECTION
     {
+        // clear the stall bit in the endpoint register
         USB0->ENDPOINT[PHY_TO_LOG(endpoint)].ENDPT &= ~USB_ENDPT_EPSTALL_MASK;
+        
+        // take ownership of the BDT entry
         int idx = PEP_BDT_IDX(endpoint, 0);
         bdt[idx].info &= ~(BD_OWN_MASK | BD_STALL_MASK | BD_DATA01_MASK);
-        bdt[idx].byte_count = epMaxPacket[endpoint];
-        Data1 &= ~(1 << endpoint);
+        
+        // if this is an RX endpoint, start a new read
+        if (OUT_EP(endpoint))
+        {
+            bdt[idx].byte_count = epMaxPacket[endpoint];
+            bdt[idx].info = BD_OWN_MASK | BD_DTS_MASK;
+        }
+
+        // Reset Data1 for the endpoint - we need to set the bit to 1 for 
+        // either TX or RX, by the same logic as in realiseEndpoint()
+        Data1 |= (1 << endpoint);
+        
+        // clear the 'completed' bit for the endpoint
+        epComplete &= ~(1 << endpoint);
     }
     EXIT_CRITICAL_SECTION
 }
@@ -640,7 +655,13 @@
             bdt[EP_BDT_IDX(0, TX, EVEN)].info &= ~(BD_OWN_MASK | BD_STALL_MASK | BD_DATA01_MASK);
             bdt[EP_BDT_IDX(0, RX, EVEN)].byte_count = MAX_PACKET_SIZE_EP0;
             bdt[EP_BDT_IDX(0, TX, EVEN)].byte_count = MAX_PACKET_SIZE_EP0;
-            Data1 &= ~0x03;
+
+            // start a new read on EP0OUT
+            bdt[EP_BDT_IDX(0, RX, EVEN)].info = BD_OWN_MASK | BD_DTS_MASK;
+
+            // reset the DATA0/1 bit to 1 on EP0IN and EP0OUT, by the same 
+            // logic as in realiseEndpoint()            
+            Data1 |= 0x03;
         }
             
         // clear the busy-suspend bit to resume token processing