Skip to content

Commit 6798e7e

Browse files
authored
Merge pull request hathach#2120 from abakosh/RA_STALL
fix(RA_hcd): STALL status can be also 3 not only 2
2 parents c5e23ea + 3230d5b commit 6798e7e

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

src/host/usbh.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ bool usbh_edpt_xfer_with_callback(uint8_t dev_addr, uint8_t ep_addr, uint8_t * b
791791
uint8_t const dir = tu_edpt_dir(ep_addr);
792792
tu_edpt_state_t* ep_state = &dev->ep_status[epnum][dir];
793793

794-
TU_LOG_USBH(" Queue EP %02X with %u bytes ... ", ep_addr, total_bytes);
794+
TU_LOG_USBH(" Queue EP %02X with %u bytes ... \r\n", ep_addr, total_bytes);
795795

796796
// Attempt to transfer on a busy endpoint, sound like an race condition !
797797
TU_ASSERT(ep_state->busy == 0);

src/portable/renesas/rusb2/dcd_rusb2.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
#error "Unsupported MCU"
4646
#endif
4747

48+
#define TU_RUSB2_DCD_DBG 0
49+
4850
//--------------------------------------------------------------------+
4951
// MACRO TYPEDEF CONSTANT ENUM
5052
//--------------------------------------------------------------------+
@@ -444,7 +446,7 @@ static bool process_pipe_xfer(int buffer_type, uint8_t ep_addr, void* buffer, ui
444446
*ctr = RUSB2_PIPE_CTR_PID_BUF;
445447
}
446448
}
447-
// TU_LOG1("X %x %d %d\r\n", ep_addr, total_bytes, buffer_type);
449+
TU_LOG(TU_RUSB2_DCD_DBG ,"X %x %d %d\r\n", ep_addr, total_bytes, buffer_type);
448450
return true;
449451
}
450452

@@ -487,7 +489,7 @@ static void process_pipe_brdy(uint8_t rhport, unsigned num)
487489
dcd_event_xfer_complete(rhport, pipe->ep,
488490
pipe->length - pipe->remaining,
489491
XFER_RESULT_SUCCESS, true);
490-
// TU_LOG1("C %d %d\r\n", num, pipe->length - pipe->remaining);
492+
TU_LOG(TU_RUSB2_DCD_DBG, "C %d %d\r\n", num, pipe->length - pipe->remaining);
491493
}
492494
}
493495

@@ -691,7 +693,7 @@ bool dcd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const * ep_desc)
691693
if (dir || (xfer != TUSB_XFER_BULK)) {
692694
*ctr = RUSB2_PIPE_CTR_PID_BUF;
693695
}
694-
// TU_LOG1("O %d %x %x\r\n", RUSB2->PIPESEL, RUSB2->PIPECFG, RUSB2->PIPEMAXP);
696+
TU_LOG(TU_RUSB2_DCD_DBG, "O %d %x %x\r\n", RUSB2->PIPESEL, RUSB2->PIPECFG, RUSB2->PIPEMAXP);
695697
dcd_int_enable(rhport);
696698

697699
return true;

src/portable/renesas/rusb2/hcd_rusb2.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
#error "Unsupported MCU"
4242
#endif
4343

44+
#define TU_RUSB2_HCD_DBG 0
45+
4446
//--------------------------------------------------------------------+
4547
// MACRO TYPEDEF CONSTANT ENUM DECLARATION
4648
//--------------------------------------------------------------------+
@@ -116,7 +118,7 @@ static unsigned find_pipe(unsigned xfer)
116118
for (int i = 3; i <= 5; ++i) {
117119
if (0 == _hcd.pipe[i].ep) return i;
118120
}
119-
for (int i = 1; i <= 1; ++i) {
121+
for (int i = 1; i <= 2; ++i) {
120122
if (0 == _hcd.pipe[i].ep) return i;
121123
}
122124
break;
@@ -409,10 +411,11 @@ static void process_pipe_nrdy(uint8_t rhport, unsigned num)
409411
(void)rhport;
410412
xfer_result_t result;
411413
uint16_t volatile *ctr = get_pipectr(num);
412-
// TU_LOG1("NRDY %d %x\n", num, *ctr);
414+
TU_LOG(TU_RUSB2_HCD_DBG, "NRDY %d %x\n", num, *ctr);
413415
switch (*ctr & RUSB2_PIPE_CTR_PID_Msk) {
414416
default: return;
415417
case RUSB2_PIPE_CTR_PID_STALL: result = XFER_RESULT_STALLED; break;
418+
case RUSB2_PIPE_CTR_PID_STALL2: result = XFER_RESULT_STALLED; break;
416419
case RUSB2_PIPE_CTR_PID_NAK: result = XFER_RESULT_FAILED; break;
417420
}
418421
pipe_state_t *pipe = &_hcd.pipe[num];
@@ -441,7 +444,7 @@ static void process_pipe_brdy(uint8_t rhport, unsigned num)
441444
hcd_event_xfer_complete(pipe->dev, pipe->ep,
442445
pipe->length - pipe->remaining,
443446
XFER_RESULT_SUCCESS, true);
444-
// TU_LOG1("C %d %d\r\n", num, pipe->length - pipe->remaining);
447+
TU_LOG(TU_RUSB2_HCD_DBG, "C %d %d\r\n", num, pipe->length - pipe->remaining);
445448
}
446449
}
447450

@@ -586,7 +589,7 @@ void hcd_device_close(uint8_t rhport, uint8_t dev_addr)
586589
uint8_t *ep = &_hcd.ep[dev_addr - 1][0][0];
587590
for (int i = 0; i < 2 * 15; ++i, ++ep) {
588591
unsigned num = *ep;
589-
if (!num || dev_addr != _hcd.pipe[num].dev) continue;
592+
if (!num || (dev_addr != _hcd.pipe[num].dev)) continue;
590593

591594
ctr = (uint16_t volatile*)&RUSB2->PIPE_CTR[num - 1];
592595
*ctr = 0;
@@ -608,7 +611,7 @@ void hcd_device_close(uint8_t rhport, uint8_t dev_addr)
608611
bool hcd_setup_send(uint8_t rhport, uint8_t dev_addr, uint8_t const setup_packet[8])
609612
{
610613
(void)rhport;
611-
// TU_LOG1("S %d %x\n", dev_addr, RUSB2->DCPCTR);
614+
TU_LOG(TU_RUSB2_HCD_DBG, "S %d %x\n", dev_addr, RUSB2->DCPCTR);
612615

613616
TU_ASSERT(dev_addr < 6); /* USBa can only handle addresses from 0 to 5. */
614617
TU_ASSERT(0 == RUSB2->DCPCTR_b.SUREQ);
@@ -701,7 +704,7 @@ bool hcd_edpt_xfer(uint8_t rhport, uint8_t dev_addr, uint8_t ep_addr, uint8_t *b
701704
{
702705
bool r;
703706
hcd_int_disable(rhport);
704-
// TU_LOG1("X %d %x %u\n", dev_addr, ep_addr, buflen);
707+
TU_LOG(TU_RUSB2_HCD_DBG, "X %d %x %u\n", dev_addr, ep_addr, buflen);
705708
r = process_edpt_xfer(dev_addr, ep_addr, buffer, buflen);
706709
hcd_int_enable(rhport);
707710
return r;
@@ -745,7 +748,7 @@ void hcd_int_handler(uint8_t rhport)
745748
/* clear active bits except VALID (don't write 0 to already cleared bits according to the HW manual) */
746749
RUSB2->INTSTS1 = ~((RUSB2_INTSTS1_SACK_Msk | RUSB2_INTSTS1_SIGN_Msk | RUSB2_INTSTS1_ATTCH_Msk | RUSB2_INTSTS1_DTCH_Msk) & is1);
747750
RUSB2->INTSTS0 = ~((RUSB2_INTSTS0_BRDY_Msk | RUSB2_INTSTS0_NRDY_Msk | RUSB2_INTSTS0_BEMP_Msk) & is0);
748-
// TU_LOG1("IS %04x %04x\n", is0, is1);
751+
TU_LOG(TU_RUSB2_HCD_DBG, "IS %04x %04x\n", is0, is1);
749752
is1 &= RUSB2->INTENB1;
750753
is0 &= RUSB2->INTENB0;
751754

src/portable/renesas/rusb2/rusb2_type.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,6 +1568,7 @@ TU_ATTR_BIT_FIELD_ORDER_END
15681568
#define RUSB2_PIPE_CTR_PID_NAK (0U << RUSB2_PIPE_CTR_PID_Pos) /* NAK response */
15691569
#define RUSB2_PIPE_CTR_PID_BUF (1U << RUSB2_PIPE_CTR_PID_Pos) /* BUF response (depends buffer state) */
15701570
#define RUSB2_PIPE_CTR_PID_STALL (2U << RUSB2_PIPE_CTR_PID_Pos) /* STALL response */
1571+
#define RUSB2_PIPE_CTR_PID_STALL2 (3U << RUSB2_PIPE_CTR_PID_Pos) /* Also STALL response */
15711572

15721573
#define RUSB2_DVSTCTR0_RHST_LS (1U << RUSB2_DVSTCTR0_RHST_Pos) /* Low-speed connection */
15731574
#define RUSB2_DVSTCTR0_RHST_FS (2U << RUSB2_DVSTCTR0_RHST_Pos) /* Full-speed connection */

0 commit comments

Comments
 (0)