add usb_dc_init declare in usb_dc.h,and add usbd_initialize to call it

This commit is contained in:
sakumisu
2022-03-10 19:10:00 +08:00
parent 0c57037257
commit 96b92efbcb
3 changed files with 18 additions and 4 deletions

View File

@@ -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

View File

@@ -1297,3 +1297,9 @@ bool usb_device_is_configured(void)
{
return usbd_core_cfg.configured;
}
int usbd_initialize(void)
{
usb_dc_init();
return 0;
}

View File

@@ -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