Skip to content

Commit aab133a

Browse files
authored
Merge pull request #1027 from kkitayam/remove_redundant_from_renesas
Remove redundant SOF processing from the Renesas RX family.
2 parents 219d186 + ff59e98 commit aab133a

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/portable/renesas/usba/dcd_usba.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727

2828
#include "tusb_option.h"
2929

30+
// Since TinyUSB doesn't use SOF for now, and this interrupt too often (1ms interval)
31+
// We disable SOF for now until needed later on
32+
#define USE_SOF 0
33+
3034
#if TUSB_OPT_DEVICE_ENABLED && ( CFG_TUSB_MCU == OPT_MCU_RX63X || \
3135
CFG_TUSB_MCU == OPT_MCU_RX65X || \
3236
CFG_TUSB_MCU == OPT_MCU_RX72N )
@@ -139,7 +143,6 @@ typedef struct
139143
{
140144
pipe_state_t pipe[10];
141145
uint8_t ep[2][16]; /* a lookup table for a pipe index from an endpoint address */
142-
uint8_t suspended;
143146
} dcd_data_t;
144147

145148
//--------------------------------------------------------------------+
@@ -627,7 +630,7 @@ void dcd_init(uint8_t rhport)
627630
/* Setup default control pipe */
628631
USB0.DCPMAXP.BIT.MXPS = 64;
629632
USB0.INTENB0.WORD = USB_IS0_VBINT | USB_IS0_BRDY | USB_IS0_BEMP |
630-
USB_IS0_DVST | USB_IS0_CTRT | USB_IS0_SOFR | USB_IS0_RESM;
633+
USB_IS0_DVST | USB_IS0_CTRT | (USE_SOF ? USB_IS0_SOFR: 0) | USB_IS0_RESM;
631634
USB0.BEMPENB.WORD = 1;
632635
USB0.BRDYENB.WORD = 1;
633636

@@ -815,21 +818,16 @@ void dcd_int_handler(uint8_t rhport)
815818
}
816819
if (is0 & USB_IS0_RESM) {
817820
dcd_event_bus_signal(rhport, DCD_EVENT_RESUME, true);
818-
_dcd.suspended = 0;
819-
}
820-
if (is0 & USB_IS0_SOFR) {
821-
if (_dcd.suspended) {
822-
/* When USB host resumes caused by `dcd_remote_wakeup()`,
823-
* RESM interrupt does not rise.
824-
* Therefore we need to manually send resume event.
825-
* Of course, when USB host resumes on its own,
826-
* RESM interrupt rise properly, then this statements are ignored. */
827-
// TODO can be dropped since this logic is implemented by usbd
828-
// USBD will exit suspended mode when SOF event is received
829-
dcd_event_bus_signal(rhport, DCD_EVENT_RESUME, true);
830-
_dcd.suspended = 0;
831-
}
821+
#if (0==USE_SOF)
822+
USB0.INTENB0.BIT.SOFE = 0;
823+
#endif
824+
}
825+
if ((is0 & USB_IS0_SOFR) && USB0.INTENB0.BIT.SOFE) {
826+
// USBD will exit suspended mode when SOF event is received
832827
dcd_event_bus_signal(rhport, DCD_EVENT_SOF, true);
828+
#if (0==USE_SOF)
829+
USB0.INTENB0.BIT.SOFE = 0;
830+
#endif
833831
}
834832
if (is0 & USB_IS0_DVST) {
835833
switch (is0 & USB_IS0_DVSQ) {
@@ -844,7 +842,9 @@ void dcd_int_handler(uint8_t rhport)
844842
case USB_IS0_DVSQ_SUSP2:
845843
case USB_IS0_DVSQ_SUSP3:
846844
dcd_event_bus_signal(rhport, DCD_EVENT_SUSPEND, true);
847-
_dcd.suspended = 1;
845+
#if (0==USE_SOF)
846+
USB0.INTENB0.BIT.SOFE = 1;
847+
#endif
848848
default:
849849
break;
850850
}

0 commit comments

Comments
 (0)