Skip to content

Commit 7480c2e

Browse files
committed
correct qhd and qtd count for ehci/ohci
1 parent 032e2c2 commit 7480c2e

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

src/host/hcd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
//--------------------------------------------------------------------+
4141

4242
#ifndef CFG_TUH_ENDPOINT_MAX
43-
#define CFG_TUH_ENDPOINT_MAX (CFG_TUH_DEVICE_MAX*(CFG_TUH_HUB + CFG_TUH_HID*2 + CFG_TUH_MSC*2 + CFG_TUH_CDC*3))
43+
#define CFG_TUH_ENDPOINT_MAX (CFG_TUH_HUB + CFG_TUH_HID*2 + CFG_TUH_MSC*2 + CFG_TUH_CDC*3)
4444
// #ifdef TUP_HCD_ENDPOINT_MAX
4545
// #define CFG_TUH_ENDPPOINT_MAX TUP_HCD_ENDPOINT_MAX
4646
// #else

src/portable/ehci/ehci.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@
5858

5959
#define FRAMELIST_SIZE (1024 >> FRAMELIST_SIZE_BIT_VALUE)
6060

61-
#define HCD_MAX_XFER CFG_TUH_ENDPOINT_MAX
61+
#define QHD_MAX (CFG_TUH_DEVICE_MAX*CFG_TUH_ENDPOINT_MAX)
62+
#define QTD_MAX QHD_MAX
6263

6364
typedef struct
6465
{
@@ -76,7 +77,7 @@ typedef struct
7677
}control[CFG_TUH_DEVICE_MAX+CFG_TUH_HUB+1];
7778

7879
ehci_qhd_t qhd_pool[CFG_TUH_ENDPOINT_MAX];
79-
ehci_qtd_t qtd_pool[HCD_MAX_XFER] TU_ATTR_ALIGNED(32);
80+
ehci_qtd_t qtd_pool[QTD_MAX] TU_ATTR_ALIGNED(32);
8081

8182
ehci_registers_t* regs;
8283

@@ -752,7 +753,7 @@ static inline ehci_qhd_t* qhd_get_from_addr(uint8_t dev_addr, uint8_t ep_addr)
752753
//------------- TD helper -------------//
753754
static inline ehci_qtd_t* qtd_find_free(void)
754755
{
755-
for (uint32_t i=0; i<HCD_MAX_XFER; i++)
756+
for (uint32_t i=0; i<QTD_MAX; i++)
756757
{
757758
if ( !ehci_data.qtd_pool[i].used ) return &ehci_data.qtd_pool[i];
758759
}

src/portable/ohci/ohci.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ static ohci_ed_t * ed_from_addr(uint8_t dev_addr, uint8_t ep_addr)
313313

314314
ohci_ed_t* ed_pool = ohci_data.ed_pool;
315315

316-
for(uint32_t i=0; i<CFG_TUH_ENDPOINT_MAX; i++)
316+
for(uint32_t i=0; i<ED_MAX; i++)
317317
{
318318
if ( (ed_pool[i].dev_addr == dev_addr) &&
319319
ep_addr == tu_edpt_addr(ed_pool[i].ep_number, ed_pool[i].pid == PID_IN) )
@@ -329,7 +329,7 @@ static ohci_ed_t * ed_find_free(void)
329329
{
330330
ohci_ed_t* ed_pool = ohci_data.ed_pool;
331331

332-
for(uint8_t i = 0; i < CFG_TUH_ENDPOINT_MAX; i++)
332+
for(uint8_t i = 0; i < ED_MAX; i++)
333333
{
334334
if ( !ed_pool[i].used ) return &ed_pool[i];
335335
}
@@ -368,7 +368,7 @@ static void ed_list_remove_by_addr(ohci_ed_t * p_head, uint8_t dev_addr)
368368

369369
static ohci_gtd_t * gtd_find_free(void)
370370
{
371-
for(uint8_t i=0; i < HCD_MAX_XFER; i++)
371+
for(uint8_t i=0; i < GTD_MAX; i++)
372372
{
373373
if ( !ohci_data.gtd_pool[i].used ) return &ohci_data.gtd_pool[i];
374374
}

src/portable/ohci/ohci.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ enum {
4242
OHCI_MAX_ITD = 4
4343
};
4444

45-
#define HCD_MAX_XFER CFG_TUH_ENDPOINT_MAX
45+
#define ED_MAX (CFG_TUH_DEVICE_MAX*CFG_TUH_ENDPOINT_MAX)
46+
#define GTD_MAX ED_MAX
4647

4748
//--------------------------------------------------------------------+
4849
// OHCI Data Structure
@@ -165,7 +166,7 @@ typedef struct TU_ATTR_ALIGNED(256)
165166

166167
// ochi_itd_t itd[OHCI_MAX_ITD]; // itd requires alignment of 32
167168
ohci_ed_t ed_pool[CFG_TUH_ENDPOINT_MAX];
168-
ohci_gtd_t gtd_pool[HCD_MAX_XFER];
169+
ohci_gtd_t gtd_pool[GTD_MAX];
169170

170171
volatile uint16_t frame_number_hi;
171172

0 commit comments

Comments
 (0)