From 741fdaaee7b346815546a8e5be2cae9dd015d64a Mon Sep 17 00:00:00 2001 From: Roman Leonov Date: Thu, 28 Nov 2024 11:58:20 +0100 Subject: [PATCH 1/2] fix(dcd_dwc2): Reset allocated_epin_count on bus reset and close all ep --- src/portable/synopsys/dwc2/dcd_dwc2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/portable/synopsys/dwc2/dcd_dwc2.c b/src/portable/synopsys/dwc2/dcd_dwc2.c index 63d2e5bb15..91c006e01a 100644 --- a/src/portable/synopsys/dwc2/dcd_dwc2.c +++ b/src/portable/synopsys/dwc2/dcd_dwc2.c @@ -539,7 +539,7 @@ void dcd_edpt_close_all(uint8_t rhport) { dwc2_regs_t* dwc2 = DWC2_REG(rhport); uint8_t const ep_count = _dwc2_controller[rhport].ep_count; - _dcd_data.allocated_epin_count = 1; + _dcd_data.allocated_epin_count = 0; // Disable non-control interrupt dwc2->daintmsk = (1 << DAINTMSK_OEPM_Pos) | (1 << DAINTMSK_IEPM_Pos); @@ -646,7 +646,7 @@ static void handle_bus_reset(uint8_t rhport) { tu_memclr(xfer_status, sizeof(xfer_status)); _dcd_data.sof_en = false; - _dcd_data.allocated_epin_count = 1; + _dcd_data.allocated_epin_count = 0; // 1. NAK for all OUT endpoints for (uint8_t n = 0; n < ep_count; n++) { From 239443c197c34f0f51a4ff7839b25985ccbb48ad Mon Sep 17 00:00:00 2001 From: Roman Leonov Date: Thu, 28 Nov 2024 12:59:13 +0100 Subject: [PATCH 2/2] fix(dcd_dwc2): Correct usage of dwc2_controller --- src/portable/synopsys/dwc2/dcd_dwc2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/portable/synopsys/dwc2/dcd_dwc2.c b/src/portable/synopsys/dwc2/dcd_dwc2.c index 91c006e01a..bde48ef577 100644 --- a/src/portable/synopsys/dwc2/dcd_dwc2.c +++ b/src/portable/synopsys/dwc2/dcd_dwc2.c @@ -192,8 +192,8 @@ static bool dfifo_alloc(uint8_t rhport, uint8_t ep_addr, uint16_t packet_size) { } } else { // Check IN endpoints concurrently active limit - if(_dwc2_controller->ep_in_count) { - TU_ASSERT(_dcd_data.allocated_epin_count < _dwc2_controller->ep_in_count); + if(dwc2_controller->ep_in_count) { + TU_ASSERT(_dcd_data.allocated_epin_count < dwc2_controller->ep_in_count); _dcd_data.allocated_epin_count++; }