refactor dcd api and ep in/out irq callback process
This commit is contained in:
107
common/usb_dc.h
107
common/usb_dc.h
@@ -67,27 +67,6 @@ int usb_dc_init(void);
|
||||
*/
|
||||
int usb_dc_deinit(void);
|
||||
|
||||
/**
|
||||
* @brief Attach USB for device connection
|
||||
*
|
||||
* Function to attach USB for device connection. Upon success, the USB PLL
|
||||
* is enabled, and the USB device is now capable of transmitting and receiving
|
||||
* on the USB bus and of generating interrupts.
|
||||
*
|
||||
* @return 0 on success, negative errno code on fail.
|
||||
*/
|
||||
int usb_dc_attach(void);
|
||||
|
||||
/**
|
||||
* @brief Detach the USB device
|
||||
*
|
||||
* Function to detach the USB device. Upon success, the USB hardware PLL
|
||||
* is powered down and USB communication is disabled.
|
||||
*
|
||||
* @return 0 on success, negative errno code on fail.
|
||||
*/
|
||||
int usb_dc_detach(void);
|
||||
|
||||
/**
|
||||
* @brief Set USB device address
|
||||
*
|
||||
@@ -155,7 +134,10 @@ int usbd_ep_clear_stall(const uint8_t ep);
|
||||
int usbd_ep_is_stalled(const uint8_t ep, uint8_t *stalled);
|
||||
|
||||
/**
|
||||
* @brief Write data to the specified endpoint with poll mode.
|
||||
* @brief Setup in ep transfer setting and start transfer.
|
||||
*
|
||||
* This function is asynchronous.
|
||||
* This function is similar to uart with tx dma.
|
||||
*
|
||||
* This function is called to write data to the specified endpoint. The
|
||||
* supplied usbd_endpoint_callback function will be called when data is transmitted
|
||||
@@ -166,77 +148,54 @@ int usbd_ep_is_stalled(const uint8_t ep, uint8_t *stalled);
|
||||
* @param[in] data Pointer to data to write
|
||||
* @param[in] data_len Length of the data requested to write. This may
|
||||
* be zero for a zero length status packet.
|
||||
* @param[out] ret_bytes Bytes scheduled for transmission. This value
|
||||
* may be NULL if the application expects all
|
||||
* bytes to be written
|
||||
*
|
||||
* @return 0 on success, negative errno code on fail.
|
||||
*/
|
||||
int usbd_ep_write(const uint8_t ep, const uint8_t *data, uint32_t data_len, uint32_t *ret_bytes);
|
||||
int usbd_ep_start_write(const uint8_t ep, const uint8_t *data, uint32_t data_len);
|
||||
|
||||
/**
|
||||
* @brief Read data from the specified endpoint
|
||||
* @brief Setup out ep transfer setting and start transfer.
|
||||
*
|
||||
* 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.
|
||||
* This function is asynchronous.
|
||||
* This function is similar to uart with rx dma.
|
||||
*
|
||||
* @param[in] ep Endpoint address corresponding to the one
|
||||
* listed in the device configuration table
|
||||
* @param[in] data Pointer to data buffer to write to
|
||||
* @param[in] max_data_len Max length of data to read
|
||||
* @param[out] read_bytes Number of bytes read. If data is NULL and
|
||||
* max_data_len is 0 the number of bytes
|
||||
* available for read should be returned.
|
||||
*
|
||||
* @return 0 on success, negative errno code on fail.
|
||||
*/
|
||||
int usbd_ep_read(const uint8_t ep, uint8_t *data, uint32_t max_data_len, uint32_t *read_bytes);
|
||||
|
||||
/**
|
||||
* @brief Write data to the specified endpoint with async mode.
|
||||
* This function is called to read data to the specified endpoint. The
|
||||
* supplied usbd_endpoint_callback function will be called when data is received
|
||||
* in.
|
||||
*
|
||||
* @param[in] ep Endpoint address corresponding to the one
|
||||
* listed in the device configuration table
|
||||
* @param[in] data Pointer to data to write
|
||||
* @param[in] data_len Length of the data requested to write. This may
|
||||
* be zero for a zero length status packet.
|
||||
* @param[in] data Pointer to data to read
|
||||
* @param[in] data_len Max length of the data requested to read.
|
||||
*
|
||||
* @return 0 on success, negative errno code on fail.
|
||||
*/
|
||||
int usbd_ep_write_async(const uint8_t ep, const uint8_t *data, uint32_t data_len);
|
||||
int usbd_ep_start_read(const uint8_t ep, uint8_t *data, uint32_t data_len);
|
||||
|
||||
/* usb dcd irq callback */
|
||||
|
||||
/**
|
||||
* @brief Read data from the specified endpoint with async mode.Actually,this function is used for these endpoint transferring with dma mode.
|
||||
*
|
||||
* @param[in] ep Endpoint address corresponding to the one
|
||||
* listed in the device configuration table
|
||||
* @param[in] data Pointer to data buffer to write to
|
||||
* @param[in] data_len Max length of data to read
|
||||
*
|
||||
* @return 0 on success, negative errno code on fail.
|
||||
* @brief Usb reset irq callback.
|
||||
*/
|
||||
int usbd_ep_read_async(const uint8_t ep, uint8_t *data, uint32_t data_len);
|
||||
|
||||
void usbd_event_reset_handler(void);
|
||||
/**
|
||||
* @brief Get actual read len when ep transfers completely by usbd_ep_read_async.
|
||||
*
|
||||
* @param[in] ep Endpoint address corresponding to the one
|
||||
* listed in the device configuration table
|
||||
* @return Actual read len.
|
||||
* @brief Usb setup packet recv irq callback.
|
||||
* @param[in] psetup setup packet.
|
||||
*/
|
||||
uint32_t usbd_ep_get_read_len(const uint8_t ep);
|
||||
|
||||
void usbd_event_ep0_setup_complete_handler(uint8_t *psetup);
|
||||
/**
|
||||
* @brief Get endpoint max packet size.
|
||||
*
|
||||
* @param[in] ep Endpoint address corresponding to the one
|
||||
* listed in the device configuration table
|
||||
* @return endpoint max packet size.
|
||||
* @brief In ep transfer complete irq callback.
|
||||
* @param[in] ep Endpoint address corresponding to the one
|
||||
* listed in the device configuration table
|
||||
* @param[in] nbytes How many nbytes have transferred.
|
||||
*/
|
||||
uint16_t usbd_ep_get_mps(const uint8_t ep);
|
||||
void usbd_event_ep_in_complete_handler(uint8_t ep, uint32_t nbytes);
|
||||
/**
|
||||
* @brief Out ep transfer complete irq callback.
|
||||
* @param[in] ep Endpoint address corresponding to the one
|
||||
* listed in the device configuration table
|
||||
* @param[in] nbytes How many nbytes have transferred.
|
||||
*/
|
||||
void usbd_event_ep_out_complete_handler(uint8_t ep, uint32_t nbytes);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
Reference in New Issue
Block a user