Преглед изворни кода

use correct NBYTES_MAX for full and high speed

hathach пре 5 година
родитељ
комит
ba90a8cb79

+ 1 - 0
hw/bsp/lpc55/boards/lpcxpresso55s69/board.mk

@@ -2,6 +2,7 @@ MCU_VARIANT = LPC55S69
 MCU_CORE = LPC55S69_cm33_core0
 
 CFLAGS += -DCPU_LPC55S69JBD100_cm33_core0
+PORT ?= 1
 
 JLINK_DEVICE = LPC55S69
 PYOCD_TARGET = LPC55S69

+ 11 - 14
src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c

@@ -76,16 +76,10 @@ typedef struct {
   __I  uint32_t EPTOGGLE;      // Endpoint toggle register, offset: 0x34
 } dcd_registers_t;
 
-/* Although device controller are the same. Somehow only LPC134x can execute
- * DMA with 1023 bytes for Bulk/Control. Others (11u, 51u, 54xxx) can only work
- * with max 64 bytes
- */
+// Max nbytes for each control/bulk/interrupt transfer
 enum {
-  #if CFG_TUSB_MCU == OPT_MCU_LPC13XX
-    DMA_NBYTES_MAX = 1023
-  #else
-    DMA_NBYTES_MAX = 64
-  #endif
+  NBYTES_CBI_FULLSPEED_MAX = 64,
+  NBYTES_CBI_HIGHSPEED_MAX = 32767 // can be up to all 15-bit, but only tested with 4096
 };
 
 enum {
@@ -342,20 +336,23 @@ static void prepare_setup_packet(uint8_t rhport)
 
 static void prepare_ep_xfer(uint8_t rhport, uint8_t ep_id, uint16_t buf_offset, uint16_t total_bytes)
 {
-  uint16_t const nbytes = tu_min16(total_bytes, DMA_NBYTES_MAX);
-
-  _dcd.dma[ep_id].nbytes = nbytes;
+  uint16_t nbytes;
 
   if (_dcd_controller[rhport].max_speed == TUSB_SPEED_FULL )
   {
+    // TODO ISO FullSpeed can have up to 1023 bytes
+    nbytes = tu_min16(total_bytes, NBYTES_CBI_FULLSPEED_MAX);
     _dcd.ep[ep_id][0].buffer_fs.offset = buf_offset;
-    _dcd.ep[ep_id][0].buffer_fs.nbytes        = nbytes;
+    _dcd.ep[ep_id][0].buffer_fs.nbytes = nbytes;
   }else
   {
+    nbytes = tu_min16(total_bytes, NBYTES_CBI_HIGHSPEED_MAX);
     _dcd.ep[ep_id][0].buffer_hs.offset = buf_offset;
-    _dcd.ep[ep_id][0].buffer_hs.nbytes        = nbytes;
+    _dcd.ep[ep_id][0].buffer_hs.nbytes = nbytes;
   }
 
+  _dcd.dma[ep_id].nbytes = nbytes;
+
   _dcd.ep[ep_id][0].active = 1;
 }