From 96b92efbcb7487abea950c84e7c2d609cfd19d93 Mon Sep 17 00:00:00 2001 From: sakumisu <1203593632@qq.com> Date: Thu, 10 Mar 2022 19:10:00 +0800 Subject: [PATCH] add usb_dc_init declare in usb_dc.h,and add usbd_initialize to call it --- common/usb_dc.h | 14 ++++++++++---- core/usbd_core.c | 6 ++++++ core/usbd_core.h | 2 ++ 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 @@ -89,6 +89,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 * @@ -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