Skip to content

Commit 3bc83eb

Browse files
authored
Update dcd_dwc2.c
1 parent 25b90f1 commit 3bc83eb

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

components/arduino_tinyusb/src/dcd_dwc2.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131

3232
#if CFG_TUD_ENABLED && defined(TUP_USBIP_DWC2)
3333

34-
#if !CFG_TUD_DWC2_SLAVE_ENABLE && !CFG_TUH_DWC2_DMA_ENABLE
35-
#error DWC2 require either CFG_TUD_DWC2_SLAVE_ENABLE or CFG_TUH_DWC2_DMA_ENABLE to be enabled
34+
#if !(CFG_TUD_DWC2_SLAVE_ENABLE || CFG_TUD_DWC2_DMA_ENABLE)
35+
#error DWC2 require either CFG_TUD_DWC2_SLAVE_ENABLE or CFG_TUD_DWC2_DMA_ENABLE to be enabled
3636
#endif
3737

3838
// Debug level for DWC2
@@ -44,7 +44,7 @@
4444
#if TU_CHECK_MCU(OPT_MCU_GD32VF103)
4545
#define DWC2_EP_COUNT(_dwc2) DWC2_EP_MAX
4646
#else
47-
#define DWC2_EP_COUNT(_dwc2) ((_dwc2)->ghwcfg2_bm.num_dev_ep)
47+
#define DWC2_EP_COUNT(_dwc2) ((_dwc2)->ghwcfg2_bm.num_dev_ep + 1)
4848
#endif
4949

5050
//--------------------------------------------------------------------+
@@ -192,8 +192,8 @@ static bool dfifo_alloc(uint8_t rhport, uint8_t ep_addr, uint16_t packet_size) {
192192
}
193193
} else {
194194
// Check IN endpoints concurrently active limit
195-
if(_dwc2_controller->ep_in_count) {
196-
TU_ASSERT(_dcd_data.allocated_epin_count < _dwc2_controller->ep_in_count);
195+
if(dwc2_controller->ep_in_count) {
196+
TU_ASSERT(_dcd_data.allocated_epin_count < dwc2_controller->ep_in_count);
197197
_dcd_data.allocated_epin_count++;
198198
}
199199

@@ -561,7 +561,7 @@ void dcd_edpt_close_all(uint8_t rhport) {
561561
dwc2_regs_t* dwc2 = DWC2_REG(rhport);
562562
uint8_t const ep_count = _dwc2_controller[rhport].ep_count;
563563

564-
_dcd_data.allocated_epin_count = 1;
564+
_dcd_data.allocated_epin_count = 0;
565565

566566
// Disable non-control interrupt
567567
dwc2->daintmsk = (1 << DAINTMSK_OEPM_Pos) | (1 << DAINTMSK_IEPM_Pos);
@@ -641,10 +641,6 @@ bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t* ff, uint16_t
641641
return true;
642642
}
643643

644-
void dcd_edpt_close(uint8_t rhport, uint8_t ep_addr) {
645-
edpt_disable(rhport, ep_addr, false);
646-
}
647-
648644
void dcd_edpt_stall(uint8_t rhport, uint8_t ep_addr) {
649645
dwc2_regs_t* dwc2 = DWC2_REG(rhport);
650646
edpt_disable(rhport, ep_addr, true);
@@ -676,7 +672,7 @@ static void handle_bus_reset(uint8_t rhport) {
676672
tu_memclr(xfer_status, sizeof(xfer_status));
677673

678674
_dcd_data.sof_en = false;
679-
_dcd_data.allocated_epin_count = 1;
675+
_dcd_data.allocated_epin_count = 0;
680676

681677
// 1. NAK for all OUT endpoints
682678
for (uint8_t n = 0; n < ep_count; n++) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy