summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsakumisu <[email protected]>2022-03-10 19:10:00 +0800
committersakumisu <[email protected]>2022-03-10 19:10:00 +0800
commit96b92efbcb7487abea950c84e7c2d609cfd19d93 (patch)
tree3619990293b134bf797f1521e5aa74288c91292e
parent0c57037257f1fdd4b4ebd26eefb34e634453b4ae (diff)
add usb_dc_init declare in usb_dc.h,and add usbd_initialize to call it
-rw-r--r--common/usb_dc.h14
-rw-r--r--core/usbd_core.c6
-rw-r--r--core/usbd_core.h2
3 files changed, 18 insertions, 4 deletions
diff --git a/common/usb_dc.h b/common/usb_dc.h
index 0b8ae7e7..db96adb6 100644
--- a/common/usb_dc.h
+++ b/common/usb_dc.h
@@ -90,6 +90,11 @@ struct usbd_endpoint_cfg {
*/
/**
+ * @brief init device controller registers.
+ * @return 0 on success, negative errno code on fail.
+ */
+int usb_dc_init(void);
+/**
* @brief Set USB device address
*
* @param[in] addr Device address
@@ -172,10 +177,11 @@ int usbd_ep_write(const uint8_t ep, const uint8_t *data, uint32_t data_len, uint
/**
* @brief Read data from the specified endpoint
*
- * This is similar to usb_dc_ep_read, the difference being that, it doesn't
- * clear the endpoint NAKs so that the consumer is not bogged down by further
- * upcalls till he is done with the processing of the data. The caller should
- * reactivate ep by setting max_data_len 0 do so.
+ * This function is called by the endpoint handler function, after an OUT
+ * interrupt has been received for that EP. The application must only call this
+ * function through the supplied usbd_ep_callback function. This function clears
+ * the ENDPOINT NAK when max_data_len is 0, if all data in the endpoint FIFO has been read,
+ * so as to accept more data from host.
*
* @param[in] ep Endpoint address corresponding to the one
* listed in the device configuration table
diff --git a/core/usbd_core.c b/core/usbd_core.c
index c5e0a5bd..ede250e3 100644
--- a/core/usbd_core.c
+++ b/core/usbd_core.c
@@ -1297,3 +1297,9 @@ bool usb_device_is_configured(void)
{
return usbd_core_cfg.configured;
}
+
+int usbd_initialize(void)
+{
+ usb_dc_init();
+ return 0;
+} \ No newline at end of file
diff --git a/core/usbd_core.h b/core/usbd_core.h
index 99aa1d87..401cf542 100644
--- a/core/usbd_core.h
+++ b/core/usbd_core.h
@@ -131,6 +131,8 @@ void usbd_class_add_interface(usbd_class_t *devclass, usbd_interface_t *intf);
void usbd_interface_add_endpoint(usbd_interface_t *intf, usbd_endpoint_t *ep);
bool usb_device_is_configured(void);
+int usbd_initialize(void);
+
#ifdef __cplusplus
}
#endif