From 8fbafc460cceb6943179c0b0613d619bb9511b3c Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 13 Mar 2014 17:06:18 +0700 Subject: [PATCH] fix a problem with dcd 13uxx dcd_pipe_clear_stall that should clear toggle for buffer0 (instead of active buffer) as the next transfer is always forced to be happened on buffer0 --- demos/device/src/mscd_app_romdisk.c | 2 +- tinyusb/device/dcd_lpc_11uxx_13uxx.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/demos/device/src/mscd_app_romdisk.c b/demos/device/src/mscd_app_romdisk.c index c59b5585..6001bb90 100644 --- a/demos/device/src/mscd_app_romdisk.c +++ b/demos/device/src/mscd_app_romdisk.c @@ -105,7 +105,7 @@ uint16_t tusbd_msc_read10_cb (uint8_t coreid, uint8_t lun, void** pp_buffer, uin return 1; } -// Stall write10 as this is readonly disk +// Stall write10 by return 0, as this is readonly disk uint16_t tusbd_msc_write10_cb(uint8_t coreid, uint8_t lun, void** pp_buffer, uint32_t lba, uint16_t block_count) { (*pp_buffer) = NULL; diff --git a/tinyusb/device/dcd_lpc_11uxx_13uxx.c b/tinyusb/device/dcd_lpc_11uxx_13uxx.c index 4eef8f7d..51719af6 100644 --- a/tinyusb/device/dcd_lpc_11uxx_13uxx.c +++ b/tinyusb/device/dcd_lpc_11uxx_13uxx.c @@ -423,12 +423,13 @@ bool dcd_pipe_is_stalled(endpoint_handle_t edpt_hdl) tusb_error_t dcd_pipe_clear_stall(uint8_t coreid, uint8_t edpt_addr) { uint8_t ep_id = edpt_addr2phy(edpt_addr); - uint8_t active_buffer = BIT_TEST_(LPC_USB->EPINUSE, ep_id) ? 1 : 0; +// uint8_t active_buffer = BIT_TEST_(LPC_USB->EPINUSE, ep_id) ? 1 : 0; dcd_data.qhd[ep_id][0].stall = dcd_data.qhd[ep_id][1].stall = 0; - dcd_data.qhd[ep_id][active_buffer].toggle_reset = 1; - dcd_data.qhd[ep_id][active_buffer].feedback_toggle = 0; + // since the next transfer always take place on buffer0 --> clear buffer0 toggle + dcd_data.qhd[ep_id][0].toggle_reset = 1; + dcd_data.qhd[ep_id][0].feedback_toggle = 0; //------------- clear stall must carry on any previously queued transfer -------------// if ( dcd_data.next_td[ep_id].total_bytes != 0 )