summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsakumisu <[email protected]>2022-06-14 22:08:49 +0800
committersakumisu <[email protected]>2022-06-14 22:08:49 +0800
commitb57d3637bb134996f60c6d4a3c88986a8b416bc9 (patch)
treee78a029ba7caf13f4dcd8bbc801fb66645b9b039
parenta31e56f13eba2a3761b994189a4fd7f892d2ba42 (diff)
add sw init for os and hw init for host controller
-rw-r--r--common/usb_hc.h27
-rw-r--r--core/usbh_core.c7
2 files changed, 22 insertions, 12 deletions
diff --git a/common/usb_hc.h b/common/usb_hc.h
index fbf8eef8..bc70d6b7 100644
--- a/common/usb_hc.h
+++ b/common/usb_hc.h
@@ -60,11 +60,18 @@ struct usbh_endpoint_cfg {
*/
/**
+ * @brief usb host software init, used for global reset.
+ *
+ * @return int
+ */
+int usb_hc_sw_init(void);
+
+/**
* @brief usb host controller hardware init.
*
* @return int
*/
-int usb_hc_init(void);
+int usb_hc_hw_init(void);
/**
* @brief get port connect status
@@ -144,11 +151,12 @@ int usbh_control_transfer(usbh_epinfo_t ep, struct usb_setup_packet *setup, uint
* of bytes successfully transferred. On a failure, a negated errno value
* is returned that indicates the nature of the failure:
*
- * EAGAIN - If devices NAKs the transfer (or NYET or other error where
+ * -EAGAIN - If devices NAKs the transfer (or NYET or other error where
* it may be appropriate to restart the entire transaction).
- * EPERM - If the endpoint stalls
- * EIO - On a TX or data toggle error
- * EPIPE - Overrun errors
+ * -EPERM - If the endpoint stalls
+ * -EIO - On a TX or data toggle error
+ * -EPIPE - Overrun errors
+ * -ETIMEDOUT - Sem wait timeout
*
*/
int usbh_ep_bulk_transfer(usbh_epinfo_t ep, uint8_t *buffer, uint32_t buflen, uint32_t timeout);
@@ -166,11 +174,12 @@ int usbh_ep_bulk_transfer(usbh_epinfo_t ep, uint8_t *buffer, uint32_t buflen, ui
* of bytes successfully transferred. On a failure, a negated errno value
* is returned that indicates the nature of the failure:
*
- * EAGAIN - If devices NAKs the transfer (or NYET or other error where
+ * -EAGAIN - If devices NAKs the transfer (or NYET or other error where
* it may be appropriate to restart the entire transaction).
- * EPERM - If the endpoint stalls
- * EIO - On a TX or data toggle error
- * EPIPE - Overrun errors
+ * -EPERM - If the endpoint stalls
+ * -EIO - On a TX or data toggle error
+ * -EPIPE - Overrun errors
+ * -ETIMEDOUT - Sem wait timeout
*
*/
int usbh_ep_intr_transfer(usbh_epinfo_t ep, uint8_t *buffer, uint32_t buflen, uint32_t timeout);
diff --git a/core/usbh_core.c b/core/usbh_core.c
index 93cd1bf3..26a495b4 100644
--- a/core/usbh_core.c
+++ b/core/usbh_core.c
@@ -745,13 +745,15 @@ static void usbh_portchange_detect_thread(void *argument)
{
struct usbh_hubport *hport = NULL;
+ usb_hc_sw_init();
+
for (uint8_t port = USBH_HUB_PORT_START_INDEX; port <= CONFIG_USBHOST_RHPORTS; port++) {
usbh_core_cfg.rhport[port - 1].hport.port = port;
usbh_core_cfg.rhport[port - 1].devgen.next = 1;
usbh_hport_activate(&usbh_core_cfg.rhport[port - 1].hport);
}
- usb_hc_init();
+ usb_hc_hw_init();
while (1) {
usbh_portchange_wait(&hport);
@@ -844,9 +846,8 @@ int usbh_initialize(void)
usbh_class_info_table_end = (struct usbh_class_info *)(class_info_table[0] + (sizeof(class_info_table) / sizeof(class_info_table[0])));
#endif
-#ifdef CONFIG_USBHOST_HUB
usbh_workq_initialize();
-#endif
+
usbh_core_cfg.pscevent = usb_osal_event_create();
if (usbh_core_cfg.pscevent == NULL) {
return -1;