diff --git a/cherryusb_config_template.h b/cherryusb_config_template.h index 8b17aea8..941f1887 100644 --- a/cherryusb_config_template.h +++ b/cherryusb_config_template.h @@ -250,9 +250,10 @@ /* ================ USB Device Port Configuration ================*/ #ifndef CONFIG_USBDEV_MAX_BUS -#define CONFIG_USBDEV_MAX_BUS 1 // for now, bus num must be 1 except hpm ip +#define CONFIG_USBDEV_MAX_BUS 1 #endif +/* only useful for musb/ch32/chipidea */ #ifndef CONFIG_USBDEV_EP_NUM #define CONFIG_USBDEV_EP_NUM 8 #endif @@ -283,6 +284,7 @@ #define CONFIG_USBHOST_MAX_BUS 1 #endif +/* only useful for musb */ #ifndef CONFIG_USBHOST_PIPE_NUM #define CONFIG_USBHOST_PIPE_NUM 10 #endif @@ -291,7 +293,7 @@ #define CONFIG_USB_EHCI_HCCR_OFFSET (0x0) #define CONFIG_USB_EHCI_FRAME_LIST_SIZE 1024 -#define CONFIG_USB_EHCI_QH_NUM CONFIG_USBHOST_PIPE_NUM +#define CONFIG_USB_EHCI_QH_NUM 10 #define CONFIG_USB_EHCI_QTD_NUM (CONFIG_USB_EHCI_QH_NUM * 3) #define CONFIG_USB_EHCI_ITD_NUM 4 // #define CONFIG_USB_EHCI_HCOR_RESERVED_DISABLE @@ -302,7 +304,7 @@ /* ---------------- OHCI Configuration ---------------- */ #define CONFIG_USB_OHCI_HCOR_OFFSET (0x0) -#define CONFIG_USB_OHCI_ED_NUM CONFIG_USBHOST_PIPE_NUM +#define CONFIG_USB_OHCI_ED_NUM 10 #define CONFIG_USB_OHCI_TD_NUM 3 // #define CONFIG_USB_OHCI_DESC_DCACHE_ENABLE diff --git a/port/ehci/usb_hc_ehci.h b/port/ehci/usb_hc_ehci.h index 80ab8b6e..3d4cb8cd 100644 --- a/port/ehci/usb_hc_ehci.h +++ b/port/ehci/usb_hc_ehci.h @@ -19,7 +19,7 @@ #define EHCI_ADDR2ITD(x) ((struct ehci_itd_hw *)(uintptr_t)((uint32_t)(x) & ~0x1F)) #ifndef CONFIG_USB_EHCI_QH_NUM -#define CONFIG_USB_EHCI_QH_NUM CONFIG_USBHOST_PIPE_NUM +#define CONFIG_USB_EHCI_QH_NUM 10 #endif #ifndef CONFIG_USB_EHCI_QTD_NUM #define CONFIG_USB_EHCI_QTD_NUM (CONFIG_USB_EHCI_QH_NUM * 3) diff --git a/port/fsdev/usb_dc_fsdev.c b/port/fsdev/usb_dc_fsdev.c index f512fb87..3e1fa22b 100644 --- a/port/fsdev/usb_dc_fsdev.c +++ b/port/fsdev/usb_dc_fsdev.c @@ -20,9 +20,8 @@ #define CONFIG_USB_FSDEV_RAM_SIZE 512 #endif -#ifndef CONFIG_USBDEV_EP_NUM +#undef CONFIG_USBDEV_EP_NUM #define CONFIG_USBDEV_EP_NUM 8 -#endif #define USB ((USB_TypeDef *)g_usbdev_bus[0].reg_base) diff --git a/port/hpmicro/usb_dc_hpm.c b/port/hpmicro/usb_dc_hpm.c index 6432e2e2..09896549 100644 --- a/port/hpmicro/usb_dc_hpm.c +++ b/port/hpmicro/usb_dc_hpm.c @@ -8,9 +8,7 @@ #include "hpm_usb_device.h" #include "usb_glue_hpm.h" -#ifndef USB_NUM_BIDIR_ENDPOINTS -#define USB_NUM_BIDIR_ENDPOINTS CONFIG_USBDEV_EP_NUM -#endif +#define USB_NUM_BIDIR_ENDPOINTS USB_SOC_DCD_MAX_ENDPOINT_COUNT /* USBSTS, USBINTR */ enum { diff --git a/port/kinetis/usb_dc_kinetis.c b/port/kinetis/usb_dc_kinetis.c index 34109530..6cbf5356 100644 --- a/port/kinetis/usb_dc_kinetis.c +++ b/port/kinetis/usb_dc_kinetis.c @@ -6,6 +6,9 @@ #include "usbd_core.h" #include "usb_kinetis_reg.h" +#undef CONFIG_USBDEV_EP_NUM +#define CONFIG_USBDEV_EP_NUM 16 + #define USB_OTG_DEV ((KINETIS_TypeDef *)g_usbdev_bus[busid].reg_base) /* Endpoint state */ diff --git a/port/ohci/usb_hc_ohci.h b/port/ohci/usb_hc_ohci.h index 3daed971..2cebd636 100644 --- a/port/ohci/usb_hc_ohci.h +++ b/port/ohci/usb_hc_ohci.h @@ -17,7 +17,7 @@ #define OHCI_ADDR2TD(x) ((struct ohci_td_hw *)(uintptr_t)((uint32_t)(x) & ~0x0F)) #ifndef CONFIG_USB_OHCI_ED_NUM -#define CONFIG_USB_OHCI_ED_NUM CONFIG_USBHOST_PIPE_NUM +#define CONFIG_USB_OHCI_ED_NUM 10 #endif #ifndef CONFIG_USB_OHCI_TD_NUM #define CONFIG_USB_OHCI_TD_NUM 3 diff --git a/port/rp2040/usb_dc_rp2040.c b/port/rp2040/usb_dc_rp2040.c index 1a48c0c0..9730e9c8 100644 --- a/port/rp2040/usb_dc_rp2040.c +++ b/port/rp2040/usb_dc_rp2040.c @@ -12,13 +12,12 @@ #include "pico/fix/rp2040_usb_device_enumeration.h" #endif +#undef CONFIG_USBDEV_EP_NUM +#define CONFIG_USBDEV_EP_NUM USB_NUM_ENDPOINTS + #define usb_hw_set hw_set_alias(usb_hw) #define usb_hw_clear hw_clear_alias(usb_hw) -#ifndef CONFIG_USBDEV_EP_NUM -#define CONFIG_USBDEV_EP_NUM 16 -#endif - #ifndef FORCE_VBUS_DETECT #define FORCE_VBUS_DETECT 1 #endif diff --git a/port/rp2040/usb_hc_rp2040.c b/port/rp2040/usb_hc_rp2040.c index 90ac9b99..be8ff976 100644 --- a/port/rp2040/usb_hc_rp2040.c +++ b/port/rp2040/usb_hc_rp2040.c @@ -9,6 +9,9 @@ #include "hardware/irq.h" #include "hardware/structs/usb.h" +#undef CONFIG_USBHOST_PIPE_NUM +#define CONFIG_USBHOST_PIPE_NUM USB_HOST_INTERRUPT_ENDPOINTS + #define usb_hw_set hw_set_alias(usb_hw) #define usb_hw_clear hw_clear_alias(usb_hw)