summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsakumisu <[email protected]>2025-08-05 21:27:45 +0800
committersakumisu <[email protected]>2025-08-05 21:27:45 +0800
commit8cf12c1958f7526ec967b8df0412444a92f1838a (patch)
tree61f57e3883ee8d5bd339ad154856a4ffa7f3b406
parentc0f544dafe7e358b276177bed75cc6d763765648 (diff)
update(port/musb): add mode check
Signed-off-by: sakumisu <[email protected]>
-rw-r--r--port/musb/usb_dc_musb.c6
-rw-r--r--port/musb/usb_hc_musb.c4
2 files changed, 9 insertions, 1 deletions
diff --git a/port/musb/usb_dc_musb.c b/port/musb/usb_dc_musb.c
index a6485143..de45b97b 100644
--- a/port/musb/usb_dc_musb.c
+++ b/port/musb/usb_dc_musb.c
@@ -121,7 +121,7 @@
#define MUSB_RXHUBADDRx_OFFSET 0x8E
#define MUSB_RXHUBPORTx_OFFSET 0x8F
-#define MUSB_TXMAP0_OFFSET 0x100
+#define MUSB_TXMAP0_OFFSET 0x100
// do not use EPIDX
#define USB_TXMAP_BASE(ep_idx) (USB_BASE + MUSB_TXMAP0_OFFSET + 0x10 * ep_idx)
@@ -787,6 +787,10 @@ void USBD_IRQHandler(uint8_t busid)
uint8_t ep_idx;
uint16_t write_count, read_count;
+ if (HWREGB(USB_BASE + MUSB_DEVCTL_OFFSET) & USB_DEVCTL_HOST) {
+ return;
+ }
+
is = HWREGB(USB_BASE + MUSB_IS_OFFSET);
txis = HWREGH(USB_BASE + MUSB_TXIS_OFFSET);
rxis = HWREGH(USB_BASE + MUSB_RXIS_OFFSET);
diff --git a/port/musb/usb_hc_musb.c b/port/musb/usb_hc_musb.c
index fe2da20a..2862f854 100644
--- a/port/musb/usb_hc_musb.c
+++ b/port/musb/usb_hc_musb.c
@@ -977,6 +977,10 @@ void USBH_IRQHandler(uint8_t busid)
bus = &g_usbhost_bus[busid];
+ if (!(HWREGB(USB_BASE + MUSB_DEVCTL_OFFSET) & USB_DEVCTL_HOST)) {
+ return;
+ }
+
is = HWREGB(USB_BASE + MUSB_IS_OFFSET);
txis = HWREGH(USB_BASE + MUSB_TXIS_OFFSET);
rxis = HWREGH(USB_BASE + MUSB_RXIS_OFFSET);