summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhihong Chen <[email protected]>2024-02-19 18:14:46 +0800
committersakumisu <[email protected]>2024-02-19 20:19:48 +0800
commit4803a6826b2668e60c767b7a0952244f37052c86 (patch)
tree5bd74a5642f050aecb267d74ebe7cf8195a88bd2
parente0551b3e7b49cf80902683b0d1af34967cd3f0bd (diff)
update endpoint number usage and fix busid check
Signed-off-by: Zhihong Chen <[email protected]>
-rw-r--r--cherryusb_config_template.h8
-rw-r--r--core/usbd_core.c9
-rw-r--r--core/usbh_core.c2
3 files changed, 9 insertions, 10 deletions
diff --git a/cherryusb_config_template.h b/cherryusb_config_template.h
index 4cea5509..fd205c67 100644
--- a/cherryusb_config_template.h
+++ b/cherryusb_config_template.h
@@ -33,6 +33,8 @@
/* ================= USB Device Stack Configuration ================ */
+#define CONFIG_USBDEV_MAX_BUS 1 // for now, bus num must be 1 except hpm ip
+
/* Ep0 max transfer buffer, specially for receiving data from ep0 out */
#define CONFIG_USBDEV_REQUEST_BUFFER_LEN 256
@@ -146,9 +148,9 @@
/* ================ USB Device Port Configuration ================*/
-#define CONFIG_USBDEV_MAX_BUS 1 // for now, bus num must be 1 except hpm ip
-
-#define CONFIG_USBDEV_EP_NUM 4
+#ifndef CONFIG_USBDEV_EP_NUM
+#define CONFIG_USBDEV_EP_NUM 8
+#endif
/* ================ USB Host Port Configuration ==================*/
diff --git a/core/usbd_core.c b/core/usbd_core.c
index ecaee117..695361f2 100644
--- a/core/usbd_core.c
+++ b/core/usbd_core.c
@@ -18,9 +18,6 @@
#define INTF_DESC_bInterfaceNumber 2 /** Interface number offset */
#define INTF_DESC_bAlternateSetting 3 /** Alternate setting offset */
-#define USB_EP_OUT_NUM 16
-#define USB_EP_IN_NUM 16
-
struct usbd_tx_rx_msg {
uint8_t ep;
uint32_t nbytes;
@@ -59,8 +56,8 @@ USB_NOCACHE_RAM_SECTION struct usbd_core_priv {
struct usbd_interface *intf[8];
uint8_t intf_offset;
- struct usbd_tx_rx_msg tx_msg[USB_EP_IN_NUM];
- struct usbd_tx_rx_msg rx_msg[USB_EP_OUT_NUM];
+ struct usbd_tx_rx_msg tx_msg[CONFIG_USBDEV_EP_NUM];
+ struct usbd_tx_rx_msg rx_msg[CONFIG_USBDEV_EP_NUM];
void (*event_handler)(uint8_t busid, uint8_t event);
} g_usbd_core[CONFIG_USBDEV_MAX_BUS];
@@ -1206,7 +1203,7 @@ int usbd_initialize(uint8_t busid, uint32_t reg_base, void (*event_handler)(uint
int ret;
struct usbd_bus *bus;
- if (busid > CONFIG_USBDEV_MAX_BUS) {
+ if (busid >= CONFIG_USBDEV_MAX_BUS) {
USB_LOG_ERR("bus overflow\r\n");
while (1) {
}
diff --git a/core/usbh_core.c b/core/usbh_core.c
index 673660f1..6ca6ddc1 100644
--- a/core/usbh_core.c
+++ b/core/usbh_core.c
@@ -668,7 +668,7 @@ int usbh_initialize(uint8_t busid, uint32_t reg_base)
{
struct usbh_bus *bus;
- if (busid > CONFIG_USBHOST_MAX_BUS) {
+ if (busid >= CONFIG_USBHOST_MAX_BUS) {
USB_LOG_ERR("bus overflow\r\n");
while (1) {
}