use correct NBYTES_MAX for full and high speed

This commit is contained in:
hathach
2021-04-26 20:22:40 +07:00
parent c26875e70d
commit ba90a8cb79
2 changed files with 12 additions and 14 deletions

View File

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

View File

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