usb: Add end-point stall APIs and flow control APIS
USB class drivers may need to offload some work from upcall interrupt context to a background fiber. This requires some way to defer taking more data from host till the offloaded work completes. Two APIs are added to achieve this. Further USB class drivers sometimes need to set STALL condition on end-points to signal errors to host.These too are added. Change-Id: Ic973522c3394e23d7f9c4c67affc0cd050afc20f Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
This commit is contained in:
parent
2fe288b4aa
commit
7eab305593
4 changed files with 169 additions and 4 deletions
|
@ -233,4 +233,68 @@ int usb_write(uint8_t ep, const uint8_t *data, uint32_t data_len,
|
|||
int usb_read(uint8_t ep, uint8_t *data, uint32_t max_data_len,
|
||||
uint32_t *ret_bytes);
|
||||
|
||||
/*
|
||||
* @brief set STALL condition on the specified endpoint
|
||||
*
|
||||
* This function is called by USB device class handler code to set stall
|
||||
* conditionin on endpoint.
|
||||
*
|
||||
* @param[in] ep Endpoint address corresponding to the one listed in
|
||||
* the device configuration table
|
||||
*
|
||||
* @return 0 on success, negative errno code on fail
|
||||
*/
|
||||
int usb_ep_set_stall(uint8_t ep);
|
||||
|
||||
|
||||
/*
|
||||
* @brief clears STALL condition on the specified endpoint
|
||||
*
|
||||
* This function is called by USB device class handler code to clear stall
|
||||
* conditionin on endpoint.
|
||||
*
|
||||
* @param[in] ep Endpoint address corresponding to the one listed in
|
||||
* the device configuration table
|
||||
*
|
||||
* @return 0 on success, negative errno code on fail
|
||||
*/
|
||||
int usb_ep_clear_stall(uint8_t ep);
|
||||
|
||||
/**
|
||||
* @brief read data from the specified endpoint
|
||||
*
|
||||
* This is similar to usb_ep_read, the difference being that, it doesnt
|
||||
* 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 invoking usb_ep_read_continue() do so.
|
||||
*
|
||||
* @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 usb_ep_read_wait(uint8_t ep, uint8_t *data, uint32_t max_data_len,
|
||||
uint32_t *read_bytes);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Continue reading data from the endpoint
|
||||
*
|
||||
* Clear the endpoint NAK and enable the endpoint to accept more data
|
||||
* from the host. Usually called after usb_ep_read_wait() when the consumer
|
||||
* is fine to accept more data. Thus these calls together acts as flow control
|
||||
* meachanism.
|
||||
*
|
||||
* @param[in] ep Endpoint address corresponding to the one
|
||||
* listed in the device configuration table
|
||||
*
|
||||
* @return 0 on success, negative errno code on fail.
|
||||
*/
|
||||
int usb_ep_read_continue(uint8_t ep);
|
||||
|
||||
#endif /* USB_DEVICE_H_ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue